예제 #1
0
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return(new MetadataTypesConfig
     {
         BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
         MakePartial = req.MakePartial ?? defaults.MakePartial,
         MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
         AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
         AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
         AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
         MakeDataContractsExtensible = req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
         AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
         InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
         AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
         BaseClass = req.BaseClass ?? defaults.BaseClass,
         AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
         AddServiceStackTypes = req.AddServiceStackTypes ?? defaults.AddServiceStackTypes,
         AddModelExtensions = req.AddModelExtensions ?? defaults.AddModelExtensions,
         MakePropertiesOptional = req.MakePropertiesOptional ?? defaults.MakePropertiesOptional,
         AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
         DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
         DefaultImports = req.DefaultImports ?? defaults.DefaultImports,
         IncludeTypes = TrimArgs(req.IncludeTypes ?? defaults.IncludeTypes),
         ExcludeTypes = TrimArgs(req.ExcludeTypes ?? defaults.ExcludeTypes),
         ExportAttributes = defaults.ExportAttributes,
         IgnoreTypes = defaults.IgnoreTypes,
         IgnoreTypesInNamespaces = defaults.IgnoreTypesInNamespaces,
         GlobalNamespace = req.GlobalNamespace ?? defaults.GlobalNamespace,
     });
 }
        public string GenerateTypeScript(NativeTypesBase request, MetadataTypesConfig typesConfig)
        {
            //Include SS types by removing ServiceStack namespaces
            if (typesConfig.AddServiceStackTypes)
            {
                typesConfig.IgnoreTypesInNamespaces = new List <string>();
            }

            var metadataTypes = NativeTypesMetadata.GetMetadataTypes(Request, typesConfig);

            metadataTypes.Types.RemoveAll(x => x.Name == "Service");

            if (typesConfig.AddServiceStackTypes)
            {
                //IReturn markers are metadata properties that are not included as normal interfaces
                var generator          = ((NativeTypesMetadata)NativeTypesMetadata).GetMetadataTypesGenerator(typesConfig);
                var registerInterfaces = new List <Type>
                {
                    typeof(IReturn <>),
                    typeof(IReturnVoid),
                };
                var builtinInterfaces = new[]
                {
                    typeof(IGet),
                    typeof(IPost),
                    typeof(IPut),
                    typeof(IDelete),
                    typeof(IPatch),
                    typeof(IOptions),
                    typeof(IMeta),
                    typeof(IHasSessionId),
                    typeof(IHasVersion),
                };

                foreach (var op in metadataTypes.Operations)
                {
                    foreach (var typeName in op.Request.Implements.Safe())
                    {
                        var iface = builtinInterfaces.FirstOrDefault(x => x.Name == typeName.Name);
                        if (iface != null)
                        {
                            registerInterfaces.AddIfNotExists(iface);
                        }
                    }
                }

                metadataTypes.Types.InsertRange(0, registerInterfaces.Map(x => generator.ToType(x)));
            }

            ExportMissingSystemTypes(typesConfig);

            typesConfig.ExportTypes.Add(typeof(Tuple <>));
            typesConfig.ExportTypes.Add(typeof(Tuple <,>));
            typesConfig.ExportTypes.Add(typeof(Tuple <, ,>));
            typesConfig.ExportTypes.Add(typeof(Tuple <, , ,>));

            var typeScript = new TypeScriptGenerator(typesConfig).GetCode(metadataTypes, base.Request, NativeTypesMetadata);

            return(typeScript);
        }
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return new MetadataTypesConfig
     {
         BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
         MakePartial = req.MakePartial ?? defaults.MakePartial,
         MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
         AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
         AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
         AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
         MakeDataContractsExtensible = req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
         AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
         AddGeneratedCodeAttributes = req.AddGeneratedCodeAttributes ?? defaults.AddGeneratedCodeAttributes,
         InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
         AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
         BaseClass = req.BaseClass ?? defaults.BaseClass,
         Package = req.Package ?? defaults.Package,
         AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
         AddServiceStackTypes = req.AddServiceStackTypes ?? defaults.AddServiceStackTypes,
         AddModelExtensions = req.AddModelExtensions ?? defaults.AddModelExtensions,
         AddPropertyAccessors = req.AddPropertyAccessors ?? defaults.AddPropertyAccessors,
         ExcludeGenericBaseTypes = req.ExcludeGenericBaseTypes ?? defaults.ExcludeGenericBaseTypes,
         SettersReturnThis = req.SettersReturnThis ?? defaults.SettersReturnThis,
         MakePropertiesOptional = req.MakePropertiesOptional ?? defaults.MakePropertiesOptional,
         AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
         DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
         DefaultImports = req.DefaultImports ?? defaults.DefaultImports,
         IncludeTypes = TrimArgs(req.IncludeTypes ?? defaults.IncludeTypes),
         ExcludeTypes = TrimArgs(req.ExcludeTypes ?? defaults.ExcludeTypes),
         ExportAttributes = defaults.ExportAttributes,
         IgnoreTypes = defaults.IgnoreTypes,
         IgnoreTypesInNamespaces = defaults.IgnoreTypesInNamespaces,
         GlobalNamespace = req.GlobalNamespace ?? defaults.GlobalNamespace,
     };
 }
