private void Serialize(XElement XElement, ISerializableObject SerializableObject)
        {
            System.Runtime.Serialization.SerializationInfo si = new System.Runtime.Serialization.SerializationInfo(SerializableObject.GetType(), new System.Runtime.Serialization.FormatterConverter());

            SerializableObject.Serialize(si);

            XElement elem = new XElement(SerializableObject.SerializationTag.Type);

            elem.Add(new XAttribute("name", SerializableObject.SerializationTag.Name));        

            foreach (System.Runtime.Serialization.SerializationEntry entry in si)
            {
                elem.Add(new XElement(entry.Name, entry.Value));
            }

            if (SerializableObject.ChildrenSerializable != null)
            {
                foreach (ISerializableObject childSerializable in SerializableObject.ChildrenSerializable.Where(p=>p != null))
                {
                    Serialize(elem, childSerializable);
                }
            }

            if (!elem.IsEmpty)
                XElement.Add(elem);
        }
Exemplo n.º 2
0
        public byte[] Serialize()
        {
            using (var ms = new MemoryStream())
                using (var writer = new BinaryWriter(ms))
                {
                    // Format the assembly delegate name.
                    writer.Write(FormatDelegateString(_assemblyDelegate.AssemblyName));

                    writer.Write(FormatDelegateString($"{_assemblyDelegate.AssemblyName}.{_assemblyDelegate.TypeName}"));

                    writer.Write(FormatDelegateString(_assemblyDelegate.MethodName));

                    // Serialize the assembly delegate's arguments.
                    writer.Write(_arguments.Serialize());

                    return(ms.ToArray());
                }
        }
Exemplo n.º 3
0
 public void AppendObject(ISerializableObject obj)
 {
     obj.Serialize(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Write an instance of <see cref="ISerializableObject"/> in the stream
 /// </summary>
 /// <param name="value"><see cref="ISerializableObject"/> to serialize</param>
 /// <returns>Returns the current instance</returns>
 public BasicWriter SetSerializableObject(ISerializableObject value)
 {
     value.Serialize(this);
     return(this);
 }
 public static string Serialize <T>(ISerializableObject obj)
 {
     return(obj.Serialize());
 }
Exemplo n.º 6
0
 internal void AppendObject(ISerializableObject obj)
 {
     obj.Serialize(this);
 }
Exemplo n.º 7
0
 internal void AppendObject(ISerializableObject obj)
 {
     obj.Serialize(this);
 }
Exemplo n.º 8
0
 public void AppendObject(ISerializableObject obj)
 {
     obj.Serialize(this);
 }