コード例 #1
0
        private static void FindAllTagTypes()
        {
            _xmlBaseTypes = new Dictionary <string, System.Type>();

            //Find all the XmlBase types in any of the assemblies
            foreach (Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    foreach (System.Type type in assembly.GetExportedTypes())
                    {
                        if (!type.IsAbstract && !type.IsGenericType && typeof(XmlBase).IsAssignableFrom(type))
                        {
                            try
                            {
                                XmlBase obj = System.Activator.CreateInstance(type) as XmlBase;
                                xmlBaseTypes[obj.xmlType.ToLower()] = type;
                            }
                            catch (System.Exception e)
                            {
                                UnityEngine.Debug.LogException(e);
                            }
                        }
                    }
                }
                catch {}
            }
        }
コード例 #2
0
        public override void ConstructFromXml(XmlNode node, XmlDocument document)
        {
            base.ConstructFromXml(node, document);
            children.Clear();

            //One offs
            isSealed   = node.GetAttribute("sealed", "false").Equals("true", System.StringComparison.InvariantCultureIgnoreCase);
            isStatic   = node.GetAttribute("static", "false").Equals("true", System.StringComparison.InvariantCultureIgnoreCase);
            isPartial  = node.GetAttribute("partial", "false").Equals("true", System.StringComparison.InvariantCultureIgnoreCase);
            isAbstract = node.GetAttribute("abstract", "false").Equals("true", System.StringComparison.InvariantCultureIgnoreCase);
            @base      = node.GetAttribute("base");

            //Children
            foreach (XmlNode child in node.ChildNodes)
            {
                XmlBase xmlObj = XmlTemplate.CreateXmlObjectFromNode(child, document);

                if (xmlObj is XmlInterfaceContract)
                {
                    interfaces.Add(xmlObj as XmlInterfaceContract);
                }
                else if (xmlObj != null)
                {
                    children.Add(xmlObj);
                }
            }
        }
コード例 #3
0
        /// Constructs the object from an Xml node and document
        public override void ConstructFromXml(XmlNode node, XmlDocument document)
        {
            base.ConstructFromXml(node, document);

            //Children
            foreach (XmlNode child in node.ChildNodes)
            {
                XmlBase xmlBase = XmlTemplate.CreateXmlObjectFromNode(child, document);

                if (xmlBase != null)
                {
                    children.Add(xmlBase);
                }
            }
        }
コード例 #4
0
        /// Constructs the object from an Xml node and document
        public override void ConstructFromXml(XmlNode node, XmlDocument document)
        {
            base.ConstructFromXml(node, document);
            buildOptionsToCheck = node.GetAttribute("options", string.Empty).Split(DELIMITERS, System.StringSplitOptions.RemoveEmptyEntries);
            isAND = node.GetAttribute("operator", "and").Equals("and", System.StringComparison.InvariantCultureIgnoreCase);

            //Children
            foreach (XmlNode child in node.ChildNodes)
            {
                XmlBase xmlBase = XmlTemplate.CreateXmlObjectFromNode(child, document);

                if (xmlBase != null)
                {
                    children.Add(xmlBase);
                }
            }
        }
コード例 #5
0
        public override void ConstructFromXml(XmlNode node, XmlDocument document)
        {
            base.ConstructFromXml(node, document);

            //One offs
            templateFormat = new System.Version(node.GetAttribute("format", "1.0"));
            priority       = node.GetAttribute <int>("priority", 0);

            if (IsTemplateFormatSupported(templateFormat))
            {
                bool hasAddedUsingPlaceholder = false;

                //Children
                foreach (XmlNode child in node.ChildNodes)
                {
                    XmlBase xmlBase = CreateXmlObjectFromNode(child, document);

                    if (xmlBase != null)
                    {
                        if (xmlBase is XmlUsingNamespace)
                        {
                            usings.Add(xmlBase as XmlUsingNamespace);

                            if (!hasAddedUsingPlaceholder)
                            {
                                children.Add(new XmlUsingNamespacePlaceholder());
                                hasAddedUsingPlaceholder = true;
                            }
                        }
                        else if (xmlBase is XmlBuildOption)
                        {
                            buildOptions.Add(xmlBase as XmlBuildOption);
                        }
                        else
                        {
                            children.Add(xmlBase);
                        }
                    }
                }
            }
            else
            {
                isMalformed = true;
            }
        }
コード例 #6
0
        /// Constructs an XmlBase from the node if it's type is known
        public static XmlBase CreateXmlObjectFromNode(XmlNode node, XmlDocument document)
        {
            XmlBase result = null;

            System.Type nodeType = null;

            //Instantiate the type if it's a known type
            if (xmlBaseTypes.TryGetValue(node.LocalName.ToLower(), out nodeType) && nodeType != null)
            {
                if (typeof(XmlBase).IsAssignableFrom(nodeType) && !nodeType.IsAbstract)
                {
                    result = System.Activator.CreateInstance(nodeType) as XmlBase;
                    result.ConstructFromXml(node, document);
                }
            }
            else if (node is XmlText)
            {
                result = new XmlCodeblock();
                result.ConstructFromXml(node, document);
            }

            //Return the result
            return(result);
        }