当前位置: 首页>>代码示例>>C#>>正文


C# ResourceProperty.IsOfKind方法代码示例

本文整理汇总了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);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:52,代码来源:ResourceType.cs

示例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;
 }
开发者ID:nickchal,项目名称:pash,代码行数:60,代码来源:MetadataProviderEdmModel.cs

示例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);
 }
开发者ID:nickchal,项目名称:pash,代码行数:51,代码来源:ResourceType.cs

示例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;
        }
开发者ID:nickchal,项目名称:pash,代码行数:40,代码来源:RequestQueryProcessor.cs

示例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);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:17,代码来源:MetadataSerializer.cs

示例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);
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:68,代码来源:ResourceType.cs

示例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 };
 }
开发者ID:nickchal,项目名称:pash,代码行数:14,代码来源:EntitySerializer.cs


注:本文中的System.Data.Services.Providers.ResourceProperty.IsOfKind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。