예제 #4
0
        public string GenerateTypeScript(NativeTypesBase request, MetadataTypesConfig typesConfig)
        {
            //Include SS types by removing ServiceStack namespaces
            if (typesConfig.AddServiceStackTypes)
            {
                typesConfig.IgnoreTypesInNamespaces = new List <string>();
            }

            var metadataTypes = NativeTypesMetadata.GetMetadataTypes(Request, typesConfig);

            metadataTypes.Types.RemoveAll(x => x.Name == "Service");

            if (typesConfig.AddServiceStackTypes)
            {
                //IReturn markers are metadata properties that are not included as normal interfaces
                var generator = ((NativeTypesMetadata)NativeTypesMetadata).GetMetadataTypesGenerator(typesConfig);
                metadataTypes.Types.Insert(0, generator.ToType(typeof(IReturn <>)));
                metadataTypes.Types.Insert(0, generator.ToType(typeof(IReturnVoid)));
            }

            if (typesConfig.ExportTypes == null)
            {
                typesConfig.ExportTypes = new HashSet <Type>();
            }

            typesConfig.ExportTypes.Add(typeof(Tuple <>));
            typesConfig.ExportTypes.Add(typeof(Tuple <,>));
            typesConfig.ExportTypes.Add(typeof(Tuple <, ,>));
            typesConfig.ExportTypes.Add(typeof(Tuple <, , ,>));

            var typeScript = new TypeScriptGenerator(typesConfig).GetCode(metadataTypes, base.Request, NativeTypesMetadata);

            return(typeScript);
        }
예제 #5
0
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return new MetadataTypesConfig
     {
         BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
         MakePartial = req.MakePartial ?? defaults.MakePartial,
         MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
         AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
         AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
         AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
         MakeDataContractsExtensible = req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
         AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
         InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
         AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
         AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
         AddServiceStackTypes = req.AddServiceStackTypes ?? defaults.AddServiceStackTypes,
         AddModelExtensions = req.AddModelExtensions ?? defaults.AddModelExtensions,
         MakePropertiesOptional = req.MakePropertiesOptional ?? defaults.MakePropertiesOptional,
         AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
         DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
         DefaultTypeScriptNamespaces = req.DefaultNamespaces ?? defaults.DefaultTypeScriptNamespaces,
         DefaultSwiftNamespaces = req.DefaultNamespaces ?? defaults.DefaultSwiftNamespaces,
         ExportAttributes = defaults.ExportAttributes,
         IgnoreTypes = defaults.IgnoreTypes,
         IgnoreTypesInNamespaces = defaults.IgnoreTypesInNamespaces,
         CSharpTypeAlias = defaults.CSharpTypeAlias,
         FSharpTypeAlias = defaults.FSharpTypeAlias,
         VbNetTypeAlias = defaults.VbNetTypeAlias,
         TypeScriptTypeAlias = defaults.TypeScriptTypeAlias,
         SwiftTypeAlias = defaults.SwiftTypeAlias,
         VbNetKeyWords = defaults.VbNetKeyWords,
         GlobalNamespace = req.GlobalNamespace ?? defaults.GlobalNamespace,
     };
 }
예제 #6
0
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return(new MetadataTypesConfig
     {
         BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
         MakePartial = req.MakePartial ?? defaults.MakePartial,
         MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
         AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
         AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
         AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
         MakeDataContractsExtensible =
             req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
         AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
         InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
         AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
         AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
         AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
         DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
         ExportAttributes = defaults.ExportAttributes,
         IgnoreTypes = defaults.IgnoreTypes,
         IgnoreTypesInNamespaces = defaults.IgnoreTypesInNamespaces,
         CSharpTypeAlias = defaults.CSharpTypeAlias,
         FSharpTypeAlias = defaults.FSharpTypeAlias,
         VbNetTypeAlias = defaults.VbNetTypeAlias,
         GlobalNamespace = defaults.GlobalNamespace,
     });
 }
