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


C# ResourceProperty.GetCustomState方法代码示例

本文整理汇总了C#中System.Data.Services.Providers.ResourceProperty.GetCustomState方法的典型用法代码示例。如果您正苦于以下问题:C# ResourceProperty.GetCustomState方法的具体用法?C# ResourceProperty.GetCustomState怎么用?C# ResourceProperty.GetCustomState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Services.Providers.ResourceProperty的用法示例。


在下文中一共展示了ResourceProperty.GetCustomState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrimitiveTypeSerializer

		public PrimitiveTypeSerializer(ResourceType resourceType, ResourceProperty resourceProperty) : base(resourceType)
		{
			object defaultValue;
			object[] resourceTypeKind = new object[2];
			resourceTypeKind[0] = resourceType.ResourceTypeKind;
			resourceTypeKind[1] = ResourceTypeKind.Primitive;
			ExceptionHelpers.ThrowArgumentExceptionIf("resourceType", resourceType.ResourceTypeKind != ResourceTypeKind.Primitive, new ExceptionHelpers.MessageLoader(SerializerBase.GetInvalidArgMessage), resourceTypeKind);
			this.defaultValue = null;
			if (resourceProperty != null)
			{
				if ((resourceProperty.Kind & ResourcePropertyKind.Primitive) != ResourcePropertyKind.Primitive || resourceProperty.ResourceType.InstanceType != resourceType.InstanceType)
				{
					throw new ArgumentException("resourceProperty");
				}
				else
				{
					PropertyCustomState customState = resourceProperty.GetCustomState();
					PrimitiveTypeSerializer primitiveTypeSerializer = this;
					if (customState != null)
					{
						defaultValue = customState.DefaultValue;
					}
					else
					{
						defaultValue = null;
					}
					primitiveTypeSerializer.defaultValue = defaultValue;
					this.name = resourceProperty.Name;
				}
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:31,代码来源:PrimitiveTypeSerializer.cs

示例2: GetValue

		internal static object GetValue(ResourceProperty property, object clrObject)
		{
			string name;
			int num;
			int num1 = -1;
			string[] strArrays = null;
			if (property.GetCustomState() != null && property.GetCustomState().PsProperty != null)
			{
				char[] chrArray = new char[1];
				chrArray[0] = '.';
				strArrays = property.GetCustomState().PsProperty.Split(chrArray);
				num1 = 0;
			}
			do
			{
				if (num1 > -1)
				{
					name = strArrays[num1];
				}
				else
				{
					name = property.Name;
				}
				string str = name;
				if (clrObject as PSObject == null)
				{
					clrObject = TypeSystem.GetPropertyValue(clrObject, str, false);
				}
				else
				{
					PSObject pSObject = clrObject as PSObject;
					PSPropertyInfo item = pSObject.Properties[str];
					if (item != null)
					{
						try
						{
							clrObject = item.Value;
						}
						catch (GetValueException getValueException1)
						{
							GetValueException getValueException = getValueException1;
							TraceHelper.Current.SerializationPropertyNotFound(str, getValueException.Message);
							if (!property.ResourceType.IsPrimitive() || property.ResourceType.IsNullable())
							{
								clrObject = null;
							}
							else
							{
								throw new PSObjectSerializationFailedException(string.Format(Resources.PropertyRetrievalFailed, str, getValueException.Message));
							}
						}
					}
					else
					{
						object[] objArray = new object[1];
						objArray[0] = str;
						TraceHelper.Current.SerializationPropertyNotFound(str, string.Format(CultureInfo.CurrentCulture, Resources.PropertyNotFoundInPSObject, objArray));
						if (!property.ResourceType.IsPrimitive() || property.ResourceType.IsNullable())
						{
							clrObject = null;
							break;
						}
						else
						{
							object[] objArray1 = new object[1];
							objArray1[0] = str;
							throw new PSObjectSerializationFailedException(string.Format(CultureInfo.CurrentCulture, Resources.PropertyNotFoundInPSObject, objArray1));
						}
					}
				}
				if (clrObject == null || strArrays == null)
				{
					break;
				}
				num = num1 + 1;
				num1 = num;
			}
			while (num < (int)strArrays.Length);
			return clrObject;
		}
开发者ID:nickchal,项目名称:pash,代码行数:80,代码来源:SerializerBase.cs

示例3: GetResourceAssociationSet

		public ResourceAssociationSet GetResourceAssociationSet(ResourceSet resourceSet, ResourceType resourceType, ResourceProperty resourceProperty)
		{
			ResourceAssociationSet resourceAssociationSet;
			if (resourceSet == null || resourceType == null)
			{
				return null;
			}
			else
			{
				if (resourceType.Properties.Contains(resourceProperty))
				{
					Microsoft.Management.Odata.Schema.Schema.AssociationType associationType = (resourceProperty.GetCustomState() as ReferenceCustomState).AssociationType;
					if (associationType != null)
					{
						List<ResourceAssociationSet>.Enumerator enumerator = associationType.WcfClass.GetEnumerator();
						try
						{
							while (enumerator.MoveNext())
							{
								ResourceAssociationSet current = enumerator.Current;
								if (current.End1.ResourceSet != resourceSet || current.End1.ResourceType != resourceType || current.End1.ResourceProperty != resourceProperty)
								{
									if (current.End2.ResourceSet != resourceSet || current.End2.ResourceType != resourceType || current.End2.ResourceProperty != resourceProperty)
									{
										continue;
									}
									resourceAssociationSet = current;
									return resourceAssociationSet;
								}
								else
								{
									resourceAssociationSet = current;
									return resourceAssociationSet;
								}
							}
							return null;
						}
						finally
						{
							enumerator.Dispose();
						}
						return resourceAssociationSet;
					}
					else
					{
						return null;
					}
				}
				else
				{
					return null;
				}
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:54,代码来源:DataServiceMetadataProvider.cs


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