public GeneratorConfiguration()
        {
            NamespaceProvider = new NamespaceProvider()
            {
                GenerateNamespace = key =>
                {
                    var xn   = key.XmlSchemaNamespace;
                    var name = string.Join(".",
                                           xn.Split('/').Where(p => p != "schema" && IdentifierRegex.IsMatch(p))
                                           .Select(n => n.ToTitleCase(NamingScheme.PascalCase)));
                    if (!string.IsNullOrEmpty(NamespacePrefix))
                    {
                        name = NamespacePrefix + (string.IsNullOrEmpty(name) ? "" : ("." + name));
                    }
                    return(name);
                },
            };

            NamingScheme                  = NamingScheme.PascalCase;
            DataAnnotationMode            = DataAnnotationMode.All;
            GenerateSerializableAttribute = GenerateDesignerCategoryAttribute = true;
            CollectionType                = typeof(Collection <>);
            MemberVisitor                 = (member, model) => { };
            NamingProvider                = new NamingProvider(NamingScheme);
            Version        = VersionProvider.CreateFromAssembly();
            EnableUpaCheck = true;
        }
        private string BuildNamespace(Uri source, string xmlNamespace)
        {
            var key    = new NamespaceKey(source, xmlNamespace);
            var result = NamespaceProvider.FindNamespace(key);

            if (!string.IsNullOrEmpty(result))
            {
                return(result);
            }

            throw new Exception(string.Format("Namespace {0} not provided through map or generator.", xmlNamespace));
        }
示例#3
0
        public static NamespaceProvider ToNamespaceProvider(this IEnumerable <KeyValuePair <NamespaceKey, string> > items,
                                                            GenerateNamespaceDelegate generate = null)
        {
            var result = new NamespaceProvider()
            {
                GenerateNamespace = generate,
            };

            foreach (var item in items)
            {
                result.Add(item.Key, item.Value);
            }
            return(result);
        }
示例#4
0
        public GeneratorConfiguration()
        {
            NamespaceProvider = new NamespaceProvider()
            {
                GenerateNamespace = key =>
                {
                    var xn   = key.XmlSchemaNamespace;
                    var name = string.Join(".",
                                           xn.Split('/').Where(p => Regex.IsMatch(p, @"^[A-Za-z]+$") && p != "schema")
                                           .Select(n => Generator.ToTitleCase(n, NamingScheme.PascalCase)));
                    if (!string.IsNullOrEmpty(NamespacePrefix))
                    {
                        name = NamespacePrefix + (string.IsNullOrEmpty(name) ? "" : ("." + name));
                    }
                    return(name);
                },
            };

            NamingScheme                  = NamingScheme.PascalCase;
            DataAnnotationMode            = DataAnnotationMode.All;
            GenerateSerializableAttribute = GenerateDesignerCategoryAttribute = true;
            CollectionType                = typeof(Collection <>);
        }