本文整理汇总了C#中System.Data.Services.Providers.ResourceProperty.IsOfKind方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceProperty.IsOfKind方法的具体用法?C# ResourceProperty.IsOfKind怎么用?C# ResourceProperty.IsOfKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Services.Providers.ResourceProperty
的用法示例。
在下文中一共展示了ResourceProperty.IsOfKind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPropertyInternal
/// <summary>
/// Validate the given <paramref name="property"/> and adds it to the list of properties for this type
/// </summary>
/// <param name="property">property which needs to be added.</param>
private void AddPropertyInternal(ResourceProperty property)
{
if (this.propertiesDeclaredOnThisType == null)
{
this.propertiesDeclaredOnThisType = new List<ResourceProperty>();
}
foreach (ResourceProperty resourceProperty in this.propertiesDeclaredOnThisType)
{
if (resourceProperty.Name == property.Name)
{
throw new InvalidOperationException(Strings.ResourceType_PropertyWithSameNameAlreadyExists(resourceProperty.Name, this.FullName));
}
}
if (property.IsOfKind(ResourcePropertyKind.Key))
{
if (this.baseType != null)
{
throw new InvalidOperationException(Strings.ResourceType_NoKeysInDerivedTypes);
}
if (this.ResourceTypeKind != ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(Strings.ResourceType_KeyPropertiesOnlyOnEntityTypes);
}
Debug.Assert(property.TypeKind == ResourceTypeKind.Primitive, "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(!property.IsOfKind(ResourcePropertyKind.ETag), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(property.IsOfKind(ResourcePropertyKind.Primitive), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
}
if (property.IsOfKind(ResourcePropertyKind.ETag))
{
if (this.ResourceTypeKind != ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(Strings.ResourceType_ETagPropertiesOnlyOnEntityTypes);
}
#if DEBUG
Debug.Assert(property.TypeKind == ResourceTypeKind.Primitive, "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(property.IsOfKind(ResourcePropertyKind.Primitive), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(!property.IsOfKind(ResourcePropertyKind.Key), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
#endif
}
this.propertiesDeclaredOnThisType.Add(property);
}
示例2: CreateProperty
private IEdmProperty CreateProperty(EdmStructuredType declaringType, ResourceProperty resourceProperty)
{
IEdmProperty property;
List<KeyValuePair<string, object>> annotations = (resourceProperty.CustomAnnotations == null) ? null : resourceProperty.CustomAnnotations.ToList<KeyValuePair<string, object>>();
ODataNullValueBehaviorKind nullValueReadBehaviorKind = ODataNullValueBehaviorKind.Default;
if (resourceProperty.IsOfKind(ResourcePropertyKind.Primitive) || resourceProperty.IsOfKind(ResourcePropertyKind.Stream))
{
IEdmPrimitiveTypeReference typeReference = MetadataProviderUtils.CreatePrimitiveTypeReference(resourceProperty.ResourceType, annotations);
if (resourceProperty.IsOfKind(ResourcePropertyKind.Key))
{
if (typeReference.IsNullable)
{
typeReference = (IEdmPrimitiveTypeReference) typeReference.Clone(false);
}
nullValueReadBehaviorKind = ODataNullValueBehaviorKind.IgnoreValue;
}
else if (MetadataProviderUtils.ShouldDisablePrimitivePropertyNullValidation(resourceProperty, typeReference))
{
nullValueReadBehaviorKind = ODataNullValueBehaviorKind.DisableValidation;
}
string andRemoveDefaultValue = MetadataProviderUtils.GetAndRemoveDefaultValue(annotations);
EdmConcurrencyMode concurrencyMode = resourceProperty.IsOfKind(ResourcePropertyKind.ETag) ? EdmConcurrencyMode.Fixed : EdmConcurrencyMode.None;
property = declaringType.AddStructuralProperty(resourceProperty.Name, typeReference, andRemoveDefaultValue, concurrencyMode);
string mimeType = resourceProperty.MimeType;
if (!string.IsNullOrEmpty(mimeType))
{
this.SetMimeType(property, mimeType);
}
}
else if (resourceProperty.IsOfKind(ResourcePropertyKind.ComplexType))
{
IEdmTypeReference reference2 = this.EnsureTypeReference(resourceProperty.ResourceType, annotations);
string defaultValue = MetadataProviderUtils.GetAndRemoveDefaultValue(annotations);
property = declaringType.AddStructuralProperty(resourceProperty.Name, reference2, defaultValue, EdmConcurrencyMode.None);
if (this.metadataProvider.IsV1Provider && !reference2.IsNullable)
{
nullValueReadBehaviorKind = ODataNullValueBehaviorKind.DisableValidation;
}
}
else if (resourceProperty.IsOfKind(ResourcePropertyKind.Collection))
{
string str4 = MetadataProviderUtils.GetAndRemoveDefaultValue(annotations);
IEdmTypeReference reference3 = this.EnsureTypeReference(resourceProperty.ResourceType, annotations);
property = declaringType.AddStructuralProperty(resourceProperty.Name, reference3, str4, EdmConcurrencyMode.None);
}
else
{
if (!resourceProperty.IsOfKind(ResourcePropertyKind.ResourceSetReference) && !resourceProperty.IsOfKind(ResourcePropertyKind.ResourceReference))
{
throw new InvalidOperationException(System.Data.Services.Strings.MetadataProviderEdmModel_UnsupportedResourcePropertyKind(resourceProperty.Kind.ToString()));
}
EdmEntityType type = (EdmEntityType) declaringType;
IEdmTypeReference reference4 = resourceProperty.IsOfKind(ResourcePropertyKind.ResourceSetReference) ? this.EnsureEntityPrimitiveOrComplexCollectionTypeReference(resourceProperty.ResourceType, annotations) : this.EnsureTypeReference(resourceProperty.ResourceType, annotations);
property = new MetadataProviderEdmNavigationProperty(type, resourceProperty.Name, reference4);
type.AddProperty(property);
}
this.SetNullValueReaderBehavior(property, nullValueReadBehaviorKind);
MetadataProviderUtils.ConvertCustomAnnotations(this, annotations, property);
return property;
}
示例3: AddPropertyInternal
private void AddPropertyInternal(ResourceProperty property)
{
if (this.propertiesDeclaredOnThisType == null)
{
this.propertiesDeclaredOnThisType = new List<ResourceProperty>();
}
foreach (ResourceProperty property2 in this.propertiesDeclaredOnThisType)
{
if (property2.Name == property.Name)
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_PropertyWithSameNameAlreadyExists(property2.Name, this.FullName));
}
}
if (property.IsOfKind(ResourcePropertyKind.Stream))
{
if (this.ResourceTypeKind != System.Data.Services.Providers.ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_NamedStreamsOnlyApplyToEntityType(this.FullName));
}
}
else
{
if (property.IsOfKind(ResourcePropertyKind.Key))
{
if (this.baseType != null)
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_NoKeysInDerivedTypes);
}
if (this.ResourceTypeKind != System.Data.Services.Providers.ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_KeyPropertiesOnlyOnEntityTypes);
}
if (typeof(ISpatial).IsAssignableFrom(property.ResourceType.type))
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_SpatialKeyOrETag(property.Name, this.name));
}
}
if (property.IsOfKind(ResourcePropertyKind.ETag))
{
if (this.ResourceTypeKind != System.Data.Services.Providers.ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_ETagPropertiesOnlyOnEntityTypes);
}
if (typeof(ISpatial).IsAssignableFrom(property.ResourceType.type))
{
throw new InvalidOperationException(System.Data.Services.Strings.ResourceType_SpatialKeyOrETag(property.Name, this.name));
}
}
}
this.propertiesDeclaredOnThisType.Add(property);
}
示例4: ApplyProjectionForProperty
private static ExpandedProjectionNode ApplyProjectionForProperty(ExpandedProjectionNode parentNode, string propertyName, ResourceProperty property, ResourceType targetResourceType, bool lastPathSegment)
{
if (property != null)
{
switch (property.TypeKind)
{
case ResourceTypeKind.ComplexType:
if (!lastPathSegment)
{
throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_ComplexPropertyAsInnerSelectSegment(targetResourceType.FullName, propertyName));
}
break;
case ResourceTypeKind.Primitive:
if (!lastPathSegment)
{
if (property.IsOfKind(ResourcePropertyKind.Stream))
{
throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_NamedStreamMustBeLastSegmentInSelect(propertyName));
}
throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_PrimitivePropertyUsedAsNavigationProperty(targetResourceType.FullName, propertyName));
}
break;
case ResourceTypeKind.Collection:
if (!lastPathSegment)
{
throw DataServiceException.CreateBadRequestError(System.Data.Services.Strings.RequestQueryProcessor_CollectionPropertyAsInnerSelectSegment(targetResourceType.FullName, propertyName));
}
break;
}
}
ExpandedProjectionNode node = parentNode.AddProjectionNode(propertyName, property, targetResourceType, lastPathSegment);
if (lastPathSegment && (node != null))
{
node.ProjectionFound = true;
node.MarkSubtreeAsProjected();
}
return node;
}
示例5: WritePrimitivePropertyFacets
/// <summary>
/// Write the facets for clr types
/// </summary>
/// <param name="xmlWriter">XmlWriter in which facets needs to be written</param>
/// <param name="resourceProperty">property which contains the primitive type for which facets needs to be written</param>
private static void WritePrimitivePropertyFacets(XmlWriter xmlWriter, ResourceProperty resourceProperty)
{
Debug.Assert(resourceProperty.IsOfKind(ResourcePropertyKind.Primitive), "property must be of primitive type");
bool nullable = true;
if (resourceProperty.IsOfKind(ResourcePropertyKind.Key) || (resourceProperty.Type.IsValueType && Nullable.GetUnderlyingType(resourceProperty.Type) == null))
{
nullable = false;
}
xmlWriter.WriteAttributeString(XmlConstants.Nullable, nullable ? XmlConstants.XmlTrueLiteral : XmlConstants.XmlFalseLiteral);
}
示例6: AddPropertyImplementation
/// <summary>
/// Validate the given <paramref name="property"/> and adds it to the list of properties for this type
/// </summary>
/// <param name="property">property which needs to be added.</param>
private void AddPropertyImplementation(ResourceProperty property)
{
if (this.propertiesDeclaredOnThisType == null)
{
this.propertiesDeclaredOnThisType = new List<ResourceProperty>();
}
foreach (ResourceProperty resourceProperty in this.propertiesDeclaredOnThisType)
{
if (resourceProperty.Name == property.Name)
{
throw new InvalidOperationException(Strings.ResourceType_PropertyWithSameNameAlreadyExists(resourceProperty.Name, this.FullName));
}
}
if (property.IsOfKind(ResourcePropertyKind.Stream))
{
// NamedStream Property
// Can only add named streams to entity types.
if (this.ResourceTypeKind != Providers.ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(Strings.ResourceType_NamedStreamsOnlyApplyToEntityType(this.FullName));
}
// NamedStream cannot be used as key or etag (you cannot create a property with a mixed flag that contains stream)
Debug.Assert(!property.IsOfKind(ResourcePropertyKind.Key) && !property.IsOfKind(ResourcePropertyKind.ETag), "NamedStream property kind must be used alone");
Debug.Assert(!property.CanReflectOnInstanceTypeProperty, "NamedStream properties must not be able to reflect");
}
else
{
if (property.IsOfKind(ResourcePropertyKind.Key))
{
if (this.baseType != null)
{
throw new InvalidOperationException(Strings.ResourceType_NoKeysInDerivedTypes);
}
if (this.ResourceTypeKind != ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(Strings.ResourceType_KeyPropertiesOnlyOnEntityTypes);
}
Debug.Assert(property.ResourceType.ResourceTypeKind == ResourceTypeKind.Primitive, "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(!property.IsOfKind(ResourcePropertyKind.ETag), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(property.IsOfKind(ResourcePropertyKind.Primitive), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
}
if (property.IsOfKind(ResourcePropertyKind.ETag))
{
if (this.ResourceTypeKind != ResourceTypeKind.EntityType)
{
throw new InvalidOperationException(Strings.ResourceType_ETagPropertiesOnlyOnEntityTypes);
}
Debug.Assert(property.ResourceType.ResourceTypeKind == ResourceTypeKind.Primitive, "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(property.IsOfKind(ResourcePropertyKind.Primitive), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
Debug.Assert(!property.IsOfKind(ResourcePropertyKind.Key), "This check must have been done in ResourceProperty.ValidatePropertyParameters method");
}
Debug.Assert(property.ResourceType != GetPrimitiveResourceType(typeof(System.IO.Stream)), "Non NamedStream resource using Stream type");
}
this.propertiesDeclaredOnThisType.Add(property);
}
示例7: GetODataPropertyForEntityProperty
private ODataProperty GetODataPropertyForEntityProperty(object customObject, ResourceType currentResourceType, Uri relativeUri, ResourceProperty property)
{
object obj2;
if (property.IsOfKind(ResourcePropertyKind.Stream))
{
obj2 = this.GetNamedStreamPropertyValue(customObject, property, relativeUri);
}
else
{
object propertyValue = WebUtil.GetPropertyValue(base.Provider, customObject, currentResourceType, property, null);
obj2 = base.GetPropertyValue(property.Name, property.ResourceType, propertyValue, property == null);
}
return new ODataProperty { Name = property.Name, Value = obj2 };
}