コード例 #1
0
 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);
 }