Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / MetadataProperty.cs / 2 / MetadataProperty.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics;
using System.Reflection;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a metadata attribute for an item
///
public sealed class MetadataProperty : MetadataItem
{
#region Constructors
///
/// The constructor for MetadataProperty taking in a name, a TypeUsage object, and a value for the attribute
///
/// The name of this MetadataProperty
/// The TypeUsage describing the type of this MetadataProperty
/// The value for this attribute
/// Thrown if typeUsage argument is null
internal MetadataProperty(string name, TypeUsage typeUsage, object value)
{
EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage");
_name = name;
_value = value;
_typeUsage = typeUsage;
_propertyKind = PropertyKind.Extended;
}
///
/// The constructor for MetadataProperty taking in all the ingredients for creating TypeUsage and the actual value
///
/// The name of the attribute
/// The edm type of the attribute
/// Whether the collection type of the given edm type should be used
/// The value of the attribute
internal MetadataProperty(string name, EdmType edmType, bool isCollectionType, object value)
{
EntityUtil.CheckArgumentNull(edmType, "edmType");
_name = name;
_value = value;
if (isCollectionType)
{
_typeUsage = TypeUsage.Create(edmType.GetCollectionType());
}
else
{
_typeUsage = TypeUsage.Create(edmType);
}
_propertyKind = PropertyKind.System;
}
#endregion
#region Fields
private string _name;
private PropertyKind _propertyKind;
private object _value;
private TypeUsage _typeUsage;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.MetadataProperty; } }
///
/// Gets the identity of this item
///
internal override string Identity
{
get
{
return Name;
}
}
///
/// Gets/Sets the name of this MetadataProperty
///
[MetadataProperty(PrimitiveTypeKind.String, false)]
public string Name
{
get
{
// The name is immutable, so it should be safe to always get it from the field
return _name;
}
}
///
/// Gets/Sets the value of this MetadataProperty
///
/// Thrown if the MetadataProperty instance is in readonly state
[MetadataProperty(typeof(Object), false)]
public object Value
{
get
{
// Check if we're redirecting to an MetadataItem system property
MetadataPropertyValue redirectValue = _value as MetadataPropertyValue;
if (null != redirectValue)
{
return redirectValue.GetValue();
}
// If not, return the actual stored value
return _value;
}
}
///
/// Gets/Sets the TypeUsage object describing the type of this attribute
///
/// Thrown if value passed into setter is null
/// Thrown if the MetadataProperty instance is in readonly state
[MetadataProperty(BuiltInTypeKind.TypeUsage, false)]
public TypeUsage TypeUsage
{
get
{
return _typeUsage;
}
}
#endregion
#region Methods
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
// TypeUsage is always readonly, no need to set _typeUsage
}
}
///
/// Returns the kind of the attribute
///
public PropertyKind PropertyKind
{
get
{
return _propertyKind;
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Diagnostics;
using System.Reflection;
namespace System.Data.Metadata.Edm
{
///
/// Class representing a metadata attribute for an item
///
public sealed class MetadataProperty : MetadataItem
{
#region Constructors
///
/// The constructor for MetadataProperty taking in a name, a TypeUsage object, and a value for the attribute
///
/// The name of this MetadataProperty
/// The TypeUsage describing the type of this MetadataProperty
/// The value for this attribute
/// Thrown if typeUsage argument is null
internal MetadataProperty(string name, TypeUsage typeUsage, object value)
{
EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage");
_name = name;
_value = value;
_typeUsage = typeUsage;
_propertyKind = PropertyKind.Extended;
}
///
/// The constructor for MetadataProperty taking in all the ingredients for creating TypeUsage and the actual value
///
/// The name of the attribute
/// The edm type of the attribute
/// Whether the collection type of the given edm type should be used
/// The value of the attribute
internal MetadataProperty(string name, EdmType edmType, bool isCollectionType, object value)
{
EntityUtil.CheckArgumentNull(edmType, "edmType");
_name = name;
_value = value;
if (isCollectionType)
{
_typeUsage = TypeUsage.Create(edmType.GetCollectionType());
}
else
{
_typeUsage = TypeUsage.Create(edmType);
}
_propertyKind = PropertyKind.System;
}
#endregion
#region Fields
private string _name;
private PropertyKind _propertyKind;
private object _value;
private TypeUsage _typeUsage;
#endregion
#region Properties
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.MetadataProperty; } }
///
/// Gets the identity of this item
///
internal override string Identity
{
get
{
return Name;
}
}
///
/// Gets/Sets the name of this MetadataProperty
///
[MetadataProperty(PrimitiveTypeKind.String, false)]
public string Name
{
get
{
// The name is immutable, so it should be safe to always get it from the field
return _name;
}
}
///
/// Gets/Sets the value of this MetadataProperty
///
/// Thrown if the MetadataProperty instance is in readonly state
[MetadataProperty(typeof(Object), false)]
public object Value
{
get
{
// Check if we're redirecting to an MetadataItem system property
MetadataPropertyValue redirectValue = _value as MetadataPropertyValue;
if (null != redirectValue)
{
return redirectValue.GetValue();
}
// If not, return the actual stored value
return _value;
}
}
///
/// Gets/Sets the TypeUsage object describing the type of this attribute
///
/// Thrown if value passed into setter is null
/// Thrown if the MetadataProperty instance is in readonly state
[MetadataProperty(BuiltInTypeKind.TypeUsage, false)]
public TypeUsage TypeUsage
{
get
{
return _typeUsage;
}
}
#endregion
#region Methods
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!IsReadOnly)
{
base.SetReadOnly();
// TypeUsage is always readonly, no need to set _typeUsage
}
}
///
/// Returns the kind of the attribute
///
public PropertyKind PropertyKind
{
get
{
return _propertyKind;
}
}
#endregion
}
}
// 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
- CaseDesigner.xaml.cs
- StylusCollection.cs
- LayoutUtils.cs
- __Filters.cs
- WebPartCloseVerb.cs
- DataGridViewRowsAddedEventArgs.cs
- HttpException.cs
- WinInet.cs
- DeploymentSection.cs
- RijndaelManagedTransform.cs
- Rect3DConverter.cs
- SubpageParaClient.cs
- CompilationSection.cs
- Matrix.cs
- DesignerActionGlyph.cs
- InvokeProviderWrapper.cs
- Expr.cs
- TypeReference.cs
- IgnoreSection.cs
- DependencyObjectProvider.cs
- DataBinding.cs
- FilteredDataSetHelper.cs
- PackageRelationshipSelector.cs
- TrackingProvider.cs
- TransactionManagerProxy.cs
- MultiPageTextView.cs
- QueryOperator.cs
- SchemaElementLookUpTable.cs
- TransformDescriptor.cs
- CryptoProvider.cs
- HandlerFactoryWrapper.cs
- LinkButton.cs
- SerialPort.cs
- CalendarAutoFormat.cs
- _ProxyChain.cs
- sqlinternaltransaction.cs
- HttpSessionStateBase.cs
- CustomCategoryAttribute.cs
- PropertyTab.cs
- HttpCachePolicyWrapper.cs
- Perspective.cs
- SingleAnimationUsingKeyFrames.cs
- DeviceSpecific.cs
- UserNameSecurityTokenProvider.cs
- GeometryHitTestParameters.cs
- XmlDownloadManager.cs
- TimeSpanValidator.cs
- ReversePositionQuery.cs
- ZeroOpNode.cs
- CodeNamespace.cs
- GAC.cs
- AffineTransform3D.cs
- LogManagementAsyncResult.cs
- DbSource.cs
- TraceContext.cs
- DataObjectEventArgs.cs
- XmlSchemaValidationException.cs
- PtsCache.cs
- Camera.cs
- ExecutionScope.cs
- Int64Storage.cs
- BitmapMetadataBlob.cs
- Context.cs
- InternalBase.cs
- DataGridViewControlCollection.cs
- PersistenceContextEnlistment.cs
- PointConverter.cs
- UIntPtr.cs
- ResizingMessageFilter.cs
- NonClientArea.cs
- WebBrowsableAttribute.cs
- PingOptions.cs
- Storyboard.cs
- RSAPKCS1SignatureFormatter.cs
- EntityDesignerBuildProvider.cs
- AnnotationStore.cs
- DataServiceRequest.cs
- TypeUtil.cs
- EncoderBestFitFallback.cs
- RectangleGeometry.cs
- CustomValidator.cs
- PrintController.cs
- ProjectionPruner.cs
- ScriptResourceInfo.cs
- Int32Converter.cs
- RegexTree.cs
- ExceptionHandler.cs
- Style.cs
- TimeoutValidationAttribute.cs
- CompoundFileStreamReference.cs
- hresults.cs
- PrimaryKeyTypeConverter.cs
- SecurityTokenAuthenticator.cs
- SqlVisitor.cs
- TextTreeInsertUndoUnit.cs
- ContentWrapperAttribute.cs
- ColorInterpolationModeValidation.cs
- ExtensionElement.cs
- AuthenticationModulesSection.cs
- HandlerFactoryCache.cs