Ejemplo n.º 1
0
 public object Any(TypesCSharp request)
 {
     var typesConfig = NativeTypesMetadata.GetConfig(request);
     var metadataTypes = NativeTypesMetadata.GetMetadataTypes(Request, typesConfig);
     var csharp = new CSharpGenerator(typesConfig).GetCode(metadataTypes);
     return csharp;
 }
Ejemplo n.º 2
0
        public object Any(TypesCSharp request)
        {
            if (request.BaseUrl == null)
                request.BaseUrl = Request.GetBaseUrl();

            var typesConfig = NativeTypesMetadata.GetConfig(request);
            var metadataTypes = NativeTypesMetadata.GetMetadataTypes(Request, typesConfig);
            var csharp = new CSharpGenerator(typesConfig).GetCode(metadataTypes, base.Request);
            return csharp;
        }
Ejemplo n.º 3
0
        public List<MetadataType> GetMetadataTypesForOperation(IRequest httpReq, Operation op)
        {
            var typeMetadata = HostContext.TryResolve<INativeTypesMetadata>();

            var typesConfig = HostContext.AppHost.GetTypesConfigForMetadata(httpReq);

            var metadataTypes = typeMetadata != null
                ? typeMetadata.GetMetadataTypes(httpReq, typesConfig)
                : new MetadataTypesGenerator(this, typesConfig)
                    .GetMetadataTypes(httpReq);

            var types = new List<MetadataType>();

            var reqType = FindMetadataType(metadataTypes, op.RequestType);
            if (reqType != null)
            {
                types.Add(reqType);

                AddReferencedTypes(reqType, metadataTypes, types);
            }

            var resType = FindMetadataType(metadataTypes, op.ResponseType);
            if (resType != null)
            {
                types.Add(resType);

                AddReferencedTypes(resType, metadataTypes, types);
            }

            var generator = new CSharpGenerator(typesConfig);
            types.Each(x =>
            {
                x.DisplayType = x.DisplayType ?? generator.Type(x.Name, x.GenericArgs);
                x.Properties.Each(p =>
                    p.DisplayType = p.DisplayType ?? generator.Type(p.Type, p.GenericArgs));
            });

            return types;
        }
        public List<MetadataType> GetMetadataTypesForOperation(IRequest httpReq, Operation op)
        {
            var typeMetadata = HostContext.TryResolve<INativeTypesMetadata>();

            var metadataTypes = typeMetadata != null
                ? typeMetadata.GetMetadataTypes(httpReq)
                : new MetadataTypesGenerator(this, new NativeTypesFeature().MetadataTypesConfig)
                    .GetMetadataTypes(httpReq);

            var types = new List<MetadataType>();

            var reqType = FindMetadataType(metadataTypes, op.RequestType);
            if (reqType != null)
            {
                types.Add(reqType);

                if (reqType.Properties != null)
                {
                    var propertyTypes = reqType.Properties
                        .Select(p => FindMetadataType(metadataTypes, p.Type, p.TypeNamespace))
                        .Where(type => type != null)
                        .ToList();

                    types.AddRange(propertyTypes);
                }
            }

            var resType = FindMetadataType(metadataTypes, op.ResponseType);
            if (resType != null)
            {
                types.Add(resType);

                if (resType.Properties != null)
                {
                    var propertyTypes = resType.Properties
                        .Select(p => FindMetadataType(metadataTypes, p.Type, p.TypeNamespace))
                        .Where(type => type != null && !types.Contains(type))
                        .ToList();

                    types.AddRange(propertyTypes);
                }
            }

            var generator = new CSharpGenerator(new NativeTypesFeature().MetadataTypesConfig);
            types.Each(x => x.Properties.Each(p => 
                p.DisplayType = p.DisplayType ?? generator.Type(p.Type, p.GenericArgs)));

            return types;
        }