Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / ComponentModel / LicenseProviderAttribute.cs / 1305376 / LicenseProviderAttribute.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel {
using System;
using System.Security.Permissions;
///
/// Specifies the
/// to use with a class.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class LicenseProviderAttribute : Attribute {
///
///
/// Specifies the default value, which is no provider. This field is read-only.
///
///
public static readonly LicenseProviderAttribute Default = new LicenseProviderAttribute();
private Type licenseProviderType = null;
private string licenseProviderName = null;
///
/// Initializes a new instance of the class without a license
/// provider.
///
public LicenseProviderAttribute() : this((string)null) {
}
///
///
/// Initializes a new instance of the class with
/// the specified type.
///
///
public LicenseProviderAttribute(string typeName) {
licenseProviderName = typeName;
}
///
///
/// Initializes a new instance of the class with
/// the specified type of license provider.
///
///
public LicenseProviderAttribute(Type type) {
licenseProviderType = type;
}
///
/// Gets the license provider to use with the associated class.
///
public Type LicenseProvider {
// SECREVIEW: Remove this attribute once bug#411910 is fixed.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2113:SecureLateBindingMethods")]
get {
if (licenseProviderType == null && licenseProviderName != null) {
licenseProviderType = Type.GetType(licenseProviderName);
}
return licenseProviderType;
}
}
///
///
///
/// This defines a unique ID for this attribute type. It is used
/// by filtering algorithms to identify two attributes that are
/// the same type. For most attributes, this just returns the
/// Type instance for the attribute. LicenseProviderAttribute overrides this to include the type name and the
/// provider type name.
///
///
public override object TypeId {
get {
string typeName = licenseProviderName;
if (typeName == null && licenseProviderType != null) {
typeName = licenseProviderType.FullName;
}
return GetType().FullName + typeName;
}
}
///
///
///
public override bool Equals(object value) {
if (value is LicenseProviderAttribute && value != null) {
Type type = ((LicenseProviderAttribute)value).LicenseProvider;
if (type == LicenseProvider) {
return true;
}
else {
if (type != null && type.Equals(LicenseProvider)) {
return true;
}
}
}
return false;
}
///
///
/// Returns the hashcode for this object.
///
///
public override int GetHashCode() {
return base.GetHashCode();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.ComponentModel {
using System;
using System.Security.Permissions;
///
/// Specifies the
/// to use with a class.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class LicenseProviderAttribute : Attribute {
///
///
/// Specifies the default value, which is no provider. This field is read-only.
///
///
public static readonly LicenseProviderAttribute Default = new LicenseProviderAttribute();
private Type licenseProviderType = null;
private string licenseProviderName = null;
///
/// Initializes a new instance of the class without a license
/// provider.
///
public LicenseProviderAttribute() : this((string)null) {
}
///
///
/// Initializes a new instance of the class with
/// the specified type.
///
///
public LicenseProviderAttribute(string typeName) {
licenseProviderName = typeName;
}
///
///
/// Initializes a new instance of the class with
/// the specified type of license provider.
///
///
public LicenseProviderAttribute(Type type) {
licenseProviderType = type;
}
///
/// Gets the license provider to use with the associated class.
///
public Type LicenseProvider {
// SECREVIEW: Remove this attribute once bug#411910 is fixed.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2113:SecureLateBindingMethods")]
get {
if (licenseProviderType == null && licenseProviderName != null) {
licenseProviderType = Type.GetType(licenseProviderName);
}
return licenseProviderType;
}
}
///
///
///
/// This defines a unique ID for this attribute type. It is used
/// by filtering algorithms to identify two attributes that are
/// the same type. For most attributes, this just returns the
/// Type instance for the attribute. LicenseProviderAttribute overrides this to include the type name and the
/// provider type name.
///
///
public override object TypeId {
get {
string typeName = licenseProviderName;
if (typeName == null && licenseProviderType != null) {
typeName = licenseProviderType.FullName;
}
return GetType().FullName + typeName;
}
}
///
///
///
public override bool Equals(object value) {
if (value is LicenseProviderAttribute && value != null) {
Type type = ((LicenseProviderAttribute)value).LicenseProvider;
if (type == LicenseProvider) {
return true;
}
else {
if (type != null && type.Equals(LicenseProvider)) {
return true;
}
}
}
return false;
}
///
///
/// Returns the hashcode for this object.
///
///
public override int GetHashCode() {
return base.GetHashCode();
}
}
}
// 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
- BuildResultCache.cs
- ViewGenerator.cs
- HighContrastHelper.cs
- HttpResponseHeader.cs
- JpegBitmapDecoder.cs
- FileClassifier.cs
- CustomAttributeSerializer.cs
- DataPagerFieldCommandEventArgs.cs
- ConfigurationSectionCollection.cs
- BidOverLoads.cs
- AesCryptoServiceProvider.cs
- InvalidOleVariantTypeException.cs
- XPathMessageContext.cs
- SpeechUI.cs
- Models.cs
- WebPartDisplayMode.cs
- SecurityTokenResolver.cs
- PageCodeDomTreeGenerator.cs
- ExpandCollapseProviderWrapper.cs
- DbgCompiler.cs
- CompositeControl.cs
- GradientSpreadMethodValidation.cs
- DbBuffer.cs
- FormView.cs
- XamlWriter.cs
- ResourcePermissionBase.cs
- Point4D.cs
- PerformanceCounterManager.cs
- NameObjectCollectionBase.cs
- MachineKeySection.cs
- XmlDocument.cs
- BezierSegment.cs
- Setter.cs
- DynamicPropertyHolder.cs
- QueueException.cs
- MessageDesigner.cs
- DataBindingList.cs
- EventLog.cs
- ShortcutKeysEditor.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- UnsafeNativeMethods.cs
- GreenMethods.cs
- ReflectionUtil.cs
- PropertyToken.cs
- ReflectTypeDescriptionProvider.cs
- TextRange.cs
- SendMailErrorEventArgs.cs
- ContentDisposition.cs
- XmlSubtreeReader.cs
- Matrix.cs
- ForceCopyBuildProvider.cs
- PriorityChain.cs
- RegexCompiler.cs
- CursorConverter.cs
- QilFunction.cs
- Transform.cs
- LineBreak.cs
- WindowsUserNameCachingSecurityTokenAuthenticator.cs
- Glyph.cs
- PropertyInfoSet.cs
- Debug.cs
- WindowsTooltip.cs
- CodeChecksumPragma.cs
- TreePrinter.cs
- CharacterHit.cs
- XmlRootAttribute.cs
- SmtpFailedRecipientException.cs
- DynamicAttribute.cs
- PartManifestEntry.cs
- CommonObjectSecurity.cs
- ModulesEntry.cs
- PermissionRequestEvidence.cs
- DrawingVisual.cs
- DefaultParameterValueAttribute.cs
- DiscoveryClientProtocol.cs
- TextTreeInsertUndoUnit.cs
- IteratorDescriptor.cs
- XmlElementElementCollection.cs
- DoubleSumAggregationOperator.cs
- Pair.cs
- HandleCollector.cs
- InstanceCreationEditor.cs
- Int16.cs
- NameTable.cs
- TrailingSpaceComparer.cs
- TypedLocationWrapper.cs
- AssemblyAssociatedContentFileAttribute.cs
- SqlUtil.cs
- AuthorizationRule.cs
- PrintEvent.cs
- XmlNamespaceMappingCollection.cs
- XPathAncestorIterator.cs
- BamlVersionHeader.cs
- DependencyObject.cs
- DotAtomReader.cs
- DateTimeUtil.cs
- AppSettingsReader.cs
- HttpCachePolicyElement.cs
- ChannelToken.cs
- GiveFeedbackEventArgs.cs