//public override void Write(EngineNS.IO.XndNode xndNode) //{ // var att = xndNode.AddAttrib("ConstructionParams"); // att.Version = 0; // att.BeginWrite(); // att.Write(ConstructParam); // att.WriteMetaObject(MethodInfo); // att.EndWrite(); //} public override void Read(EngineNS.IO.XndNode xndNode) { var att = xndNode.FindAttrib("ConstructionParams"); if (att != null) { att.BeginRead(); switch (att.Version) { case 0: att.Read(out mConstructParam); if (MethodInfo == null) { MethodInfo = new CustomMethodInfo(); } att.ReadMetaObject(MethodInfo); break; case 1: att.ReadMetaObject(this); break; } att.EndRead(); } }
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); }
public void Cleanup() { if (mNode != null) { mNode.Cleanup(); mNode = null; } }
public void Dispose() { if (mNode != null) { mNode.TryReleaseHolder(); mNode = null; } }
public bool DelNode(XndNode node) { unsafe { int ret = XndSDK.XNDNode_DelNode(CoreObject, node.CoreObject); if (ret == 0) { return(false); } return(true); } }
public List <XndNode> GetNodes() { unsafe { List <XndNode> nodeList = new List <XndNode>(); int count = XndSDK.XNDNode_GetNodeNumber(CoreObject); for (int i = 0; i < count; i++) { var childHandle = XndSDK.XNDNode_GetNode(CoreObject, i); XndNode nd = new XndNode(childHandle); nodeList.Add(nd); } return(nodeList); } }
public bool LoadFromFile(System.String file) { Dispose(); var io = CEngine.Instance.FileManager.OpenFileForRead(file, EFileType.Xnd, false); if (io == null) { return(false); } mNode = new XndNode(); if (false == mNode.Load(io)) { return(false); } return(true); }
public static async System.Threading.Tasks.Task <XndHolder> LoadXND(System.String file, Thread.Async.EAsyncTarget threadTarget = Thread.Async.EAsyncTarget.AsyncIO) { return(await CEngine.Instance.EventPoster.Post(() => { var io = CEngine.Instance.FileManager.OpenFileForRead(file, EFileType.Xnd, false); if (io == null) { return null; } XndNode node = new XndNode(); if (false == node.Load(io)) { return null; } XndHolder holder = new XndHolder(); holder.mNode = node; return holder; }, threadTarget)); }
public static async System.Threading.Tasks.Task <XndHolder> LoadXND(System.String file) { return(await CEngine.Instance.EventPoster.Post(() => { var io = CEngine.Instance.FileManager.OpenFileForRead(file, EFileType.Xnd, false); if (io == null) { return null; } XndNode node = new XndNode(GetEmptyNativePointer()); if (false == node.Load(io)) { return null; } XndHolder holder = new XndHolder(); holder.mNode = node; return holder; })); }
public static XndHolder SyncLoadXND(System.String file) { var io = CEngine.Instance.FileManager.OpenFileForRead(file, EFileType.Xnd, false); if (io == null) { return(null); } XndNode node = new XndNode(); if (false == node.Load(io)) { return(null); } XndHolder holder = new XndHolder(); holder.mNode = node; return(holder); }
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); }
//public override void Write(EngineNS.IO.XndNode xndNode) //{ // var att = xndNode.AddAttrib("ConstructionParams"); // att.Version = 0; // att.BeginWrite(); // att.Write(ConstructParam); // var typeStr = EngineNS.Rtti.RttiHelper.GetTypeSaveString(CreateType); // att.Write(typeStr); // att.EndWrite(); //} public override void Read(EngineNS.IO.XndNode xndNode) { var att = xndNode.FindAttrib("ConstructionParams"); if (att != null) { att.BeginRead(); switch (att.Version) { case 0: att.Read(out mConstructParam); string typeStr; att.Read(out typeStr); CreateType = EngineNS.Rtti.RttiHelper.GetTypeFromSaveString(typeStr); break; case 1: att.ReadMetaObject(this); break; } att.EndRead(); } }
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(); }
public XndNode AddNode(XndNode childNode) { var node = XndSDK.XNDNode_AddNodeWithSource(CoreObject, childNode.CoreObject); return(new XndNode(node)); }
public bool LoadXnd(IO.XndNode node) { return((bool)SDK_IShaderDesc_LoadXnd(CoreObject, node.CoreObject)); }
public void Save2Xnd(IO.XndNode node, EPlatformType platforms) { SDK_IShaderDesc_Save2Xnd(CoreObject, node.CoreObject, (UInt32)platforms); }
public bool LoadXnd(EngineNS.IO.XndNode node) { var attr = node.FindAttrib("AttributeConstructorParamer" + Index); if (attr == null) { return(false); } attr.BeginRead(); attr.ReadMetaObject(this); attr.EndRead(); attr = node.FindAttrib("AttributeConstructorParamer_Value" + Index); if (attr == null) { return(false); } attr.BeginRead(); string assembly; attr.Read(out assembly); string typename; attr.Read(out typename); try { Type type = Type.GetType(typename + ", " + assembly); if (type.Equals(typeof(string))) { string value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(byte)) || type.Equals(typeof(char))) { byte value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(bool))) { bool value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(int))) { Int32 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(Int16))) { Int16 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(Int32))) { Int32 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(Int64))) { Int64 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(uint))) { UInt32 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(UInt16))) { UInt16 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(UInt32))) { UInt32 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(UInt64))) { UInt64 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(short))) { UInt32 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(long))) { Int64 value; attr.Read(out value); Value = value; } else if (type.Equals(typeof(double))) { double value; attr.Read(out value); Value = value; } else if (type.IsSubclassOf(typeof(Enum))) { UInt64 value; attr.Read(out value); Value = Enum.Parse(type, value.ToString()); } else { //TODO. Type.. } } catch (System.Exception e) { Console.WriteLine("System.Exception: " + e); } attr.EndRead(); return(true); }