Пример #1
0
        public static bool MergeNode(XndNode lh, XndNode rh, FDoConflict DoConflict)
        {
            if (lh.IsWritable == false)
            {
                return(false);
            }
            var atts = rh.GetAttribs();

            foreach (var i in atts)
            {
                var att = lh.FindAttrib(i.GetName());
                if (att != null)
                {
                    DoConflict(att, i);
                }
                else
                {
                    att = lh.AddAttrib(i.GetName());
                    CopyAttrib(att, i);
                }
            }
            var nodes = rh.GetNodes();

            foreach (var i in nodes)
            {
                var node = lh.FindNode(i.GetName());
                if (node == null)
                {
                    node = lh.AddNode(i.GetName(), (long)i.GetClassId(), 0);
                }
                MergeNode(node, i, DoConflict);
            }
            return(true);
        }
Пример #2
0
        public static XndNode Copy2WritableNode(XndNode src)
        {
            var dst = new XndNode();

            dst.SetName(src.GetName());
            var attrs = src.GetAttribs();

            foreach (var i in attrs)
            {
                var att = dst.AddAttrib(i.GetName());
                CopyAttrib(att, i);
            }

            var nodes = src.GetNodes();

            foreach (var i in nodes)
            {
                var node = Copy2WritableNode(i);
                dst.AddNode(node);
            }
            return(dst);
        }
Пример #3
0
        public void Save2Xnd(EngineNS.IO.XndNode node)
        {
            //var
            var attr = node.AddAttrib("AttributeConstructorParamer" + Index);

            attr.BeginWrite();
            attr.WriteMetaObject(this);
            attr.EndWrite();

            attr = node.AddAttrib("AttributeConstructorParamer_Value" + Index);
            attr.BeginWrite();
            if (Value == null)
            {
                attr.Write("");
                attr.Write("System.String");
                attr.Write("null");
                attr.EndWrite();
                return;
            }

            try
            {
                Type type = Value.GetType();

                attr.Write(type.Assembly.FullName);
                attr.Write(type.FullName);
                if (type.Equals(typeof(string)))
                {
                    attr.Write(Value as string);
                }
                else if (type.Equals(typeof(char)) || type.Equals(typeof(byte)))
                {
                    attr.Write(Convert.ToByte(Value));
                }
                else if (type.Equals(typeof(bool)))
                {
                    attr.Write(Convert.ToBoolean(Value));
                }
                else if (type.Equals(typeof(int)))
                {
                    attr.Write(Convert.ToInt32(Value));
                }
                else if (type.Equals(typeof(Int16)))
                {
                    attr.Write(Convert.ToInt16(Value));
                }
                else if (type.Equals(typeof(Int32)))
                {
                    attr.Write(Convert.ToInt32(Value));
                }
                else if (type.Equals(typeof(Int64)))
                {
                    attr.Write(Convert.ToInt64(Value));
                }
                else if (type.Equals(typeof(uint)))
                {
                    attr.Write(Convert.ToUInt32(Value));
                }
                else if (type.Equals(typeof(UInt16)))
                {
                    attr.Write(Convert.ToUInt16(Value));
                }
                else if (type.Equals(typeof(UInt32)))
                {
                    attr.Write(Convert.ToUInt32(Value));
                }
                else if (type.Equals(typeof(UInt64)))
                {
                    attr.Write(Convert.ToUInt64(Value));
                }
                else if (type.Equals(typeof(short)))
                {
                    attr.Write(Convert.ToUInt32(Value));
                }
                else if (type.Equals(typeof(long)))
                {
                    attr.Write(Convert.ToInt64(Value));
                }
                else if (type.Equals(typeof(double)))
                {
                    attr.Write(Convert.ToDouble(Value));
                }
                else if (type.IsSubclassOf(typeof(Enum)))
                {
                    attr.Write(Convert.ToUInt64(Value));
                }
                else
                {
                    //TODO. Type..
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("System.Exception: " + e);
            }


            attr.EndWrite();
        }