예제 #7
0
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return new MetadataTypesConfig
         {
             BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
             MakePartial = req.MakePartial ?? defaults.MakePartial,
             MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
             AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
             AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
             AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
             AddDataAnnotationAttributes =
                 req.AddDataAnnotationAttributes ?? defaults.AddDataAnnotationAttributes,
             MakeDataContractsExtensible =
                 req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
             AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
             InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
             AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
             AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
             AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
             DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
             SkipExistingTypes = defaults.SkipExistingTypes,
             IgnoreTypes = defaults.IgnoreTypes,
             TypeAlias = defaults.TypeAlias,
         };
 }
예제 #8
0
        public string GenerateTypeScript(NativeTypesBase request, MetadataTypesConfig typesConfig)
        {
            var metadataTypes = ConfigureScript(typesConfig);

            var typeScript = new TypeScriptGenerator(typesConfig).GetCode(metadataTypes, base.Request, NativeTypesMetadata);

            return(typeScript);
        }
예제 #9
0
 public MetadataTypesConfig GetConfig(NativeTypesBase req)
 {
     return(new MetadataTypesConfig
     {
         BaseUrl = req.BaseUrl ?? defaults.BaseUrl,
         MakePartial = req.MakePartial ?? defaults.MakePartial,
         MakeVirtual = req.MakeVirtual ?? defaults.MakeVirtual,
         MakeInternal = req.MakeInternal ?? defaults.MakeInternal,
         AddReturnMarker = req.AddReturnMarker ?? defaults.AddReturnMarker,
         AddDescriptionAsComments = req.AddDescriptionAsComments ?? defaults.AddDescriptionAsComments,
         AddDataContractAttributes = req.AddDataContractAttributes ?? defaults.AddDataContractAttributes,
         MakeDataContractsExtensible = req.MakeDataContractsExtensible ?? defaults.MakeDataContractsExtensible,
         AddIndexesToDataMembers = req.AddIndexesToDataMembers ?? defaults.AddIndexesToDataMembers,
         AddGeneratedCodeAttributes = req.AddGeneratedCodeAttributes ?? defaults.AddGeneratedCodeAttributes,
         InitializeCollections = req.InitializeCollections ?? defaults.InitializeCollections,
         AddImplicitVersion = req.AddImplicitVersion ?? defaults.AddImplicitVersion,
         BaseClass = req.BaseClass ?? defaults.BaseClass,
         Package = req.Package ?? defaults.Package,
         AddResponseStatus = req.AddResponseStatus ?? defaults.AddResponseStatus,
         AddServiceStackTypes = req.AddServiceStackTypes ?? defaults.AddServiceStackTypes,
         AddModelExtensions = req.AddModelExtensions ?? defaults.AddModelExtensions,
         AddPropertyAccessors = req.AddPropertyAccessors ?? defaults.AddPropertyAccessors,
         ExcludeGenericBaseTypes = req.ExcludeGenericBaseTypes ?? defaults.ExcludeGenericBaseTypes,
         SettersReturnThis = req.SettersReturnThis ?? defaults.SettersReturnThis,
         MakePropertiesOptional = req.MakePropertiesOptional ?? defaults.MakePropertiesOptional,
         ExportAsTypes = req.ExportAsTypes ?? defaults.ExportAsTypes,
         AddDefaultXmlNamespace = req.AddDefaultXmlNamespace ?? defaults.AddDefaultXmlNamespace,
         AddNamespaces = req.AddNamespaces ?? defaults.AddNamespaces,
         DefaultNamespaces = req.DefaultNamespaces ?? defaults.DefaultNamespaces,
         DefaultImports = req.DefaultImports ?? defaults.DefaultImports,
         IncludeTypes = TrimArgs(req.IncludeTypes ?? defaults.IncludeTypes),
         ExcludeTypes = TrimArgs(req.ExcludeTypes ?? defaults.ExcludeTypes),
         TreatTypesAsStrings = TrimArgs(req.TreatTypesAsStrings ?? defaults.TreatTypesAsStrings),
         ExportValueTypes = req.ExportValueTypes ?? defaults.ExportValueTypes,
         ExportAttributes = defaults.ExportAttributes,
         ExportTypes = defaults.ExportTypes,
         IgnoreTypes = defaults.IgnoreTypes,
         IgnoreTypesInNamespaces = defaults.IgnoreTypesInNamespaces,
         GlobalNamespace = req.GlobalNamespace ?? defaults.GlobalNamespace,
         ExcludeNamespace = req.ExcludeNamespace ?? defaults.ExcludeNamespace
     });
 }