本文整理汇总了C#中System.Data.Services.Providers.ResourceType类的典型用法代码示例。如果您正苦于以下问题:C# ResourceType类的具体用法?C# ResourceType怎么用?C# ResourceType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceType类属于System.Data.Services.Providers命名空间,在下文中一共展示了ResourceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyProperty
protected void ApplyProperty(ODataProperty property, ResourceType resourceType, object resource)
{
ResourceType type;
string name = property.Name;
ResourceProperty resourceProperty = resourceType.TryResolvePropertyName(name);
if (resourceProperty == null)
{
type = null;
}
else
{
if (resourceProperty.Kind == ResourcePropertyKind.Stream)
{
return;
}
if (base.Update && resourceProperty.IsOfKind(ResourcePropertyKind.Key))
{
return;
}
type = resourceProperty.ResourceType;
}
object propertyValue = this.ConvertValue(property.Value, ref type);
if (resourceProperty == null)
{
Deserializer.SetOpenPropertyValue(resource, name, propertyValue, base.Service);
}
else
{
Deserializer.SetPropertyValue(resourceProperty, resource, propertyValue, base.Service);
}
}
示例2: ResourceType
private ResourceType(Type type, ResourceType baseType, string namespaceName, string name, bool isAbstract)
{
this.lockPropertiesLoad = new object();
this.propertyInfosDeclaredOnThisType = new Dictionary<ResourceProperty, ResourcePropertyInfo>(ReferenceEqualityComparer<ResourceProperty>.Instance);
this.schemaVersion = ~MetadataEdmSchemaVersion.Version1Dot0;
WebUtil.CheckArgumentNull<Type>(type, "type");
WebUtil.CheckArgumentNull<string>(name, "name");
this.name = name;
this.namespaceName = namespaceName ?? string.Empty;
if ((name == "String") && object.ReferenceEquals(namespaceName, "Edm"))
{
this.fullName = "Edm.String";
}
else
{
this.fullName = string.IsNullOrEmpty(namespaceName) ? name : (namespaceName + "." + name);
}
this.type = type;
this.abstractType = isAbstract;
this.canReflectOnInstanceType = true;
if (baseType != null)
{
this.baseType = baseType;
}
}
示例3: AddEntityType
private IEdmEntityType AddEntityType(ResourceType resourceType, string resourceTypeNamespace)
{
Action<MetadataProviderEdmEntityType> propertyLoadAction = delegate (MetadataProviderEdmEntityType type) {
IEnumerable<ResourceProperty> allVisiblePropertiesDeclaredInThisType = this.GetAllVisiblePropertiesDeclaredInThisType(resourceType);
if (allVisiblePropertiesDeclaredInThisType != null)
{
foreach (ResourceProperty property in allVisiblePropertiesDeclaredInThisType)
{
IEdmProperty property2 = this.CreateProperty(type, property);
if (property.IsOfKind(ResourcePropertyKind.Key))
{
type.AddKeys(new IEdmStructuralProperty[] { (IEdmStructuralProperty) property2 });
}
}
}
};
MetadataProviderEdmEntityType schemaType = new MetadataProviderEdmEntityType(resourceTypeNamespace, resourceType.Name, (resourceType.BaseType != null) ? ((IEdmEntityType) this.EnsureSchemaType(resourceType.BaseType)) : null, resourceType.IsAbstract, resourceType.IsOpenType, propertyLoadAction);
this.CacheSchemaType(schemaType);
if (resourceType.IsMediaLinkEntry && ((resourceType.BaseType == null) || !resourceType.BaseType.IsMediaLinkEntry))
{
this.SetHasDefaultStream(schemaType, true);
}
if (resourceType.HasEntityPropertyMappings)
{
MetadataProviderUtils.ConvertEntityPropertyMappings(this, resourceType, schemaType);
}
MetadataProviderUtils.ConvertCustomAnnotations(this, resourceType.CustomAnnotations, schemaType);
return schemaType;
}
示例4: MovableWhereFinder
public MovableWhereFinder(Expression tree, IQueryable<DSResource> resourceRoot, ResourceType baseResourceType)
{
this.resourceRoot = resourceRoot;
this.baseResourceType = baseResourceType;
this.MovableWhereExpression = null;
this.Visit(tree);
}
示例5: GetAllEntityProperties
private IEnumerable<ODataProperty> GetAllEntityProperties(object customObject, ResourceType currentResourceType, Uri relativeUri)
{
List<ODataProperty> list = new List<ODataProperty>(currentResourceType.Properties.Count);
foreach (ResourceProperty property in base.Provider.GetResourceSerializableProperties(base.CurrentContainer, currentResourceType))
{
if (property.TypeKind != ResourceTypeKind.EntityType)
{
list.Add(this.GetODataPropertyForEntityProperty(customObject, currentResourceType, relativeUri, property));
}
}
if (currentResourceType.IsOpenType)
{
foreach (KeyValuePair<string, object> pair in base.Provider.GetOpenPropertyValues(customObject))
{
string key = pair.Key;
if (string.IsNullOrEmpty(key))
{
throw new DataServiceException(500, System.Data.Services.Strings.Syndication_InvalidOpenPropertyName(currentResourceType.FullName));
}
list.Add(this.GetODataPropertyForOpenProperty(key, pair.Value));
}
if (!currentResourceType.HasEntityPropertyMappings || (this.contentFormat == ODataFormat.VerboseJson))
{
return list;
}
HashSet<string> propertiesLookup = new HashSet<string>(from p in list select p.Name);
foreach (EpmSourcePathSegment segment in from p in currentResourceType.EpmSourceTree.Root.SubProperties
where !propertiesLookup.Contains(p.PropertyName)
select p)
{
list.Add(this.GetODataPropertyForOpenProperty(segment.PropertyName, base.Provider.GetOpenPropertyValue(customObject, segment.PropertyName)));
}
}
return list;
}
示例6: GetBinaryOperatorResultType
/// <summary>
/// Compute the result type of a binary operator based on the type of its operands and the operator kind.
/// </summary>
/// <param name="type">The type of the operators.</param>
/// <param name="operatorKind">The kind of operator.</param>
/// <returns>The result type of the binary operator.</returns>
internal static ResourceType GetBinaryOperatorResultType(ResourceType type, BinaryOperatorKind operatorKind)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(type != null, "type != null");
switch (operatorKind)
{
case BinaryOperatorKind.Or: // fall through
case BinaryOperatorKind.And: // fall through
case BinaryOperatorKind.Equal: // fall through
case BinaryOperatorKind.NotEqual: // fall through
case BinaryOperatorKind.GreaterThan: // fall through
case BinaryOperatorKind.GreaterThanOrEqual: // fall through
case BinaryOperatorKind.LessThan: // fall through
case BinaryOperatorKind.LessThanOrEqual:
Type resultType = Nullable.GetUnderlyingType(type.InstanceType) == null
? typeof(bool)
: typeof(bool?);
return ResourceType.GetPrimitiveResourceType(resultType);
case BinaryOperatorKind.Add: // fall through
case BinaryOperatorKind.Subtract: // fall through
case BinaryOperatorKind.Multiply: // fall through
case BinaryOperatorKind.Divide: // fall through
case BinaryOperatorKind.Modulo:
return type;
default:
throw new ODataException(Strings.General_InternalError(InternalErrorCodes.QueryNodeUtils_BinaryOperatorResultType_UnreachableCodepath));
}
}
示例7: GetCommand
public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId)
{
if (entityType.Name == "CommandInvocation")
{
CommandType commandType1 = commandType;
switch (commandType1)
{
case CommandType.Create:
case CommandType.Read:
case CommandType.Delete:
{
return new GICommand(commandType, this.runspaceStore, entityType, userContext, membershipId);
}
case CommandType.Update:
{
throw new NotImplementedException();
}
default:
{
throw new NotImplementedException();
}
}
}
else
{
throw new NotImplementedException();
}
}
示例8: 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;
}
}
}
示例9: GetDerivedTypes
public IEnumerable<ResourceType> GetDerivedTypes(
ResourceType resourceType
)
{
// We don't support type inheritance yet
yield break;
}
示例10: CollectionResourceTypeSerializer
public CollectionResourceTypeSerializer(ResourceType resourceType) : base(resourceType)
{
object[] resourceTypeKind = new object[2];
resourceTypeKind[0] = resourceType.ResourceTypeKind;
resourceTypeKind[1] = ResourceTypeKind.Collection;
ExceptionHelpers.ThrowArgumentExceptionIf("resourceType", resourceType.ResourceTypeKind != ResourceTypeKind.Collection, new ExceptionHelpers.MessageLoader(SerializerBase.GetInvalidArgMessage), resourceTypeKind);
}
示例11: WriteEntryEpm
/// <summary>
/// Writes the custom mapped EPM properties to an XML writer which is expected to be positioned such to write
/// a child element of the entry element.
/// </summary>
/// <param name="writer">The XmlWriter to write to.</param>
/// <param name="epmTargetTree">The EPM target tree to use.</param>
/// <param name="epmValueCache">The entry properties value cache to use to access the properties.</param>
/// <param name="resourceType">The resource type of the entry.</param>
/// <param name="metadata">The metadata provider to use.</param>
internal static void WriteEntryEpm(
XmlWriter writer,
EpmTargetTree epmTargetTree,
EntryPropertiesValueCache epmValueCache,
ResourceType resourceType,
DataServiceMetadataProviderWrapper metadata)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(writer != null, "writer != null");
Debug.Assert(epmTargetTree != null, "epmTargetTree != null");
Debug.Assert(epmValueCache != null, "epmValueCache != null");
Debug.Assert(resourceType != null, "For any EPM to exist the metadata must be available.");
// If there are no custom mappings, just return null.
EpmTargetPathSegment customRootSegment = epmTargetTree.NonSyndicationRoot;
Debug.Assert(customRootSegment != null, "EPM Target tree must always have non-syndication root.");
if (customRootSegment.SubSegments.Count == 0)
{
return;
}
foreach (EpmTargetPathSegment targetSegment in customRootSegment.SubSegments)
{
Debug.Assert(!targetSegment.IsAttribute, "Target segments under the custom root must be for elements only.");
string alreadyDeclaredPrefix = null;
WriteElementEpm(writer, targetSegment, epmValueCache, resourceType, metadata, ref alreadyDeclaredPrefix);
}
}
示例12: GetPropertyInfo
/// <summary>
/// Gets the property info for the resource property declared on this type.
/// </summary>
/// <param name="resourceType">The resource type to get the property on.</param>
/// <param name="resourceProperty">Resource property instance to get the property info for.</param>
/// <returns>Returns the PropertyInfo object for the specified resource property.</returns>
internal PropertyInfo GetPropertyInfo(ResourceType resourceType, ResourceProperty resourceProperty)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(resourceType != null, "resourceType != null");
Debug.Assert(resourceProperty != null, "resourceProperty != null");
Debug.Assert(resourceProperty.CanReflectOnInstanceTypeProperty, "resourceProperty.CanReflectOnInstanceTypeProperty");
Debug.Assert(resourceType.Properties.Contains(resourceProperty), "The resourceType does not define the specified resourceProperty.");
if (this.propertyInfosDeclaredOnThisType == null)
{
this.propertyInfosDeclaredOnThisType = new Dictionary<ResourceProperty, PropertyInfo>(ReferenceEqualityComparer<ResourceProperty>.Instance);
}
PropertyInfo propertyInfo;
if (!this.propertyInfosDeclaredOnThisType.TryGetValue(resourceProperty, out propertyInfo))
{
BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.Instance;
propertyInfo = resourceType.InstanceType.GetProperty(resourceProperty.Name, bindingFlags);
if (propertyInfo == null)
{
throw new ODataException(Strings.PropertyInfoResourceTypeAnnotation_CannotFindProperty(resourceType.FullName, resourceType.InstanceType, resourceProperty.Name));
}
this.propertyInfosDeclaredOnThisType.Add(resourceProperty, propertyInfo);
}
Debug.Assert(propertyInfo != null, "propertyInfo != null");
return propertyInfo;
}
示例13: GetReturnTypeFromResultType
private static ResourceType GetReturnTypeFromResultType(ResourceType resultType, ServiceOperationResultKind resultKind)
{
if (((resultKind == ServiceOperationResultKind.Void) && (resultType != null)) || ((resultKind != ServiceOperationResultKind.Void) && (resultType == null)))
{
throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ResultTypeAndKindMustMatch("resultKind", "resultType", ServiceOperationResultKind.Void));
}
if ((resultType != null) && (resultType.ResourceTypeKind == ResourceTypeKind.Collection))
{
throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_InvalidResultType(resultType.FullName));
}
if ((resultType != null) && (resultType.ResourceTypeKind == ResourceTypeKind.EntityCollection))
{
throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_InvalidResultType(resultType.FullName));
}
if (resultType == null)
{
return null;
}
if (((resultType.ResourceTypeKind == ResourceTypeKind.Primitive) || (resultType.ResourceTypeKind == ResourceTypeKind.ComplexType)) && ((resultKind == ServiceOperationResultKind.Enumeration) || (resultKind == ServiceOperationResultKind.QueryWithMultipleResults)))
{
return ResourceType.GetCollectionResourceType(resultType);
}
if ((resultType.ResourceTypeKind == ResourceTypeKind.EntityType) && ((resultKind == ServiceOperationResultKind.Enumeration) || (resultKind == ServiceOperationResultKind.QueryWithMultipleResults)))
{
return ResourceType.GetEntityCollectionResourceType(resultType);
}
return resultType;
}
示例14: Extract
public bool Extract(Expression tree, IQueryable<DSResource> resourceRoot, ResourceType resourceType, EntityMetadata entityMetadata)
{
this.resourceRoot = resourceRoot;
this.entityMetadata = entityMetadata;
this.navigationProperty = null;
this.referredEntityKeys = new Dictionary<string, object>();
this.referringEntityKeys = new Dictionary<string, object>();
this.currentState = ReferredResourceExtractor.ExtractionState.ExtractingReferredEntityInfo;
this.Visit(tree);
if (this.currentState == ReferredResourceExtractor.ExtractionState.ExtractingReferringEntityInfo)
{
DSResource dSResource = ResourceTypeExtensions.CreateKeyOnlyResource(resourceType, this.referringEntityKeys);
if (dSResource != null)
{
this.ReferredResource = ResourceTypeExtensions.CreateKeyOnlyResource(this.navigationProperty.ResourceType, this.referredEntityKeys);
if (this.ReferredResource != null)
{
this.currentState = ReferredResourceExtractor.ExtractionState.ExtractionDone;
}
}
}
if (this.currentState != ReferredResourceExtractor.ExtractionState.ExtractionDone)
{
this.currentState = ReferredResourceExtractor.ExtractionState.ExtractionFailed;
}
return this.currentState == ReferredResourceExtractor.ExtractionState.ExtractionDone;
}
示例15: EpmContentDeSerializer
/// <summary>
/// Constructor creates contained serializers
/// </summary>
/// <param name="resourceType">Resource type being serialized</param>
/// <param name="element">Instance of <paramref name="resourceType"/></param>
internal EpmContentDeSerializer(ResourceType resourceType, object element)
{
Debug.Assert(resourceType.HasEntityPropertyMappings == true, "Must have entity property mappings to instantiate EpmContentDeSerializer");
this.resourceType = resourceType;
this.element = element;
this.resourceType.EnsureEpmInfoAvailability();
}