public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, ExportAttributes = new HashSet<Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), typeof(AutoQueryViewerAttribute), typeof(AutoQueryViewerFieldAttribute), }, ExportTypes = new HashSet<Type> { typeof(IGet), typeof(IPost), typeof(IPut), typeof(IDelete), typeof(IPatch), }, IgnoreTypes = new HashSet<Type> { }, IgnoreTypesInNamespaces = new List<string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Caching", "ServiceStack.Configuration", "ServiceStack.Data", "ServiceStack.IO", "ServiceStack.Logging", "ServiceStack.Messaging", "ServiceStack.Model", "ServiceStack.Redis", "ServiceStack.Web", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List<string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", }, }; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, TypeAlias = new Dictionary<string, string> { { "String", "string" }, { "Boolean", "bool" }, { "Byte", "byte" }, { "Int16", "short" }, { "Int32", "int" }, { "Int64", "long" }, { "UInt16", "ushort" }, { "UInt32", "uint" }, { "UInt64", "ulong" }, { "Single", "float" }, { "Double", "double" }, { "Decimal", "decimal" }, }, ExportAttributes = new HashSet<Type> { typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(DefaultAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), }, IgnoreTypes = new HashSet<Type> { }, IgnoreTypesInNamespaces = new List<string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List<string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", } }; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, TypeAlias = new Dictionary<string, string> { { "String", "string" }, { "Boolean", "bool" }, { "Byte", "byte" }, { "Int16", "short" }, { "Int32", "int" }, { "Int64", "long" }, { "UInt16", "ushort" }, { "UInt32", "uint" }, { "UInt64", "ulong" }, { "Single", "float" }, { "Double", "double" }, { "Decimal", "decimal" }, }, SkipExistingTypes = new HashSet<Type> { typeof(ResponseStatus), typeof(ErrorResponse), typeof(Authenticate), typeof(AuthenticateResponse), typeof(Register), typeof(RegisterResponse), typeof(QueryResponse<>), }, IgnoreTypes = new HashSet<Type> { typeof(TypesCSharp), typeof(TypesMetadata), typeof(NativeTypesBase), typeof(MetadataTypesConfig), }, DefaultNamespaces = new List<string> { "System", "System.Collections", "System.ComponentModel", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack.ServiceHost", "ServiceStack.ServiceInterface.ServiceModel", } }; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, ExportAttributes = new HashSet <Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), typeof(AutoQueryViewerAttribute), typeof(AutoQueryViewerFieldAttribute), }, ExportTypes = new HashSet <Type> { typeof(IGet), typeof(IPost), typeof(IPut), typeof(IDelete), typeof(IPatch), typeof(IMeta), typeof(IHasSessionId), typeof(IHasBearerToken), typeof(IHasVersion) }, IgnoreTypes = new HashSet <Type> { }, IgnoreTypesInNamespaces = new List <string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Caching", "ServiceStack.Configuration", "ServiceStack.Data", "ServiceStack.IO", "ServiceStack.Logging", "ServiceStack.Messaging", "ServiceStack.Model", "ServiceStack.Redis", "ServiceStack.Web", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List <string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", }, }; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, CSharpTypeAlias = new Dictionary<string, string> { { "String", "string" }, { "Boolean", "bool" }, { "Byte", "byte" }, { "Int16", "short" }, { "Int32", "int" }, { "Int64", "long" }, { "UInt16", "ushort" }, { "UInt32", "uint" }, { "UInt64", "ulong" }, { "Single", "float" }, { "Double", "double" }, { "Decimal", "decimal" }, }, FSharpTypeAlias = new Dictionary<string, string> { }, VbNetTypeAlias = new Dictionary<string, string> { { "Int16", "Short" }, { "Int32", "Integer" }, { "Int64", "Long" }, { "DateTime", "Date" }, }, TypeScriptTypeAlias = new Dictionary<string, string> { { "String", "string" }, { "Boolean", "boolean" }, { "DateTime", "string" }, { "TimeSpan", "string" }, { "Byte", "number" }, { "Int16", "number" }, { "Int32", "number" }, { "Int64", "number" }, { "UInt16", "number" }, { "UInt32", "number" }, { "UInt64", "number" }, { "Single", "number" }, { "Double", "number" }, { "Decimal", "number" }, }, VbNetKeyWords = new HashSet<string> { "Default", "Dim", "Catch", "Byte", "Short", "Integer", "Long", "UShort", "ULong", "Double", "Decimal", "String", "Object", "Each", "Error", "Finally", "Function", "Global", "If", "Imports", "Inherits", "Not", "IsNot", "Module", "MyBase", "Option", "Out", "Protected", "Return", "Shadows", "Static", "Then", "With", "When", }, ExportAttributes = new HashSet<Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(DefaultAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), }, IgnoreTypes = new HashSet<Type> { }, IgnoreTypesInNamespaces = new List<string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List<string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", } }; }
public static MetadataTypes GetMetadataTypes(MetadataTypesConfig config, IRequest httpReq) { var metadata = new MetadataTypes { Config = config, }; var existingTypes = new HashSet <Type> { typeof(ResponseStatus), typeof(ErrorResponse), }; var meta = HostContext.Metadata; foreach (var operation in meta.Operations) { if (!meta.IsVisible(httpReq, operation)) { continue; } metadata.Operations.Add(new MetadataOperationType { Actions = operation.Actions, Request = operation.RequestType.ToType(), Response = operation.ResponseType.ToType(), }); existingTypes.Add(operation.RequestType); if (operation.ResponseType != null) { existingTypes.Add(operation.ResponseType); } } foreach (var type in meta.GetAllTypes()) { if (existingTypes.Contains(type)) { continue; } metadata.Operations.Add(new MetadataOperationType { Request = type.ToType(), }); existingTypes.Add(type); } var considered = new HashSet <Type>(existingTypes); var queue = new Queue <Type>(existingTypes); while (queue.Count > 0) { var type = queue.Dequeue(); foreach (var pi in type.GetSerializableProperties()) { if (pi.PropertyType.IsUserType()) { if (considered.Contains(pi.PropertyType)) { continue; } considered.Add(pi.PropertyType); queue.Enqueue(pi.PropertyType); metadata.Types.Add(pi.PropertyType.ToType()); } } if (type.BaseType != null && type.BaseType.IsUserType() && !considered.Contains(type.BaseType)) { considered.Add(type.BaseType); queue.Enqueue(type.BaseType); metadata.Types.Add(type.BaseType.ToType()); } } return(metadata); }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, ExportAttributes = new HashSet <Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(ComputedAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), typeof(AutoQueryViewerAttribute), typeof(AutoQueryViewerFieldAttribute), typeof(ValidateRequestAttribute), typeof(ValidateIsAuthenticatedAttribute), typeof(ValidateIsAdminAttribute), typeof(ValidateHasRoleAttribute), typeof(ValidateHasPermissionAttribute), typeof(ValidateAttribute), typeof(ValidateNullAttribute), typeof(ValidateEmptyAttribute), typeof(ValidateEmailAttribute), typeof(ValidateNotNullAttribute), typeof(ValidateNotEmptyAttribute), typeof(ValidateCreditCardAttribute), typeof(ValidateLengthAttribute), typeof(ValidateExactLengthAttribute), typeof(ValidateMaximumLengthAttribute), typeof(ValidateMinimumLengthAttribute), typeof(ValidateLessThanAttribute), typeof(ValidateLessThanOrEqualAttribute), typeof(ValidateGreaterThanAttribute), typeof(ValidateGreaterThanOrEqualAttribute), typeof(ValidateScalePrecisionAttribute), typeof(ValidateRegularExpressionAttribute), typeof(ValidateEqualAttribute), typeof(ValidateNotEqualAttribute), typeof(ValidateInclusiveBetweenAttribute), typeof(ValidateExclusiveBetweenAttribute), typeof(RefAttribute), typeof(IconAttribute), typeof(InputAttribute), typeof(FieldAttribute), typeof(FormatAttribute), typeof(FieldCssAttribute), typeof(LocodeCssAttribute), typeof(ExplorerCssAttribute), typeof(Intl), typeof(IntlNumber), typeof(IntlDateTime), typeof(IntlRelativeTime), }, ExportTypes = new HashSet <Type> { typeof(IGet), typeof(IPost), typeof(IPut), typeof(IDelete), typeof(IPatch), typeof(IMeta), typeof(IHasSessionId), typeof(IHasBearerToken), typeof(IHasVersion), typeof(ICreateDb <>), typeof(IUpdateDb <>), typeof(IPatchDb <>), typeof(IDeleteDb <>), typeof(ISaveDb <>), }, IgnoreTypes = new HashSet <Type> { }, IgnoreTypesInNamespaces = new List <string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Caching", "ServiceStack.Configuration", "ServiceStack.Data", "ServiceStack.IO", "ServiceStack.Logging", "ServiceStack.Messaging", "ServiceStack.Model", "ServiceStack.Redis", "ServiceStack.Web", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.OpenApi", }, DefaultNamespaces = new List <string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", }, }; }
public static MetadataTypes GetMetadataTypes(MetadataTypesConfig config, IRequest httpReq) { var metadata = new MetadataTypes { Config = config, }; var existingTypes = new HashSet<Type> { typeof (ResponseStatus), typeof (ErrorResponse), }; var meta = HostContext.Metadata; foreach (var operation in meta.Operations) { if (!meta.IsVisible(httpReq, operation)) continue; metadata.Operations.Add(new MetadataOperationType { Actions = operation.Actions, Request = operation.RequestType.ToType(), Response = operation.ResponseType.ToType(), }); existingTypes.Add(operation.RequestType); if (operation.ResponseType != null) { existingTypes.Add(operation.ResponseType); } } foreach (var type in meta.GetAllTypes()) { if (existingTypes.Contains(type)) continue; metadata.Operations.Add(new MetadataOperationType { Request = type.ToType(), }); existingTypes.Add(type); } var considered = new HashSet<Type>(existingTypes); var queue = new Queue<Type>(existingTypes); while (queue.Count > 0) { var type = queue.Dequeue(); foreach (var pi in type.GetSerializableProperties()) { if (pi.PropertyType.IsUserType()) { if (considered.Contains(pi.PropertyType)) continue; considered.Add(pi.PropertyType); queue.Enqueue(pi.PropertyType); metadata.Types.Add(pi.PropertyType.ToType()); } } if (type.BaseType != null && type.BaseType.IsUserType() && !considered.Contains(type.BaseType)) { considered.Add(type.BaseType); queue.Enqueue(type.BaseType); metadata.Types.Add(type.BaseType.ToType()); } } return metadata; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, CSharpTypeAlias = new Dictionary <string, string> { { "String", "string" }, { "Boolean", "bool" }, { "Byte", "byte" }, { "Int16", "short" }, { "Int32", "int" }, { "Int64", "long" }, { "UInt16", "ushort" }, { "UInt32", "uint" }, { "UInt64", "ulong" }, { "Single", "float" }, { "Double", "double" }, { "Decimal", "decimal" }, }, FSharpTypeAlias = new Dictionary <string, string> { }, VbNetTypeAlias = new Dictionary <string, string> { { "Int16", "Short" }, { "Int32", "Integer" }, { "Int64", "Long" }, { "DateTime", "Date" }, }, VbNetKeyWords = new HashSet <string> { "Default", "Dim", "Catch", "Byte", "Short", "Integer", "Long", "UShort", "ULong", "Double", "Decimal", "String", "Object", "Each", "Error", "Finally", "Function", "Global", "If", "Imports", "Inherits", "Not", "IsNot", "Module", "MyBase", "Option", "Out", "Protected", "Return", "Shadows", "Static", "Then", "With", "When", }, ExportAttributes = new HashSet <Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(DefaultAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), }, IgnoreTypes = new HashSet <Type> { }, IgnoreTypesInNamespaces = new List <string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List <string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", } }; }
public NativeTypesFeature() { MetadataTypesConfig = new MetadataTypesConfig { AddDefaultXmlNamespace = HostConfig.DefaultWsdlNamespace, CSharpTypeAlias = new Dictionary <string, string> { { "String", "string" }, { "Boolean", "bool" }, { "Byte", "byte" }, { "Int16", "short" }, { "Int32", "int" }, { "Int64", "long" }, { "UInt16", "ushort" }, { "UInt32", "uint" }, { "UInt64", "ulong" }, { "Single", "float" }, { "Double", "double" }, { "Decimal", "decimal" }, }, FSharpTypeAlias = new Dictionary <string, string> { }, VbNetTypeAlias = new Dictionary <string, string> { { "Int16", "Short" }, { "Int32", "Integer" }, { "Int64", "Long" }, { "DateTime", "Date" }, }, ExportAttributes = new HashSet <Type> { typeof(FlagsAttribute), typeof(ApiAttribute), typeof(ApiResponseAttribute), typeof(ApiMemberAttribute), typeof(StringLengthAttribute), typeof(DefaultAttribute), typeof(IgnoreAttribute), typeof(IgnoreDataMemberAttribute), typeof(MetaAttribute), typeof(RequiredAttribute), typeof(ReferencesAttribute), typeof(StringLengthAttribute), }, IgnoreTypes = new HashSet <Type> { }, IgnoreTypesInNamespaces = new List <string> { "ServiceStack", "ServiceStack.Auth", "ServiceStack.Admin", "ServiceStack.NativeTypes", "ServiceStack.Api.Swagger", }, DefaultNamespaces = new List <string> { "System", "System.Collections", "System.Collections.Generic", "System.Runtime.Serialization", "ServiceStack", "ServiceStack.DataAnnotations", } }; }