本文整理汇总了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;
}
}
}
示例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;
}
示例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;
}
}
}