Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Management / Automation / UMPAttributes.cs / 1305376 / UMPAttributes.cs
using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.Diagnostics; using System.Globalization; namespace System.Management.Instrumentation { #region CommonUMPAttributes ////// This attribute declares a class to be exposed as a management /// interface. /// /// It declares the noun to expose in Monad and /// optionally the XML Namespace to expose the class /// through WMI.NET and WS-Management. /// /// /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false,Inherited=false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementEntityAttribute : Attribute { public ManagementEntityAttribute() { } public string Name { get { return _nounName; } set { _nounName = value; } } public bool External { get { return _isExternalClass; } set { _isExternalClass = value; } } public bool Singleton { get { return _isSingleton; } set { _isSingleton = value; } } private string _nounName; private bool _isExternalClass = false; private bool _isSingleton = false; /* ////// Reference to the Type which acts as a factory for instances /// of this class. /// /// public Type Factory { get { return _factory; } set { _factory = value; } } private Type _factory; public Type FactoryFor { get { return _factoryfor; } set { _factoryfor = value; } } private Type _factoryfor; */ } #endregion CommonUMPAttributes ////// WMI is able to deal with Decoupled and Hosted providers. /// UserHosted for component loaded inproc to the client is not allowed for .NET extension providers. public enum ManagementHostingModel { Decoupled, NetworkService, LocalService, LocalSystem } [AttributeUsage(AttributeTargets.Assembly)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class WmiConfigurationAttribute : Attribute { private string _Scope = null; private string _SecurityRestriction = null; private string _NamespaceSecurity = null; private ManagementHostingModel _HostingModel = ManagementHostingModel.Decoupled; private string _HostingGroup = null; private bool _IdentifyLevel = true; public WmiConfigurationAttribute(string scope) { string namespaceName = scope; if (namespaceName != null) namespaceName = namespaceName.Replace('/', '\\'); if (namespaceName == null || namespaceName.Length == 0) namespaceName = "root\\default"; bool once = true; foreach (string namespacePart in namespaceName.Split('\\')) { if (namespacePart.Length == 0 || (once && String.Compare(namespacePart, "root", StringComparison.OrdinalIgnoreCase) != 0) // Must start with 'root' || !Regex.Match(namespacePart, @"^[a-z,A-Z]").Success // All parts must start with letter || Regex.Match(namespacePart, @"_$").Success // Must not end with an underscore || Regex.Match(namespacePart, @"[^a-z,A-Z,0-9,_,\u0080-\uFFFF]").Success) // Only letters, digits, or underscores { //ManagementException.ThrowWithExtendedInfo(ManagementStatus.InvalidNamespace); } once = false; } _Scope = namespaceName; } /// /// The security descriptor used by instrumentation to filter the providers public string SecurityRestriction { get { return _SecurityRestriction; } set { _SecurityRestriction = value; } } public string NamespaceSecurity { get { return _NamespaceSecurity; } set { _NamespaceSecurity = value; } } public bool IdentifyLevel { get { return _IdentifyLevel; } set { _IdentifyLevel = value; } } public ManagementHostingModel HostingModel { get { return _HostingModel; } set { _HostingModel = value; } } /// /// To support provider separation public string HostingGroup { get { return _HostingGroup; } set { _HostingGroup = value; } } /// /// Scope of the assembly in the target instrumentation space /// In WMI speak is the namespace public string Scope { get { return _Scope; } } } /// /// This is the base class for all attribute which can be applied /// to members of the Automation class. /// /// ////// The Exception member tells Monad which exception coming from the /// member can be treated as non-fatal errors for the pipeline. /// /// [AttributeUsage(AttributeTargets.All)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public abstract class ManagementMemberAttribute : Attribute { ////// The exceptions that can be thrown by the member. /// /// public string Name { get { return _Name; } set { _Name = value; } } private string _Name; } ////// This abstract attribute determines how one would get an instance of the class. /// You can get an instance by: /// 1) Binding to an instance [Bind] /// 2) Creating an instance [Create] /// 3) Using a factory to get an instance [Factory] /// For any particular NOUN, there can only be ONE way to get instances. /// /// [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public abstract class ManagementNewInstanceAttribute : ManagementMemberAttribute { } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementBindAttribute : ManagementNewInstanceAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public ManagementBindAttribute() { } public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementCreateAttribute : ManagementNewInstanceAttribute { ////////// Declares the type that the output should be ///// treated as even if the return value is of ///// type System.Object. ///// ///// } ////// This attribute determines how one would remove a real object /// /// /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementRemoveAttribute : ManagementMemberAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } ////// This attribute defines the enumerator of instances of the class /// /// [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementEnumeratorAttribute : ManagementNewInstanceAttribute { /* ////// Declares the member as an enumerator for other classes. The other /// Type must specify the Factory property of the AutomationAttribute to /// be this Type. /// /// public Type FactoryFor { get { return _factoryFor; } set { _factoryFor = value; } } private Type _factoryFor; */ ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } ////// Exposes a method or property as a Probe /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementProbeAttribute : ManagementMemberAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } #region Task ////// Exposes a method as a task. /// /// ////// The TaskAttribute is placed on a method to expose it as a management task. /// /// If the task enumerates manageable objects, the task declaration should set /// the Enumeration option to true. /// /// ISSUE-2005/06/08-jeffjon /// Does the task need a Schema parameter or should we have a separate Probe /// attribute? /// /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementTaskAttribute : ManagementMemberAttribute { public ManagementTaskAttribute() { } ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } #endregion Task #region Naming ////// This attribute defines the ID (key) property of the class. /// /// ////// For Monad, this property is used to do filtering of enumerations. /// /// If used on a parameter, then the attribute must also exist on a property in /// the class. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementKeyAttribute : ManagementMemberAttribute { public ManagementKeyAttribute() { } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementReferenceAttribute : Attribute { public ManagementReferenceAttribute() { } public string Type { get { return _Type; } set { _Type = value; } } private string _Type; } #endregion Naming #region Configuration ////// Defines a property as the storage for configuration data. /// /// public enum ManagementConfigurationType { Apply, OnCommit }; [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementConfigurationAttribute : ManagementMemberAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public ManagementConfigurationAttribute() { updateMode = ManagementConfigurationType.Apply; } public ManagementConfigurationType Mode { get { return updateMode; } set { updateMode = value; } } public Type Schema { get { return _schema; } set { _schema = value; } } private ManagementConfigurationType updateMode; private Type _schema; } [AttributeUsage(AttributeTargets.Method)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementCommitAttribute : ManagementMemberAttribute { } ////// This attribute defines the naming (user friendly name) of method parameters /// /// [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] sealed public class ManagementNameAttribute : Attribute { public ManagementNameAttribute(string name) { _Name = name; } public string Name { get { return _Name; } } private string _Name; } #endregion Configuration /* [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class FactoryAttribute : NewInstanceAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public FactoryAttribute() { } public FactoryAttribute(Type t) { } public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class FactoryForAttribute : ManagementMemberAttribute { ////// Declares the type that the output should be /// treated as even if the return value is of /// type System.Object. /// /// public FactoryForAttribute(Type t) { } public Type Schema { get { return _schema; } set { _schema = value; } } private Type _schema; } #region Constraints ////// Constraints the member/option to a minimum and/or maximum length. /// /// ////// This can be used for strings or collections. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ValidateLengthAttribute : Attribute { ////// The minimum length /// /// public int Min { get { return _min; } set { _min = value; } } private int _min = int.MinValue; ////// The maximum length /// /// public int Max { get { return _max; } set { _max = value; } } private int _max = int.MaxValue; } ////// Constraints the member/option to a range of values. /// /// ////// This can be used for strings or collections. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ValidateRangeAttribute : Attribute { ////// Defines the range for the constraint /// /// /// /// The minimum of the range. /// /// /// /// The maximum of the range. /// /// public ValidateRangeAttribute(object lower, object upper) { this._lower = lower; this._upper = upper; } ////// The lower bound for the range /// /// public object Lower { get { return _lower; } set { _lower = value; } } private object _lower; ////// The upper bound for the range /// /// public object Upper { get { return _upper; } set { _upper = value; } } private object _upper; } ////// Constraints the member/option to a pattern represented by a regular expression /// /// ////// This can be used for strings or collections. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ValidatePatternAttribute : Attribute { ////// Defines the pattern for the constraint /// /// /// /// The minimum of the range. /// /// public ValidatePatternAttribute(string pattern) { this._pattern = pattern; } ////// The pattern which defines the constraint /// /// public string Pattern { get { return _pattern; } set { _pattern = value; } } private string _pattern; ////// The options for the regular expression defined by the pattern. /// /// public RegexOptions Options { get { return _options; } set { _options = value; } } private RegexOptions _options = RegexOptions.IgnoreCase; } ////// Constraints the member/option to a number of values. /// /// ////// This can be used for strings or collections. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ValidateCountAttribute : Attribute { ////// Defines the minimum and maximum number of elements. /// /// /// /// The minimum minimum number of elements. /// /// /// /// The maximum number of elements. /// /// public ValidateCountAttribute(int minimum, int maximum) { } ////// The minimum number of elements /// /// public int Minimum; ////// The maximum number of elements /// /// public int Maximum; } ////// Constraints the member/option to a set of values. /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ValidateSetAttribute : Attribute { ////// Defines the range for the constraint /// /// /// /// The valid values for the set. /// /// public ValidateSetAttribute(params string[] validValues) { } ////// The valid values for the set. /// /// public string[] ValidValues { get { return null; } set { } } ////// If true, the values are compared in a case-insensitive way. /// If false, the set is constrained to exact matches. /// /// public bool IgnoreCase { get { return _ignoreCase; } set { _ignoreCase = value; } } private bool _ignoreCase = true; } #endregion Constraints ////// Specifies the options for a task. /// /// ////// When placed on a parameter of a task method, this attribute /// describes the options for the parameter. /// /// [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = true)] [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] public class ManagementTaskOptionAttribute : Attribute { ////// If true, the option must be specified. /// /// ////// If false, and the InitialValue is not specified, then /// an initial value will be deduced using the "default" /// keyword in C#. /// /// public bool Mandatory { get { return _mandatory; } set { _mandatory = value; } } private bool _mandatory = true; ////// The initial value of the parameter. Used if Mandatory=false. /// /// public object InitialValue { get { return _initialValue; } set { _initialValue = value; } } private object _initialValue; ////// Monad specific - provides mapping of the pipeline object /// to the parameter value. /// /// public bool ValueFromPipeline { get { return _valueFromPipeline; } set { _valueFromPipeline = value; } } private bool _valueFromPipeline; ////// Monad specific - provides mapping of the pipeline object's /// property with the same name as the parameter to the parameter /// value. /// public bool ValueFromPipelineByPropertyName { get { return _valueFromPipelineByPropertyName; } set { _valueFromPipelineByPropertyName = value; } } private bool _valueFromPipelineByPropertyName; } */ }; // 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
- SafeMILHandleMemoryPressure.cs
- UnconditionalPolicy.cs
- XhtmlTextWriter.cs
- MethodInfo.cs
- StyleHelper.cs
- QilCloneVisitor.cs
- LocatorPartList.cs
- TableDetailsRow.cs
- XmlSchemaObject.cs
- OutputCacheProfile.cs
- ListBoxItemAutomationPeer.cs
- PathFigureCollection.cs
- UrlMappingsModule.cs
- VoiceSynthesis.cs
- GeneralTransform2DTo3D.cs
- GeneratedCodeAttribute.cs
- ReadOnlyObservableCollection.cs
- PiiTraceSource.cs
- ScalarOps.cs
- FontSource.cs
- HttpHandlerAction.cs
- Page.cs
- SqlNotificationRequest.cs
- ParameterBinding.cs
- BooleanToVisibilityConverter.cs
- TreeViewAutomationPeer.cs
- SmiXetterAccessMap.cs
- LineUtil.cs
- BrowserCapabilitiesCodeGenerator.cs
- ClientTargetSection.cs
- WindowClosedEventArgs.cs
- BaseCodeDomTreeGenerator.cs
- PropertyValueUIItem.cs
- SqlNotificationEventArgs.cs
- WebScriptMetadataMessageEncoderFactory.cs
- CatalogZone.cs
- ToolboxService.cs
- Label.cs
- SoapCodeExporter.cs
- DLinqTableProvider.cs
- FormsAuthenticationUser.cs
- LineServices.cs
- Pool.cs
- XmlILOptimizerVisitor.cs
- QuaternionKeyFrameCollection.cs
- NativeMethods.cs
- HtmlInputRadioButton.cs
- ProfileService.cs
- ThreadStartException.cs
- WeakReference.cs
- SmtpFailedRecipientException.cs
- InputMethodStateTypeInfo.cs
- SystemResourceKey.cs
- RecognizedPhrase.cs
- ToolStripPanelRow.cs
- XmlSchemaImport.cs
- DistinctQueryOperator.cs
- CodeGeneratorOptions.cs
- DbUpdateCommandTree.cs
- AttributeQuery.cs
- ColumnWidthChangedEvent.cs
- UserControlParser.cs
- StrokeIntersection.cs
- NamedObject.cs
- RequestQueryParser.cs
- FileClassifier.cs
- BoundsDrawingContextWalker.cs
- _NegoStream.cs
- MimeImporter.cs
- MarginsConverter.cs
- MediaContext.cs
- ExpandSegmentCollection.cs
- XmlSchemaSimpleContent.cs
- SqlCachedBuffer.cs
- PerspectiveCamera.cs
- OdbcUtils.cs
- RouteData.cs
- PlaceHolder.cs
- LinqToSqlWrapper.cs
- DockPatternIdentifiers.cs
- RotationValidation.cs
- Menu.cs
- GeneratedCodeAttribute.cs
- TypeViewSchema.cs
- DataGridColumn.cs
- Helper.cs
- ColorBlend.cs
- LOSFormatter.cs
- EmbeddedMailObjectsCollection.cs
- FileDialogPermission.cs
- StreamWriter.cs
- RowsCopiedEventArgs.cs
- input.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- OleDbStruct.cs
- WmlValidationSummaryAdapter.cs
- DbProviderManifest.cs
- PostBackTrigger.cs
- SiteMapNodeItemEventArgs.cs
- UxThemeWrapper.cs