Пример #1
0
        /// <summary>
        ///     Generates a new XmlSchema object from the <see cref="_configType" /> object
        /// </summary>
        public XmlSchema GenerateXsd(string rootElementName)
        {
            _rootElement = CreateRootElement(rootElementName);
            var rootCt = (XmlSchemaComplexType)_schemaDoc.Items[0];

            //  get all properties from the configuration object
            var properties = TypeParser.GetProperties <ConfigurationPropertyAttribute>(_configType);

            foreach (var pi in properties)
            {
                Debug.IndentLevel = 0;
                Debug.WriteLine("ConfigurationProperty: " + pi.Name);

                var parser = TypeParserFactory.GetParser(this, pi);
                parser.GenerateSchemaTypeObjects(pi, rootCt, 0);
            }

            return(_schemaDoc);
        }
Пример #2
0
        /// <summary>
        /// Gets the Type parser.
        /// </summary>
        /// <param name="typeKeyword">The Type keyword.</param>
        /// <returns>The Type parser.</returns>
        private static ITypeParser GetTypeParser(string typeKeyword)
        {
            if (!string.IsNullOrEmpty(typeKeyword))
            {
                if (cachedTypeParsersMap == null)
                {
                    cachedTypeParsersMap = new Dictionary <Type, ITypeParser>();
                }

                Type        type       = TypeParserFactory.GetTypeParserType(typeKeyword);
                ITypeParser typeParser = null;

                if (type != null)
                {
                    if (cachedTypeParsersMap.ContainsKey(type))
                    {
                        typeParser = cachedTypeParsersMap[type];

                        if (typeParser == null)
                        {
                            typeParser = TypeParserFactory.CreateTypeParser(typeKeyword);
                            cachedTypeParsersMap[type] = typeParser;
                        }
                    }
                    else
                    {
                        typeParser = TypeParserFactory.CreateTypeParser(typeKeyword);
                        cachedTypeParsersMap.Add(type, typeParser);
                    }

                    return(typeParser);
                }
            }

            return(null);
        }