Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Recognition / SrgsGrammar / SrgsSubset.cs / 1 / SrgsSubset.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
//
// History:
// 5/1/2004 jeanfp Created from the Kurosawa Code
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Globalization;
using System.Speech.Internal;
using System.Speech.Internal.SrgsParser;
using System.Xml;
namespace System.Speech.Recognition.SrgsGrammar
{
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset"]/*' />
// Note that currently if multiple words are stored in a Subset they are treated internally
// and in the result as multiple tokens.
[Serializable]
[DebuggerDisplay ("{DebuggerDisplayString ()}")]
public class SrgsSubset : SrgsElement, ISubset
{
//*******************************************************************
//
// Constructors
//
//*******************************************************************
#region Constructors
/// TODOC
public SrgsSubset (string text)
: this (text, SubsetMatchingMode.Subsequence)
{
}
/// TODOC
public SrgsSubset (string text, SubsetMatchingMode matchingMode)
{
Helpers.ThrowIfEmptyOrNull (text, "text");
if (matchingMode != SubsetMatchingMode.OrderedSubset && matchingMode != SubsetMatchingMode.Subsequence && matchingMode != SubsetMatchingMode.OrderedSubsetContentRequired && matchingMode != SubsetMatchingMode.SubsequenceContentRequired)
{
throw new ArgumentException (SR.Get (SRID.InvalidSubsetAttribute), "matchingMode");
}
_matchMode = matchingMode;
_text = text.Trim (Helpers._achTrimChars);
Helpers.ThrowIfEmptyOrNull (_text, "text");
}
#endregion
//********************************************************************
//
// Public Properties
//
//*******************************************************************
#region public Properties
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset.Text"]/*' />
public SubsetMatchingMode MatchingMode
{
get
{
return _matchMode;
}
set
{
if (value != SubsetMatchingMode.OrderedSubset && value != SubsetMatchingMode.Subsequence && value != SubsetMatchingMode.OrderedSubsetContentRequired && value != SubsetMatchingMode.SubsequenceContentRequired)
{
throw new ArgumentException (SR.Get (SRID.InvalidSubsetAttribute), "value");
}
_matchMode = value;
}
}
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset.Pronunciation"]/*' />
public string Text
{
get
{
return _text;
}
set
{
Helpers.ThrowIfEmptyOrNull (value, "value");
value = value.Trim (Helpers._achTrimChars);
Helpers.ThrowIfEmptyOrNull (value, "value");
_text = value;
}
}
#endregion
//********************************************************************
//
// Internal methods
//
//********************************************************************
#region Internal methods
internal override void WriteSrgs (XmlWriter writer)
{
// Write _text
writer.WriteStartElement ("sapi", "subset", XmlParser.sapiNamespace);
if (_matchMode != SubsetMatchingMode.Subsequence)
{
string sMatchMode = null;
switch (_matchMode)
{
case SubsetMatchingMode.Subsequence:
sMatchMode = "subsequence";
break;
case SubsetMatchingMode.OrderedSubset:
sMatchMode = "ordered-subset";
break;
case SubsetMatchingMode.SubsequenceContentRequired:
sMatchMode = "subsequence-content-required";
break;
case SubsetMatchingMode.OrderedSubsetContentRequired:
sMatchMode = "ordered-subset-content-required";
break;
}
writer.WriteAttributeString ("sapi", "match", XmlParser.sapiNamespace, sMatchMode);
}
// If an empty string is provided, skip the WriteString
// to have the XmlWrite to put rather than
if (_text != null && _text.Length > 0)
{
writer.WriteString (_text);
}
writer.WriteEndElement ();
}
internal override void Validate (SrgsGrammar grammar)
{
grammar.HasSapiExtension = true;
base.Validate (grammar);
}
internal override string DebuggerDisplayString ()
{
return _text + " [" + _matchMode.ToString () + "]";
}
#endregion
//*******************************************************************
//
// Private Fields
//
//********************************************************************
#region Private Fields
private SubsetMatchingMode _matchMode;
private string _text;
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
//
// History:
// 5/1/2004 jeanfp Created from the Kurosawa Code
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Globalization;
using System.Speech.Internal;
using System.Speech.Internal.SrgsParser;
using System.Xml;
namespace System.Speech.Recognition.SrgsGrammar
{
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset"]/*' />
// Note that currently if multiple words are stored in a Subset they are treated internally
// and in the result as multiple tokens.
[Serializable]
[DebuggerDisplay ("{DebuggerDisplayString ()}")]
public class SrgsSubset : SrgsElement, ISubset
{
//*******************************************************************
//
// Constructors
//
//*******************************************************************
#region Constructors
/// TODOC
public SrgsSubset (string text)
: this (text, SubsetMatchingMode.Subsequence)
{
}
/// TODOC
public SrgsSubset (string text, SubsetMatchingMode matchingMode)
{
Helpers.ThrowIfEmptyOrNull (text, "text");
if (matchingMode != SubsetMatchingMode.OrderedSubset && matchingMode != SubsetMatchingMode.Subsequence && matchingMode != SubsetMatchingMode.OrderedSubsetContentRequired && matchingMode != SubsetMatchingMode.SubsequenceContentRequired)
{
throw new ArgumentException (SR.Get (SRID.InvalidSubsetAttribute), "matchingMode");
}
_matchMode = matchingMode;
_text = text.Trim (Helpers._achTrimChars);
Helpers.ThrowIfEmptyOrNull (_text, "text");
}
#endregion
//********************************************************************
//
// Public Properties
//
//*******************************************************************
#region public Properties
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset.Text"]/*' />
public SubsetMatchingMode MatchingMode
{
get
{
return _matchMode;
}
set
{
if (value != SubsetMatchingMode.OrderedSubset && value != SubsetMatchingMode.Subsequence && value != SubsetMatchingMode.OrderedSubsetContentRequired && value != SubsetMatchingMode.SubsequenceContentRequired)
{
throw new ArgumentException (SR.Get (SRID.InvalidSubsetAttribute), "value");
}
_matchMode = value;
}
}
/// TODOC <_include file='doc\Subset.uex' path='docs/doc[@for="Subset.Pronunciation"]/*' />
public string Text
{
get
{
return _text;
}
set
{
Helpers.ThrowIfEmptyOrNull (value, "value");
value = value.Trim (Helpers._achTrimChars);
Helpers.ThrowIfEmptyOrNull (value, "value");
_text = value;
}
}
#endregion
//********************************************************************
//
// Internal methods
//
//********************************************************************
#region Internal methods
internal override void WriteSrgs (XmlWriter writer)
{
// Write _text
writer.WriteStartElement ("sapi", "subset", XmlParser.sapiNamespace);
if (_matchMode != SubsetMatchingMode.Subsequence)
{
string sMatchMode = null;
switch (_matchMode)
{
case SubsetMatchingMode.Subsequence:
sMatchMode = "subsequence";
break;
case SubsetMatchingMode.OrderedSubset:
sMatchMode = "ordered-subset";
break;
case SubsetMatchingMode.SubsequenceContentRequired:
sMatchMode = "subsequence-content-required";
break;
case SubsetMatchingMode.OrderedSubsetContentRequired:
sMatchMode = "ordered-subset-content-required";
break;
}
writer.WriteAttributeString ("sapi", "match", XmlParser.sapiNamespace, sMatchMode);
}
// If an empty string is provided, skip the WriteString
// to have the XmlWrite to put rather than
if (_text != null && _text.Length > 0)
{
writer.WriteString (_text);
}
writer.WriteEndElement ();
}
internal override void Validate (SrgsGrammar grammar)
{
grammar.HasSapiExtension = true;
base.Validate (grammar);
}
internal override string DebuggerDisplayString ()
{
return _text + " [" + _matchMode.ToString () + "]";
}
#endregion
//*******************************************************************
//
// Private Fields
//
//********************************************************************
#region Private Fields
private SubsetMatchingMode _matchMode;
private string _text;
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CookieProtection.cs
- CodeMethodInvokeExpression.cs
- PageClientProxyGenerator.cs
- CorrelationTokenTypeConvertor.cs
- XPathPatternParser.cs
- TTSVoice.cs
- ErrorFormatter.cs
- ProcessManager.cs
- CodeMemberProperty.cs
- WindowsStatusBar.cs
- CapabilitiesAssignment.cs
- ContractMapping.cs
- OdbcDataReader.cs
- FlagsAttribute.cs
- EmissiveMaterial.cs
- Point.cs
- StreamGeometryContext.cs
- DataGridViewRowPrePaintEventArgs.cs
- FixedSOMPage.cs
- IPEndPoint.cs
- LinqDataSourceValidationException.cs
- ActivityDesignerAccessibleObject.cs
- Mapping.cs
- ReaderOutput.cs
- DirectionalLight.cs
- SchemaNames.cs
- ControlUtil.cs
- GB18030Encoding.cs
- KeySplineConverter.cs
- HtmlControl.cs
- XmlDeclaration.cs
- ScriptIgnoreAttribute.cs
- MetabaseServerConfig.cs
- RegexGroup.cs
- VisualBasicHelper.cs
- DesignerSerializerAttribute.cs
- SoapCodeExporter.cs
- SemanticResolver.cs
- DocumentGridContextMenu.cs
- DesignerActionList.cs
- SqlPersonalizationProvider.cs
- AutomationPropertyInfo.cs
- ClientRequest.cs
- Range.cs
- PropertyBuilder.cs
- ClientTargetCollection.cs
- CodeAccessSecurityEngine.cs
- BCryptNative.cs
- CacheMode.cs
- KeyEvent.cs
- UnitySerializationHolder.cs
- FigureHelper.cs
- EnumBuilder.cs
- RelatedCurrencyManager.cs
- ObjectAssociationEndMapping.cs
- SignatureToken.cs
- Signature.cs
- PointAnimation.cs
- XmlDataSourceNodeDescriptor.cs
- TextServicesCompartmentEventSink.cs
- XmlElementAttribute.cs
- SwitchAttribute.cs
- SafeNativeMethods.cs
- _StreamFramer.cs
- XmlSchemaSimpleContent.cs
- StreamWithDictionary.cs
- Rect.cs
- RowCache.cs
- InkCanvasInnerCanvas.cs
- CreateUserErrorEventArgs.cs
- SQLConvert.cs
- TimeSpanStorage.cs
- ThreadExceptionDialog.cs
- MetadataItemSerializer.cs
- TextServicesProperty.cs
- BuiltInPermissionSets.cs
- PiiTraceSource.cs
- SqlProviderManifest.cs
- CallbackException.cs
- HierarchicalDataTemplate.cs
- HostedTransportConfigurationManager.cs
- HebrewCalendar.cs
- HostSecurityManager.cs
- ConditionalAttribute.cs
- baseaxisquery.cs
- ComboBoxAutomationPeer.cs
- TypeBuilderInstantiation.cs
- QueryConverter.cs
- XPathDescendantIterator.cs
- MapPathBasedVirtualPathProvider.cs
- ObjectQueryState.cs
- XmlReaderSettings.cs
- PresentationTraceSources.cs
- TextPointerBase.cs
- ResourceReferenceExpressionConverter.cs
- SoapMessage.cs
- prefixendpointaddressmessagefiltertable.cs
- ScriptBehaviorDescriptor.cs
- CommandValueSerializer.cs
- ActivityExecutionContext.cs