Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Internal / SrgsCompiler / OneOf.cs / 1 / OneOf.cs
//------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------- #region Using directives using System; using System.Speech.Internal.SrgsParser; #endregion namespace System.Speech.Internal.SrgsCompiler { internal class OneOf : ParseElementCollection, IOneOf { //******************************************************************* // // Constructors // //******************************************************************* #region Constructors ////// Process the 'one-of' element. /// /// /// public OneOf (Rule rule, Backend backend) : base (backend, rule) { // Create a start and end start. _startState = _backend.CreateNewState (rule); _endState = _backend.CreateNewState (rule); //Add before the start state an epsilon arc _startArc = _backend.EpsilonTransition (1.0f); _startArc.End = _startState; //Add after the end state an epsilon arc _endArc = _backend.EpsilonTransition (1.0f); _endArc.Start = _endState; } #endregion //******************************************************************** // // Internal Method // //******************************************************************* #region Internal Method ////// Process the '/one-of' element. /// Connects all the arsc into an exit enf point. /// /// Verify OneOf contains at least one child 'item'. /// /// void IElement.PostParse (IElement parentElement) { if (_startArc.End.OutArcs.IsEmpty) { XmlParser.ThrowSrgsException (SRID.EmptyOneOf); } // Remove the extraneous arc and state if possible at the start and end _startArc = TrimStart (_startArc, _backend); _endArc = TrimEnd (_endArc, _backend); // Connect the one-of to the parrent base.PostParse ((ParseElementCollection) parentElement); } #endregion //******************************************************************** // // Protected Method // //******************************************************************** #region Protected Method ////// Adds a new arc to the one-of /// /// /// internal override void AddArc (Arc start, Arc end) { start = TrimStart (start, _backend); end = TrimEnd (end, _backend); State endStartState = end.Start; State startEndState = start.End; // Connect the previous arc with the 'start' set the intertion point if (start.IsEpsilonTransition & start.IsPropertylessTransition && startEndState != null && startEndState.InArcs.IsEmpty) { System.Diagnostics.Debug.Assert (start.End == startEndState); start.End = null; _backend.MoveOutputTransitionsAndDeleteState (startEndState, _startState); } else { start.Start = _startState; } // Connect with the epsilon transition at the end if (end.IsEpsilonTransition & end.IsPropertylessTransition && endStartState != null && endStartState.OutArcs.IsEmpty) { System.Diagnostics.Debug.Assert (end.Start == endStartState); end.Start = null; _backend.MoveInputTransitionsAndDeleteState (endStartState, _endState); } else { end.End = _endState; } } #endregion //******************************************************************* // // Protected Method // //******************************************************************** #region Protected Method private State _startState; private State _endState; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------- #region Using directives using System; using System.Speech.Internal.SrgsParser; #endregion namespace System.Speech.Internal.SrgsCompiler { internal class OneOf : ParseElementCollection, IOneOf { //******************************************************************* // // Constructors // //******************************************************************* #region Constructors ////// Process the 'one-of' element. /// /// /// public OneOf (Rule rule, Backend backend) : base (backend, rule) { // Create a start and end start. _startState = _backend.CreateNewState (rule); _endState = _backend.CreateNewState (rule); //Add before the start state an epsilon arc _startArc = _backend.EpsilonTransition (1.0f); _startArc.End = _startState; //Add after the end state an epsilon arc _endArc = _backend.EpsilonTransition (1.0f); _endArc.Start = _endState; } #endregion //******************************************************************** // // Internal Method // //******************************************************************* #region Internal Method ////// Process the '/one-of' element. /// Connects all the arsc into an exit enf point. /// /// Verify OneOf contains at least one child 'item'. /// /// void IElement.PostParse (IElement parentElement) { if (_startArc.End.OutArcs.IsEmpty) { XmlParser.ThrowSrgsException (SRID.EmptyOneOf); } // Remove the extraneous arc and state if possible at the start and end _startArc = TrimStart (_startArc, _backend); _endArc = TrimEnd (_endArc, _backend); // Connect the one-of to the parrent base.PostParse ((ParseElementCollection) parentElement); } #endregion //******************************************************************** // // Protected Method // //******************************************************************** #region Protected Method ////// Adds a new arc to the one-of /// /// /// internal override void AddArc (Arc start, Arc end) { start = TrimStart (start, _backend); end = TrimEnd (end, _backend); State endStartState = end.Start; State startEndState = start.End; // Connect the previous arc with the 'start' set the intertion point if (start.IsEpsilonTransition & start.IsPropertylessTransition && startEndState != null && startEndState.InArcs.IsEmpty) { System.Diagnostics.Debug.Assert (start.End == startEndState); start.End = null; _backend.MoveOutputTransitionsAndDeleteState (startEndState, _startState); } else { start.Start = _startState; } // Connect with the epsilon transition at the end if (end.IsEpsilonTransition & end.IsPropertylessTransition && endStartState != null && endStartState.OutArcs.IsEmpty) { System.Diagnostics.Debug.Assert (end.Start == endStartState); end.Start = null; _backend.MoveInputTransitionsAndDeleteState (endStartState, _endState); } else { end.End = _endState; } } #endregion //******************************************************************* // // Protected Method // //******************************************************************** #region Protected Method private State _startState; private State _endState; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SplitterDesigner.cs
- NotifyCollectionChangedEventArgs.cs
- WaitForChangedResult.cs
- ConnectivityStatus.cs
- SystemUnicastIPAddressInformation.cs
- CharKeyFrameCollection.cs
- Variable.cs
- CaseKeyBox.xaml.cs
- ColumnMapProcessor.cs
- _BasicClient.cs
- GZipStream.cs
- SequentialUshortCollection.cs
- X509Extension.cs
- SystemResourceKey.cs
- HtmlShim.cs
- Visitors.cs
- StringUtil.cs
- ObjectTypeMapping.cs
- PagesSection.cs
- ColumnMapTranslator.cs
- PropertySourceInfo.cs
- Encoding.cs
- CommonDialog.cs
- DocumentReference.cs
- DbCommandTree.cs
- ExpressionsCollectionEditor.cs
- XmlQueryStaticData.cs
- GradientStopCollection.cs
- shaperfactoryquerycachekey.cs
- PnrpPermission.cs
- DataServiceHostWrapper.cs
- XmlTextReaderImpl.cs
- AvtEvent.cs
- NamedPermissionSet.cs
- InternalTransaction.cs
- SortExpressionBuilder.cs
- CommandLibraryHelper.cs
- AppliedDeviceFiltersEditor.cs
- Delegate.cs
- SpellerInterop.cs
- httpstaticobjectscollection.cs
- SerialPinChanges.cs
- ZipPackagePart.cs
- GridViewColumnCollectionChangedEventArgs.cs
- TimelineCollection.cs
- WebPartEditorCancelVerb.cs
- RuntimeIdentifierPropertyAttribute.cs
- DataRelationCollection.cs
- XmlDocumentType.cs
- PeerEndPoint.cs
- SafeNativeMethodsOther.cs
- Transform.cs
- XmlEntity.cs
- ThemeConfigurationDialog.cs
- TraceFilter.cs
- LeafCellTreeNode.cs
- TimeEnumHelper.cs
- UTF32Encoding.cs
- _FtpControlStream.cs
- SqlUnionizer.cs
- GridViewColumnHeader.cs
- BitSet.cs
- Overlapped.cs
- OperationCanceledException.cs
- ProfileInfo.cs
- QueryableDataSourceHelper.cs
- DataObjectAttribute.cs
- RawContentTypeMapper.cs
- DisableDpiAwarenessAttribute.cs
- TextFormatterHost.cs
- SQLMoneyStorage.cs
- ConstructorNeedsTagAttribute.cs
- TokenBasedSetEnumerator.cs
- ResourceManagerWrapper.cs
- PageRanges.cs
- RangeValidator.cs
- BitmapEffect.cs
- ColorContext.cs
- Baml2006Reader.cs
- ManifestSignedXml.cs
- Types.cs
- UserPreferenceChangingEventArgs.cs
- SafeRightsManagementSessionHandle.cs
- DataGridViewRowCancelEventArgs.cs
- __Filters.cs
- BehaviorEditorPart.cs
- Size3D.cs
- Win32SafeHandles.cs
- CacheSection.cs
- Parallel.cs
- Win32MouseDevice.cs
- hwndwrapper.cs
- HostingEnvironmentSection.cs
- DataControlCommands.cs
- FormClosedEvent.cs
- SoapCodeExporter.cs
- StreamFormatter.cs
- SwitchLevelAttribute.cs
- VBCodeProvider.cs
- ChannelCacheSettings.cs