Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / UIAutomation / UIAutomationClient / System / Windows / Automation / PropertyCondition.cs / 1 / PropertyCondition.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
//
// History:
// 10/14/2003 : BrendanM - Created
//
//---------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Windows.Automation;
using MS.Internal.Automation;
namespace System.Windows.Automation
{
///
/// Flags that affect how a property value is compared in a PropertyCondition
///
[Flags]
#if (INTERNAL_COMPILE)
internal enum PropertyConditionFlags
#else
public enum PropertyConditionFlags
#endif
{
///Properties are to be compared using default options (eg. case-sensitive comparison for strings)
None = 0x00,
///For string comparisons, specifies that a case-insensitive comparison should be used
IgnoreCase = 0x01,
}
///
/// Condition that checks whether a property has the specified value
///
#if (INTERNAL_COMPILE)
internal class PropertyCondition : Condition
#else
public class PropertyCondition : Condition
#endif
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructor to create a condition that checks whether a property has the specified value
///
/// The property to check
/// The value to check the property for
public PropertyCondition( AutomationProperty property, object value )
{
Init(property, value, PropertyConditionFlags.None);
}
///
/// Constructor to create a condition that checks whether a property has the specified value
///
/// The property to check
/// The value to check the property for
/// Flags that affect the comparison
public PropertyCondition( AutomationProperty property, object value, PropertyConditionFlags flags )
{
Init(property, value, flags);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Returns the property that this condition is checking for
///
public AutomationProperty Property
{
get
{
return _property;
}
}
///
/// Returns the value of the property that this condition is checking for
///
public object Value
{
get
{
return _val;
}
}
///
/// Returns the flags used in this property comparison
///
public PropertyConditionFlags Flags
{
get
{
return _flags;
}
}
#endregion Public Properties
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
void Init(AutomationProperty property, object val, PropertyConditionFlags flags )
{
Misc.ValidateArgumentNonNull(property, "property");
AutomationPropertyInfo info;
if (!Schema.GetPropertyInfo(property, out info))
{
throw new ArgumentException(SR.Get(SRID.UnsupportedProperty));
}
// Check type is appropriate: NotSupported is allowed against any property,
// null is allowed for any reference type (ie not for value types), otherwise
// type must be assignable from expected type.
Type expectedType = info.Type;
if (val != AutomationElement.NotSupported &&
((val == null && expectedType.IsValueType)
|| (val != null && !expectedType.IsAssignableFrom(val.GetType()))))
{
throw new ArgumentException(SR.Get(SRID.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));
}
if ((flags & PropertyConditionFlags.IgnoreCase) != 0)
{
Misc.ValidateArgument(val is string, SRID.IgnoreCaseRequiresString);
}
// Some types are handled differently in managed vs unmanaged - handle those here...
if (val is AutomationElement)
{
// If this is a comparison against a Raw/LogicalElement,
// save the runtime ID instead of the element so that we
// can take it cross-proc if needed.
val = ((AutomationElement)val).GetRuntimeId();
}
else if (val is ControlType)
{
// If this is a control type, use the ID, not the CLR object
val = ((ControlType)val).Id;
}
else if (val is Rect)
{
Rect rc = (Rect)val;
val = new double[] { rc.Left, rc.Top, rc.Width, rc.Height };
}
else if (val is Point)
{
Point pt = (Point)val;
val = new double[] { pt.X, pt.Y };
}
else if (val is CultureInfo)
{
val = ((CultureInfo)val).LCID;
}
_property = property;
_val = val;
_flags = flags;
SetMarshalData(new UiaCoreApi.UiaPropertyCondition(_property.Id, _val, _flags));
}
#endregion Private Methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private AutomationProperty _property;
private object _val;
private PropertyConditionFlags _flags;
#endregion Private Fields
}
}
// 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:
// 10/14/2003 : BrendanM - Created
//
//---------------------------------------------------------------------------
using System;
using System.Globalization;
using System.Windows.Automation;
using MS.Internal.Automation;
namespace System.Windows.Automation
{
///
/// Flags that affect how a property value is compared in a PropertyCondition
///
[Flags]
#if (INTERNAL_COMPILE)
internal enum PropertyConditionFlags
#else
public enum PropertyConditionFlags
#endif
{
///Properties are to be compared using default options (eg. case-sensitive comparison for strings)
None = 0x00,
///For string comparisons, specifies that a case-insensitive comparison should be used
IgnoreCase = 0x01,
}
///
/// Condition that checks whether a property has the specified value
///
#if (INTERNAL_COMPILE)
internal class PropertyCondition : Condition
#else
public class PropertyCondition : Condition
#endif
{
//-----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
///
/// Constructor to create a condition that checks whether a property has the specified value
///
/// The property to check
/// The value to check the property for
public PropertyCondition( AutomationProperty property, object value )
{
Init(property, value, PropertyConditionFlags.None);
}
///
/// Constructor to create a condition that checks whether a property has the specified value
///
/// The property to check
/// The value to check the property for
/// Flags that affect the comparison
public PropertyCondition( AutomationProperty property, object value, PropertyConditionFlags flags )
{
Init(property, value, flags);
}
#endregion Constructors
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
#region Public Properties
///
/// Returns the property that this condition is checking for
///
public AutomationProperty Property
{
get
{
return _property;
}
}
///
/// Returns the value of the property that this condition is checking for
///
public object Value
{
get
{
return _val;
}
}
///
/// Returns the flags used in this property comparison
///
public PropertyConditionFlags Flags
{
get
{
return _flags;
}
}
#endregion Public Properties
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
void Init(AutomationProperty property, object val, PropertyConditionFlags flags )
{
Misc.ValidateArgumentNonNull(property, "property");
AutomationPropertyInfo info;
if (!Schema.GetPropertyInfo(property, out info))
{
throw new ArgumentException(SR.Get(SRID.UnsupportedProperty));
}
// Check type is appropriate: NotSupported is allowed against any property,
// null is allowed for any reference type (ie not for value types), otherwise
// type must be assignable from expected type.
Type expectedType = info.Type;
if (val != AutomationElement.NotSupported &&
((val == null && expectedType.IsValueType)
|| (val != null && !expectedType.IsAssignableFrom(val.GetType()))))
{
throw new ArgumentException(SR.Get(SRID.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));
}
if ((flags & PropertyConditionFlags.IgnoreCase) != 0)
{
Misc.ValidateArgument(val is string, SRID.IgnoreCaseRequiresString);
}
// Some types are handled differently in managed vs unmanaged - handle those here...
if (val is AutomationElement)
{
// If this is a comparison against a Raw/LogicalElement,
// save the runtime ID instead of the element so that we
// can take it cross-proc if needed.
val = ((AutomationElement)val).GetRuntimeId();
}
else if (val is ControlType)
{
// If this is a control type, use the ID, not the CLR object
val = ((ControlType)val).Id;
}
else if (val is Rect)
{
Rect rc = (Rect)val;
val = new double[] { rc.Left, rc.Top, rc.Width, rc.Height };
}
else if (val is Point)
{
Point pt = (Point)val;
val = new double[] { pt.X, pt.Y };
}
else if (val is CultureInfo)
{
val = ((CultureInfo)val).LCID;
}
_property = property;
_val = val;
_flags = flags;
SetMarshalData(new UiaCoreApi.UiaPropertyCondition(_property.Id, _val, _flags));
}
#endregion Private Methods
//-----------------------------------------------------
//
// Private Fields
//
//------------------------------------------------------
#region Private Fields
private AutomationProperty _property;
private object _val;
private PropertyConditionFlags _flags;
#endregion Private Fields
}
}
// 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
- LinearKeyFrames.cs
- Panel.cs
- HitTestResult.cs
- diagnosticsswitches.cs
- PathSegment.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- DelegatingTypeDescriptionProvider.cs
- Dynamic.cs
- TypeDependencyAttribute.cs
- TextTreeTextBlock.cs
- UriParserTemplates.cs
- NavigateEvent.cs
- ImageInfo.cs
- QuaternionIndependentAnimationStorage.cs
- WebBrowserNavigatedEventHandler.cs
- WindowsSysHeader.cs
- PolygonHotSpot.cs
- DecimalAnimation.cs
- DataSourceUtil.cs
- Rotation3DAnimationUsingKeyFrames.cs
- UnorderedHashRepartitionStream.cs
- HtmlInputReset.cs
- TransformFinalBlockRequest.cs
- SmiEventSink_Default.cs
- FamilyMap.cs
- PageParser.cs
- OleDbEnumerator.cs
- SqlClientMetaDataCollectionNames.cs
- StringSorter.cs
- SchemaMerger.cs
- NominalTypeEliminator.cs
- XPathNodePointer.cs
- RecordConverter.cs
- ControlParser.cs
- ToolStripPanelRow.cs
- ViewPort3D.cs
- LinqDataSourceUpdateEventArgs.cs
- ObjectCache.cs
- EntityStoreSchemaFilterEntry.cs
- Propagator.ExtentPlaceholderCreator.cs
- Helpers.cs
- SiteMapNodeItemEventArgs.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- SimpleExpression.cs
- HyperLink.cs
- ProxyGenerator.cs
- StateRuntime.cs
- SelectedGridItemChangedEvent.cs
- HostedElements.cs
- Binding.cs
- DataGridViewColumnCollection.cs
- WebPartConnectionsCloseVerb.cs
- ProcessInfo.cs
- StdValidatorsAndConverters.cs
- CodeSnippetStatement.cs
- RIPEMD160Managed.cs
- ErrorHandler.cs
- MethodSet.cs
- UnsafeNativeMethods.cs
- XmlSerializationGeneratedCode.cs
- CopyOfAction.cs
- TextSpanModifier.cs
- RoleService.cs
- BaseProcessor.cs
- EntityParameter.cs
- OrderedDictionary.cs
- PerformanceCounterNameAttribute.cs
- GridViewCancelEditEventArgs.cs
- FixedSOMElement.cs
- RemotingConfigParser.cs
- LocalizeDesigner.cs
- StrongNameKeyPair.cs
- InputMethodStateTypeInfo.cs
- StateMachineDesignerPaint.cs
- CodeAccessPermission.cs
- XmlSchemaObject.cs
- MethodAccessException.cs
- DoubleKeyFrameCollection.cs
- DataGridComponentEditor.cs
- ClientScriptManagerWrapper.cs
- MaskInputRejectedEventArgs.cs
- PathSegment.cs
- ObjectContextServiceProvider.cs
- MdImport.cs
- WindowCollection.cs
- PenContext.cs
- DisplayInformation.cs
- AsyncPostBackTrigger.cs
- InternalDuplexChannelListener.cs
- AnonymousIdentificationModule.cs
- DbQueryCommandTree.cs
- FramingEncoders.cs
- OutputCacheModule.cs
- ReleaseInstanceMode.cs
- TraceListener.cs
- XsltLoader.cs
- ComponentEditorForm.cs
- ToolStripKeyboardHandlingService.cs
- ISessionStateStore.cs
- DiagnosticTraceSource.cs