internal static ResourceSetWrapper CreateResourceSetWrapper(System.Data.Services.Providers.ResourceSet resourceSet, DataServiceProviderWrapper provider, Func <System.Data.Services.Providers.ResourceType, System.Data.Services.Providers.ResourceType> resourceTypeValidator) { if (!resourceSet.IsReadOnly) { throw new DataServiceException(500, System.Data.Services.Strings.DataServiceProviderWrapper_ResourceContainerNotReadonly(resourceSet.Name)); } ResourceSetWrapper wrapper = new ResourceSetWrapper(resourceSet); wrapper.ApplyConfiguration(provider.Configuration); if (!wrapper.IsVisible) { return(null); } wrapper.resourceType = resourceTypeValidator(resourceSet.ResourceType); return(wrapper); }
public ResourceAssociationSetEnd(System.Data.Services.Providers.ResourceSet resourceSet, System.Data.Services.Providers.ResourceType resourceType, System.Data.Services.Providers.ResourceProperty resourceProperty) { WebUtil.CheckArgumentNull <System.Data.Services.Providers.ResourceSet>(resourceSet, "resourceSet"); WebUtil.CheckArgumentNull <System.Data.Services.Providers.ResourceType>(resourceType, "resourceType"); if ((resourceProperty != null) && ((resourceType.TryResolvePropertyName(resourceProperty.Name) == null) || (resourceProperty.TypeKind != ResourceTypeKind.EntityType))) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourcePropertyMustBeNavigationPropertyOnResourceType); } if (!resourceSet.ResourceType.IsAssignableFrom(resourceType) && !resourceType.IsAssignableFrom(resourceSet.ResourceType)) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourceTypeMustBeAssignableToResourceSet); } if ((resourceProperty != null) && (DataServiceProviderWrapper.GetDeclaringTypeForProperty(resourceType, resourceProperty, null) != resourceType)) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourceTypeMustBeTheDeclaringType(resourceType.FullName, resourceProperty.Name)); } this.resourceSet = resourceSet; this.resourceType = resourceType; this.resourceProperty = resourceProperty; }
public ResourceAssociationSetEnd(System.Data.Services.Providers.ResourceSet resourceSet, System.Data.Services.Providers.ResourceType resourceType, System.Data.Services.Providers.ResourceProperty resourceProperty) { WebUtil.CheckArgumentNull<System.Data.Services.Providers.ResourceSet>(resourceSet, "resourceSet"); WebUtil.CheckArgumentNull<System.Data.Services.Providers.ResourceType>(resourceType, "resourceType"); if ((resourceProperty != null) && ((resourceType.TryResolvePropertyName(resourceProperty.Name) == null) || (resourceProperty.TypeKind != ResourceTypeKind.EntityType))) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourcePropertyMustBeNavigationPropertyOnResourceType); } if (!resourceSet.ResourceType.IsAssignableFrom(resourceType) && !resourceType.IsAssignableFrom(resourceSet.ResourceType)) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourceTypeMustBeAssignableToResourceSet); } if ((resourceProperty != null) && (DataServiceProviderWrapper.GetDeclaringTypeForProperty(resourceType, resourceProperty, null) != resourceType)) { throw new ArgumentException(Strings.ResourceAssociationSetEnd_ResourceTypeMustBeTheDeclaringType(resourceType.FullName, resourceProperty.Name)); } this.resourceSet = resourceSet; this.resourceType = resourceType; this.resourceProperty = resourceProperty; }
internal Operation(string name, ServiceOperationResultKind resultKind, ResourceType returnType, System.Data.Services.Providers.ResourceSet resultSet, ResourceSetPathExpression resultSetPathExpression, string method, IEnumerable<OperationParameter> parameters, System.Data.Services.Providers.OperationParameterBindingKind operationParameterBindingKind, OperationKind kind) { WebUtil.CheckStringArgumentNullOrEmpty(name, "name"); WebUtil.CheckServiceOperationResultKind(resultKind, "resultKind"); WebUtil.CheckStringArgumentNullOrEmpty(method, "method"); ValidateConstructorArguments(name, returnType, resultSet, resultSetPathExpression, method, operationParameterBindingKind, kind); this.name = name; this.resultKind = resultKind; this.returnType = returnType; this.resourceSet = resultSet; this.resultSetPathExpression = resultSetPathExpression; this.method = method; this.kind = kind; this.operationParameterBindingKind = operationParameterBindingKind; this.operationParameters = ValidateParameters(this.operationParameterBindingKind, parameters); if (this.operationParameterBindingKind != System.Data.Services.Providers.OperationParameterBindingKind.Never) { this.bindingParameter = this.operationParameters.FirstOrDefault<OperationParameter>(); if (this.bindingParameter == null) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_BindableOperationMustHaveAtLeastOneParameter, "operationParameterBindingKind"); } if (((resultSetPathExpression != null) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityType)) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityCollection)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_BindingParameterMustBeEntityToUsePathExpression("resultSetPathExpression")); } if (((this.kind == OperationKind.Action) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityType)) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityCollection)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ActionBindingMustBeEntityOrEntityCollection, "parameters"); } if (this.resultSetPathExpression != null) { this.resultSetPathExpression.SetBindingParameter(this.bindingParameter); } } }
internal Operation(string name, ServiceOperationResultKind resultKind, ResourceType returnType, System.Data.Services.Providers.ResourceSet resultSet, ResourceSetPathExpression resultSetPathExpression, string method, IEnumerable <OperationParameter> parameters, System.Data.Services.Providers.OperationParameterBindingKind operationParameterBindingKind, OperationKind kind) { WebUtil.CheckStringArgumentNullOrEmpty(name, "name"); WebUtil.CheckServiceOperationResultKind(resultKind, "resultKind"); WebUtil.CheckStringArgumentNullOrEmpty(method, "method"); ValidateConstructorArguments(name, returnType, resultSet, resultSetPathExpression, method, operationParameterBindingKind, kind); this.name = name; this.resultKind = resultKind; this.returnType = returnType; this.resourceSet = resultSet; this.resultSetPathExpression = resultSetPathExpression; this.method = method; this.kind = kind; this.operationParameterBindingKind = operationParameterBindingKind; this.operationParameters = ValidateParameters(this.operationParameterBindingKind, parameters); if (this.operationParameterBindingKind != System.Data.Services.Providers.OperationParameterBindingKind.Never) { this.bindingParameter = this.operationParameters.FirstOrDefault <OperationParameter>(); if (this.bindingParameter == null) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_BindableOperationMustHaveAtLeastOneParameter, "operationParameterBindingKind"); } if (((resultSetPathExpression != null) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityType)) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityCollection)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_BindingParameterMustBeEntityToUsePathExpression("resultSetPathExpression")); } if (((this.kind == OperationKind.Action) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityType)) && (this.bindingParameter.ParameterType.ResourceTypeKind != ResourceTypeKind.EntityCollection)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ActionBindingMustBeEntityOrEntityCollection, "parameters"); } if (this.resultSetPathExpression != null) { this.resultSetPathExpression.SetBindingParameter(this.bindingParameter); } } }
private static void ValidateConstructorArguments(string operationName, ResourceType returnType, System.Data.Services.Providers.ResourceSet resultSet, ResourceSetPathExpression resultSetPathExpression, string method, System.Data.Services.Providers.OperationParameterBindingKind operationParameterBindingKind, OperationKind kind) { if ((returnType != null) && ((returnType.ResourceTypeKind == ResourceTypeKind.EntityType) || (returnType.ResourceTypeKind == ResourceTypeKind.EntityCollection))) { ResourceType subType = (returnType.ResourceTypeKind == ResourceTypeKind.EntityCollection) ? ((EntityCollectionResourceType)returnType).ItemType : returnType; if (((resultSet == null) && (resultSetPathExpression == null)) || ((resultSet != null) && !resultSet.ResourceType.IsAssignableFrom(subType))) { if (kind == OperationKind.ServiceOperation) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ResultTypeAndResultSetMustMatch("resultType", "resultSet")); } throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ReturnTypeAndResultSetMustMatch("returnType", "resultSetPathExpression", "resultSet")); } } else if ((resultSet != null) || (resultSetPathExpression != null)) { string str = (resultSet != null) ? "resultSet" : "resultSetPathExpression"; if (kind == OperationKind.ServiceOperation) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ResultSetMustBeNullForGivenResultType(str, "resultType")); } throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_ResultSetMustBeNullForGivenReturnType(str, "returnType")); } if ((returnType != null) && (returnType == ResourceType.GetPrimitiveResourceType(typeof(Stream)))) { string str2; string str3; if (kind == OperationKind.ServiceOperation) { str2 = "resultType"; str3 = System.Data.Services.Strings.ServiceOperation_InvalidResultType(returnType.FullName); } else { str2 = "returnType"; str3 = System.Data.Services.Strings.ServiceOperation_InvalidReturnType(returnType.FullName); } throw new ArgumentException(str3, str2); } if ((string.CompareOrdinal("GET", method) != 0) && (string.CompareOrdinal("POST", method) != 0)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_NotSupportedProtocolMethod(method, operationName), "method"); } if ((resultSetPathExpression != null) && (operationParameterBindingKind == System.Data.Services.Providers.OperationParameterBindingKind.Never)) { throw new ArgumentException(System.Data.Services.Strings.ServiceOperation_MustBeBindableToUsePathExpression("resultSetPathExpression"), "resultSetPathExpression"); } }
private ResourceSetWrapper(System.Data.Services.Providers.ResourceSet resourceSet) { this.resourceSet = resourceSet; this.resourcePropertyCache = new Dictionary<System.Data.Services.Providers.ResourceType, ResourcePropertyCache>(ReferenceEqualityComparer<System.Data.Services.Providers.ResourceType>.Instance); }
private ResourceSetWrapper(System.Data.Services.Providers.ResourceSet resourceSet) { this.resourceSet = resourceSet; this.resourcePropertyCache = new Dictionary <System.Data.Services.Providers.ResourceType, ResourcePropertyCache>(ReferenceEqualityComparer <System.Data.Services.Providers.ResourceType> .Instance); }