Пример #1
0
        void IDictionaryMetaInitializer.Initialize(IDictionaryAdapterFactory factory, DictionaryAdapterMeta dictionaryMeta)
        {
            var              type             = dictionaryMeta.Type;
            bool?            qualified        = null;
            bool?            isNullable       = null;
            string           defaultNamespace = null;
            XmlTypeAttribute xmlType          = null;
            XmlRootAttribute xmlRoot          = null;
            List <Type>      xmlIncludes      = null;

            new BehaviorVisitor()
            .OfType <XmlTypeAttribute>(attrib => xmlType = attrib)
            .OfType <XmlRootAttribute>(attrib => xmlRoot = attrib)
            .OfType <XmlDefaultsAttribute>(attrib =>
            {
                qualified  = attrib.Qualified;
                isNullable = attrib.IsNullable;
            })
            .OfType <XmlNamespaceAttribute>(attrib =>
            {
                if (attrib.Default)
                {
                    defaultNamespace = attrib.NamespaceUri;
                }
            })
            .OfType <XmlIncludeAttribute>(attrib =>
            {
                xmlIncludes = xmlIncludes ?? new List <Type>();
                if (type != attrib.Type && type.IsAssignableFrom(attrib.Type))
                {
                    xmlIncludes.Add(attrib.Type);
                }
            })
            .Apply(dictionaryMeta.Behaviors);

            if (xmlType == null)
            {
                xmlType = new XmlTypeAttribute();
            }

            if (string.IsNullOrEmpty(xmlType.TypeName))
            {
                xmlType.TypeName = type.Name;
                if (xmlType.TypeName.StartsWith("I"))
                {
                    xmlType.TypeName = xmlType.TypeName.Substring(1);
                }
            }

            if (xmlType.Namespace == null)
            {
                xmlType.Namespace = defaultNamespace;
            }

            dictionaryMeta.SetXmlMeta(new XmlMetadata(type, qualified, isNullable, xmlType, xmlRoot, xmlIncludes));
        }
Пример #2
0
		void IDictionaryMetaInitializer.Initialize(IDictionaryAdapterFactory factory, DictionaryAdapterMeta dictionaryMeta)
		{
			var type = dictionaryMeta.Type;
			bool? qualified = null;
			bool? isNullable = null;
			string defaultNamespace = null;
			XmlTypeAttribute xmlType = null;
			XmlRootAttribute xmlRoot = null;
			List<Type> xmlIncludes = null;

			new BehaviorVisitor()
				.OfType<XmlTypeAttribute>(attrib => xmlType = attrib)
				.OfType<XmlRootAttribute>(attrib => xmlRoot = attrib)
				.OfType<XmlDefaultsAttribute>(attrib =>
				{
					qualified = attrib.Qualified;
					isNullable = attrib.IsNullable;
				})
				.OfType<XmlNamespaceAttribute>(attrib =>
				{
					if (attrib.Default)
					{
						defaultNamespace = attrib.NamespaceUri;
					}
				})
				.OfType<XmlIncludeAttribute>(attrib =>
				{
					xmlIncludes = xmlIncludes ?? new List<Type>();
					if (type != attrib.Type && type.IsAssignableFrom(attrib.Type))
					{
						xmlIncludes.Add(attrib.Type);
					}
				})
				.Apply(dictionaryMeta.Behaviors);

			if (xmlType == null)
			{
				xmlType = new XmlTypeAttribute();
			}

			if (string.IsNullOrEmpty(xmlType.TypeName))
			{
				xmlType.TypeName = type.Name;
				if (xmlType.TypeName.StartsWith("I"))
				{
					xmlType.TypeName = xmlType.TypeName.Substring(1);
				}
			}

			if (xmlType.Namespace == null)
			{
				xmlType.Namespace = defaultNamespace;
			}

			dictionaryMeta.SetXmlMeta(new XmlMetadata(type, qualified, isNullable, xmlType, xmlRoot, xmlIncludes));
		}
Пример #3
0
        void IDictionaryMetaInitializer.Initialize(IDictionaryAdapterFactory factory, DictionaryAdapterMeta dictionaryMeta)
        {
            var              type             = dictionaryMeta.Type;
            string           defaultNamespace = null;
            XmlTypeAttribute xmlType          = null;
            XmlRootAttribute xmlRoot          = null;
            List <Type>      xmlIncludes      = null;

            new BehaviorVisitor()
            .OfType <XmlTypeAttribute>(attrib =>
            {
                xmlType = attrib;
            })
            .OfType <XmlRootAttribute>(attrib =>
            {
                xmlRoot = attrib;
            })
            .OfType <XmlNamespaceAttribute>(attrib =>
            {
                if (attrib.Default)
                {
                    defaultNamespace = attrib.NamespaceUri;
                }
            })
            .OfType <XmlIncludeAttribute>(attrib =>
            {
                xmlIncludes = xmlIncludes ?? new List <Type>();
                if (type != attrib.Type && type.IsAssignableFrom(attrib.Type))
                {
                    xmlIncludes.Add(attrib.Type);
                }
            })
            .Apply(dictionaryMeta.Behaviors);

            if (xmlType == null)
            {
                xmlType = new XmlTypeAttribute
                {
                    TypeName  = type.Name,
                    Namespace = defaultNamespace
                };
                if (xmlType.TypeName.StartsWith("I"))
                {
                    xmlType.TypeName = xmlType.TypeName.Substring(1);
                }
            }
            else if (xmlType.Namespace == null)
            {
                xmlType.Namespace = defaultNamespace;
            }

            dictionaryMeta.SetXmlMeta(new XmlMetadata(type, xmlType, xmlRoot, xmlIncludes));
        }
Пример #4
0
		void IDictionaryMetaInitializer.Initialize(IDictionaryAdapterFactory factory, DictionaryAdapterMeta dictionaryMeta)
		{
			var type = dictionaryMeta.Type;
			string defaultNamespace = null;
			XmlTypeAttribute xmlType = null;
			XmlRootAttribute xmlRoot = null;
			List<Type> xmlIncludes = null;

			new BehaviorVisitor()
				.OfType<XmlTypeAttribute>(attrib =>
				{
					xmlType = attrib;
				})
				.OfType<XmlRootAttribute>(attrib =>
				{
					xmlRoot = attrib;
				})
				.OfType<XmlNamespaceAttribute>(attrib =>
				{
					if (attrib.Default)
						defaultNamespace = attrib.NamespaceUri;
				})
				.OfType<XmlIncludeAttribute>(attrib =>
				{
					xmlIncludes = xmlIncludes ?? new List<Type>();
					if (type != attrib.Type && type.IsAssignableFrom(attrib.Type))
					{
						xmlIncludes.Add(attrib.Type);
					}
				})
				.Apply(dictionaryMeta.Behaviors);

			if (xmlType == null)
			{
				xmlType = new XmlTypeAttribute
				{
					TypeName = type.Name,
					Namespace = defaultNamespace
				};
				if (xmlType.TypeName.StartsWith("I"))
				{
					xmlType.TypeName = xmlType.TypeName.Substring(1);
				}
			}
			else if (xmlType.Namespace == null)
				xmlType.Namespace = defaultNamespace;

			dictionaryMeta.SetXmlMeta(new XmlMetadata(type, xmlType, xmlRoot, xmlIncludes));
		}