Exemplo n.º 1
0
        private ResourceType GenerateComplexTypeSchema(Type clrType, ResourceTypeKind resourceTypeKind)
        {
            if (this.complexTypeResourceTypes.ContainsKey(clrType.FullName))
            {
                return(this.complexTypeResourceTypes[clrType.FullName]);
            }
            ResourceType resourceType = new ResourceType(clrType, resourceTypeKind, null, "TenantReporting", clrType.Name, false);

            foreach (PropertyInfo propertyInfo in clrType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy))
            {
                Type type = propertyInfo.PropertyType;
                Type type2;
                if (ReportingSchema.IsNullableType(type, out type2))
                {
                    type = type2;
                }
                ResourcePropertyKind resourcePropertyKind = 1;
                ResourceType         resourceType2        = ResourceType.GetPrimitiveResourceType(type);
                if (resourceType2 == null)
                {
                    if (type.IsEnum || type.IsValueType)
                    {
                        throw new NotSupportedException("struct and enum are not supported. For struct, try to change it to class. For enum, try to change it to integer or string.");
                    }
                    if (type.Equals(clrType))
                    {
                        resourceType2 = resourceType;
                    }
                    else
                    {
                        resourceType2 = this.GenerateComplexTypeSchema(type, 1);
                    }
                    resourcePropertyKind = 4;
                }
                resourceType.AddProperty(new ResourceProperty(propertyInfo.Name, resourcePropertyKind, resourceType2));
            }
            if (resourceTypeKind == 1)
            {
                this.complexTypeResourceTypes.Add(clrType.FullName, resourceType);
            }
            return(resourceType);
        }
Exemplo n.º 2
0
 private void BuildResourceType(IEntity entity, ResourceType resourceType, Dictionary <string, ResourceType> complexTypeResourceTypes)
 {
     if (ResourceType.GetPrimitiveResourceType(entity.ClrType) == null)
     {
         foreach (PropertyInfo propertyInfo in entity.ClrType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy))
         {
             if (entity.ReportPropertyCmdletParamsMap == null || !entity.ReportPropertyCmdletParamsMap.ContainsKey(propertyInfo.Name) || this.IsEntityPropertyVisibleForCurrentUser(entity, propertyInfo.Name))
             {
                 Type type = propertyInfo.PropertyType;
                 Type type2;
                 if (ReportingSchema.IsNullableType(type, out type2))
                 {
                     type = type2;
                 }
                 ResourcePropertyKind resourcePropertyKind = 1;
                 ResourceType         resourceType2        = ResourceType.GetPrimitiveResourceType(type);
                 if (resourceType2 == null)
                 {
                     if (type.IsEnum || type.IsValueType)
                     {
                         throw new NotSupportedException("struct and enum are not supported. For struct, try to change it to class. For enum, try to change it to integer or string.");
                     }
                     if (type.Equals(entity.ClrType))
                     {
                         resourceType2 = resourceType;
                     }
                     else
                     {
                         resourceType2 = complexTypeResourceTypes[type.FullName];
                     }
                     resourcePropertyKind = 4;
                 }
                 resourceType.AddProperty(new ResourceProperty(propertyInfo.Name, resourcePropertyKind | (entity.KeyMembers.Contains(propertyInfo.Name) ? 2 : 0), resourceType2));
             }
         }
     }
     resourceType.SetReadOnly();
 }