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
- ConnectionStringsExpressionBuilder.cs
- Message.cs
- DataSourceProvider.cs
- AudioFormatConverter.cs
- XmlQueryTypeFactory.cs
- Matrix.cs
- TableDetailsCollection.cs
- AppDomain.cs
- ContainerSelectorBehavior.cs
- RequestBringIntoViewEventArgs.cs
- SchemaDeclBase.cs
- OptimizedTemplateContent.cs
- ImageEditor.cs
- ExpressionConverter.cs
- CompilerGlobalScopeAttribute.cs
- DynamicVirtualDiscoSearcher.cs
- DefaultWorkflowSchedulerService.cs
- Timer.cs
- EntityContainerRelationshipSet.cs
- SharedUtils.cs
- EntityCollectionChangedParams.cs
- DataSourceGeneratorException.cs
- RequestContext.cs
- RSATokenProvider.cs
- CalendarDateChangedEventArgs.cs
- EditorZoneBase.cs
- DescendentsWalkerBase.cs
- HwndStylusInputProvider.cs
- AccessDataSourceView.cs
- TextFormatterHost.cs
- BuildProvider.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- SqlBulkCopy.cs
- VerificationAttribute.cs
- COAUTHIDENTITY.cs
- DbProviderFactoriesConfigurationHandler.cs
- DbConnectionPoolOptions.cs
- TreeNodeCollection.cs
- AssemblyNameProxy.cs
- HostSecurityManager.cs
- TypeDescriptorContext.cs
- BitStack.cs
- LayoutEditorPart.cs
- BatchParser.cs
- SemaphoreSlim.cs
- Camera.cs
- SystemWebSectionGroup.cs
- NodeCounter.cs
- ApplicationException.cs
- FileClassifier.cs
- SchemaMapping.cs
- DesignSurfaceEvent.cs
- CultureMapper.cs
- PolicyLevel.cs
- TypeToArgumentTypeConverter.cs
- WorkflowDispatchContext.cs
- ListViewTableCell.cs
- ObjectDataSourceStatusEventArgs.cs
- SuppressIldasmAttribute.cs
- XmlAnyElementAttributes.cs
- HuffmanTree.cs
- FilteredDataSetHelper.cs
- Application.cs
- PeerNameRecordCollection.cs
- ResourceExpressionEditorSheet.cs
- OleDbMetaDataFactory.cs
- DesignTimeData.cs
- AnimatedTypeHelpers.cs
- NavigateEvent.cs
- StringAnimationUsingKeyFrames.cs
- UdpMessageProperty.cs
- DiscoveryService.cs
- TextEffect.cs
- AppDomain.cs
- QueryContinueDragEventArgs.cs
- DataGridViewRowPrePaintEventArgs.cs
- BaseTemplateBuildProvider.cs
- HtmlInputImage.cs
- CrossContextChannel.cs
- SourceFileBuildProvider.cs
- SplashScreenNativeMethods.cs
- XmlDataImplementation.cs
- DataMemberFieldEditor.cs
- LicenseContext.cs
- ApplicationGesture.cs
- IndexedEnumerable.cs
- CollaborationHelperFunctions.cs
- XmlMemberMapping.cs
- HttpCacheVaryByContentEncodings.cs
- LineSegment.cs
- IndexedSelectQueryOperator.cs
- TreeView.cs
- UnionCqlBlock.cs
- IDReferencePropertyAttribute.cs
- PartitionResolver.cs
- MruCache.cs
- XslException.cs
- ColumnCollection.cs
- FixedDSBuilder.cs
- NotifyInputEventArgs.cs