public object Unserial(Pointer _pointer, SerialAttribute _attribute, System.Xml.XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable) { // get list IList list = (IList)(_pointer.GetValue()); if (list == null) { Type fieldType = Type.GetType(((XmlElement)_fieldNode).GetAttribute("typeinfo")); ConstructorInfo listConstructor = fieldType.GetConstructor(new Type[0]); Debug.Assert(listConstructor != null, "Cannot find valid constructor for list"); list = (IList)(listConstructor.Invoke(new object[0])); } // get value type Type valueType = list.GetType().GetGenericArguments()[0]; ISerializeType valueIType = Serialable.FindSuitableSerialType(valueType); int index = 0; foreach (XmlNode valueNode in _fieldNode.ChildNodes) { //XmlNode valueContentNode = valueNode.FirstChild; object valueObject = valueIType.Unserial(new Pointer(list, index), _attribute, valueNode, _delayBindingTable); if (valueObject != null) { list.Add(valueObject); } ++index; } return(list); }
public object Clone(Pointer _pointer, SerialAttribute _attribute, object _original, Dictionary <Pointer, string> _delayBindingTable) { // get list IList list = (IList)(_pointer.GetValue()); if (list == null) { Type fieldType = _original.GetType(); ConstructorInfo listConstructor = fieldType.GetConstructor(new Type[0]); Debug.Assert(listConstructor != null, "Connot find valid constructor for list"); list = (IList)(listConstructor.Invoke(new object[0])); } // get value type Type valueType = list.GetType().GetGenericArguments()[0]; ISerializeType valueIType = Serialable.FindSuitableSerialType(valueType); IList originalList = (IList)_original; IEnumerator it = originalList.GetEnumerator(); int index = 0; while (it.MoveNext()) { object valueObject = valueIType.Clone(new Pointer(list, index), _attribute, it.Current, _delayBindingTable); if (valueObject != null) { list.Add(valueObject); } ++index; } return(list); }
public Object Clone(Pointer _pointer, SerialAttribute _attribute, object _original, Dictionary <Pointer, string> _delayBindingTable) { // get dictionary IDictionary dictionary = (IDictionary)(_pointer.GetValue()); if (dictionary == null) { Type fieldType = _original.GetType(); ConstructorInfo dictionaryConstructor = fieldType.GetConstructor(new Type[0]); Debug.Assert(dictionaryConstructor != null, "Cannot find valid constructor for dictionary"); dictionary = (IDictionary)(dictionaryConstructor.Invoke(new object[0])); } // get key value type Type[] keyValueType = dictionary.GetType().GetGenericArguments(); ISerializeType keyIType = Serialable.FindSuitableSerialType(keyValueType[0]); ISerializeType valueIType = Serialable.FindSuitableSerialType(keyValueType[1]); IDictionary orignialDictionary = (IDictionary)_original; IDictionaryEnumerator it = orignialDictionary.GetEnumerator(); while (it.MoveNext()) { object keyObject = it.Key; object valueObject = valueIType.Clone(new Pointer(dictionary, keyObject), _attribute, it.Value, _delayBindingTable); if (valueObject != null) { dictionary.Add(keyObject, valueObject); } } return(dictionary); }
public System.Xml.XmlNode Serial(object _object, SerialAttribute _attribute, System.Xml.XmlDocument _doc, string _nameField) { if (_object != null) { IList list = (IList)(_object); Type valueType = _object.GetType().GetGenericArguments()[0]; ISerializeType valueIType = Serialable.FindSuitableSerialType(valueType); XmlElement root = _doc.CreateElement(typeof(IList).ToString()); root.SetAttribute("name", _nameField); root.SetAttribute("typeinfo", _object.GetType().ToString()); IEnumerator it = list.GetEnumerator(); while (it.MoveNext()) { // XmlNode valueNodeHead = _doc.CreateElement("Value"); // root.AppendChild(valueNodeHead); XmlNode valueNode = valueIType.Serial(it.Current, _attribute, _doc, ""); root.AppendChild(valueNode); } return(root); } else { return(null); } }
public XmlNode Serial(Object _object, SerialAttribute _attribute, XmlDocument _doc, string _nameField) { if (_object != null) { XmlElement root = null; Serialable serialable = (Serialable)(_object); if (serialable == null) { return(null); } if (_attribute.GetIsReference() == SerialAttribute.AttributePolicy.PolicyReference) { root = _doc.CreateElement(((Serialable)(_object)).GetThisType().Name); root.SetAttribute("value", serialable.GUID); } else if (_attribute.GetIsReference() == SerialAttribute.AttributePolicy.PolicyCopy) { root = (XmlElement)serialable.DoSerial(_doc); } root.SetAttribute("name", _nameField); return(root); } else { return(null); } }
public Object Clone(Pointer _pointer, SerialAttribute _attribute, object _original, Dictionary <Pointer, string> _delayBindingTable) { string res; res = (string)_original; return(res); }
public XmlNode Serial(Object _object, SerialAttribute _attribute, XmlDocument _doc, string _nameField) { if (_object != null) { XmlElement root = _doc.CreateElement(_object.GetType().Name); root.SetAttribute("name", _nameField); root.SetAttribute("value", ((IEffectParameter)(_object)).ToValueString()); return(root); } else { return(null); } }
public XmlNode Serial(Object _object, SerialAttribute _attribute, XmlDocument _doc, string _nameField) { if (_object != null) { XmlElement root = _doc.CreateElement(typeof(string).Name); root.SetAttribute("name", _nameField); root.SetAttribute("value", (string)(_object)); return(root); } else { return(null); } }
public Object Clone(Pointer _pointer, SerialAttribute _attribute, object _original, Dictionary <Pointer, string> _delayBindingTable) { if (_attribute.GetIsCloneReference() == SerialAttribute.AttributePolicy.PolicyReference) { _delayBindingTable.Add(_pointer, ((Serialable)_original).GUID); return(null); } else if (_attribute.GetIsCloneReference() == SerialAttribute.AttributePolicy.PolicyCopy) { Serialable obj = ((Serialable)_original).DoClone(); return(obj); } return(null); }
public Object Unserial(Pointer _pointer, SerialAttribute _attribute, XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable) { if (_attribute.GetIsReference() == SerialAttribute.AttributePolicy.PolicyReference) { _delayBindingTable.Add(_pointer, ((XmlElement)_fieldNode).GetAttribute("value")); return(null); } else if (_attribute.GetIsReference() == SerialAttribute.AttributePolicy.PolicyCopy) { Serialable obj = Serialable.DoUnserial(_fieldNode); return(obj); } return(null); }
public object Unserial(Pointer _pointer, SerialAttribute _attribute, XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable) { // get dictionary IDictionary dictionary = (IDictionary)(_pointer.GetValue()); if (dictionary == null) { Type fieldType = Type.GetType(((XmlElement)_fieldNode).GetAttribute("typeinfo")); ConstructorInfo dictionaryConstructor = fieldType.GetConstructor(new Type[0]); Debug.Assert(dictionaryConstructor != null, "Cannot find valid constructor for dictionary"); dictionary = (IDictionary)(dictionaryConstructor.Invoke(new object[0])); } // get key value type Type[] keyValueType = dictionary.GetType().GetGenericArguments(); ISerializeType keyIType = Serialable.FindSuitableSerialType(keyValueType[0]); ISerializeType valueIType = Serialable.FindSuitableSerialType(keyValueType[1]); foreach (XmlNode keyValueNode in _fieldNode.ChildNodes) { // foreach keyValue // key XmlNode keyNode = keyValueNode.SelectSingleNode("Key"); XmlNode keyContentNode = keyNode.FirstChild; // do not support delay binding for key object keyObject = keyIType.Unserial(null, _attribute, keyContentNode, _delayBindingTable); // value XmlNode valueNode = keyValueNode.SelectSingleNode("Value"); XmlNode valueContentNode = valueNode.FirstChild; object valueObject = valueIType.Unserial(new Pointer(dictionary, keyObject), _attribute, valueContentNode, _delayBindingTable); // insert into dictionary if (valueObject != null) { dictionary.Add(keyObject, valueObject); } } return(dictionary); }
public XmlNode Serial(Object _object, SerialAttribute _attribute, XmlDocument _doc, string _nameField) { if (_object != null) { // get value <key, value> IDictionary dictionary = (IDictionary)(_object); Type[] keyValueType = _object.GetType().GetGenericArguments(); ISerializeType keyIType = Serialable.FindSuitableSerialType(keyValueType[0]); ISerializeType valueIType = Serialable.FindSuitableSerialType(keyValueType[1]); XmlElement root = _doc.CreateElement(typeof(IDictionary).ToString()); // FROM .Name root.SetAttribute("name", _nameField); root.SetAttribute("typeinfo", _object.GetType().ToString()); IDictionaryEnumerator it = dictionary.GetEnumerator(); while (it.MoveNext()) { XmlNode keyValueNode = _doc.CreateElement("KeyValue"); root.AppendChild(keyValueNode); // key XmlNode keyNodeHead = _doc.CreateElement("Key"); keyValueNode.AppendChild(keyNodeHead); XmlNode keyNode = keyIType.Serial(it.Key, _attribute, _doc, ""); keyNodeHead.AppendChild(keyNode); // value XmlNode valueNodeHead = _doc.CreateElement("Value"); keyValueNode.AppendChild(valueNodeHead); XmlNode valueNode = valueIType.Serial(it.Value, _attribute, _doc, ""); valueNodeHead.AppendChild(valueNode); } return(root); } else { return(null); } }
public Object Clone(Pointer _pointer, SerialAttribute _attribute, object _original, Dictionary <Pointer, string> _delayBindingTable) { ((IEffectParameter)_pointer.GetValue()).FromString(((IEffectParameter)_original).ToValueString()); return(null); }
public object Unserial(Pointer _pointer, SerialAttribute _attribute, XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable) { ((IEffectParameter)_pointer.GetValue()).FromString(((XmlElement)_fieldNode).GetAttribute("value")); return(null); }
public Object Unserial(Pointer _pointer, SerialAttribute _attribute, XmlNode _fieldNode, Dictionary <Pointer, string> _delayBindingTable) { return(((XmlElement)_fieldNode).GetAttribute("value")); }