Esempio n. 1
0
        public BuildConfigXmlGenerator(IBuildConfigXmlClient buildConfigXmlClient = null, bool buildNonStubVersion = false)
        {
            _buildConfigXmlClient = buildConfigXmlClient;

            if (buildNonStubVersion)
            {
                BuildConfigXml = new BuildConfigXml(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            }
            else
            {
                BuildConfigXml = Substitute.For <BuildConfigXml>(_buildConfigXmlClient, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            }

            Xml.AppendChild(Xml.CreateXmlDeclaration("1.0", "UTF-8", null));

            BuildTypeElement = (XmlElement)Xml.AppendChild(Xml.CreateElement("build-type"));
            BuildTypeElement.SetAttribute("uuid", Guid.NewGuid().ToString());

            NameElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("name"));

            SettingsElement = (XmlElement)BuildTypeElement.AppendChild(Xml.CreateElement("settings"));
            SettingsElement.SetAttribute("ref", "CPlusPlusTemplate_v1");

            ParametersElement = (XmlElement)SettingsElement.AppendChild(Xml.CreateElement("parameters"));
        }
Esempio n. 2
0
        static void Disasm()
        {
            Xml.AppendChild(Xml.CreateXmlDeclaration("1.0", "UTF-8", null));
            XmlNode root = NodeWithAttribute("motion_list", "id", ConvertHash(MFile.IDHash));

            foreach (Motion motion in MFile.Entries)
            {
                XmlNode motionNode = NodeWithAttribute("motion", "hash", ConvertHash(motion.MotionKind));
                motionNode.AppendChild(NodeWithValue("game_hash", ConvertHash(motion.GameHash)));
                motionNode.AppendChild(NodeWithValue("flags", "0x" + motion.Flags.ToString("x4")));
                motionNode.AppendChild(NodeWithValue("transition_frames", motion.Frames.ToString()));

                motionNode.AppendChild(NodeWithValue("animation_count", motion.AnimationCount.ToString()));
                for (int i = 0; i < motion.AnimationCount; i++)
                {
                    motionNode.AppendChild(NodeWithAttributeValue("animation_hash", ConvertHash(motion.AnimationHashes[i]), "id", i.ToString()));
                }
                for (int i = 0; i < motion.AnimationCount; i++)
                {
                    motionNode.AppendChild(NodeWithAttributeValue("animation_unk", motion.AnimationUnks[i].ToString(), "id", i.ToString()));
                }

                foreach (var hash in motion.ExtraHashes)
                {
                    motionNode.AppendChild(NodeWithAttributeValue("extra_hash", ConvertHash(hash.Value), "kind", hash.Key.ToString()));
                }

                if (motion.HasExtended)
                {
                    motionNode.AppendChild(NodeWithValue("xlu_start", motion.XluStart.ToString()));
                    motionNode.AppendChild(NodeWithValue("xlu_end", motion.XluEnd.ToString()));
                    motionNode.AppendChild(NodeWithValue("cancel_frame", motion.CancelFrame.ToString()));
                    motionNode.AppendChild(NodeWithValue("no_stop_intp", motion.NoStopIntp.ToString()));
                }
                root.AppendChild(motionNode);
            }
            Xml.AppendChild(root);
        }
Esempio n. 3
0
        public virtual IElement Add(object content)
        {
            if (content == null
#if DBDATA
                || content == DBNull.Value
#endif
                )
            {
                return(this);
            }

            if (content is Element elem && elem.Xml != null)
            {
                Xml.AppendChild(Xml.OwnerDocument.ImportNode(elem.Xml, true));
                return(this);
            }

            if (content is Item item && item.nodeList != null)
            {
                foreach (var node in item.nodeList.OfType <XmlNode>())
                {
                    Xml.AppendChild(Xml.OwnerDocument.ImportNode(node, true));
                }
                return(this);
            }

            if (content is IAmlNode aml)
            {
                using (var writer = Xml.CreateNavigator().AppendChild())
                    aml.ToAml(writer);
                return(this);
            }

            if (content is IReadOnlyAttribute attr)
            {
                Xml.SetAttribute(attr.Name, attr.Value);
                return(this);
            }

            if (content is string str)
            {
                Xml.InnerText = str;
                return(this);
            }

            var enumerable = content as IEnumerable;
            if (enumerable != null)
            {
                foreach (var curr in enumerable)
                {
                    Add(curr);
                }
                return(this);
            }

            if (content is XmlElement xElem)
            {
                var imported = Xml.OwnerDocument.ImportNode(xElem, true);
                Xml.AppendChild(imported);
                return(this);
            }

            Xml.InnerText = AmlContext.LocalizationContext.Format(content);
            return(this);
        }