public virtual void Serialize( ISIS.GME.Common.IndentedStreamWriter writer, Serializer.Type type = Serializer.Type.OnlyThisObject) { // serialize this object writer.WriteLine(Name, true); if ((type == Serializer.Type.SubGraph || type == Serializer.Type.Children) && this is Interfaces.Container) { writer.Depth++; // serialize child objects foreach (Interfaces.Base b in (this as Interfaces.Container).AllChildren) { if (type == Serializer.Type.SubGraph) { b.Serialize(writer, type); } else if (type == Serializer.Type.Children) { b.Serialize(writer, Serializer.Type.OnlyThisObject); } } writer.Depth--; } }
public override void Serialize( ISIS.GME.Common.IndentedStreamWriter writer, Serializer.Type type = Serializer.Type.OnlyThisObject) { // serialize this object StringBuilder sb = new StringBuilder(); string SrcRefName = "null"; string DstRefName = "null"; if (GenericSrcEndRef != null) { SrcRefName = GenericSrcEndRef.Name; } if (GenericDstEndRef != null) { DstRefName = GenericDstEndRef.Name; } sb.AppendFormat( "{0} [{1} -> {2}] [SrcRef = {3} DstRef = {4}]", Name, GenericSrcEnd.Name, GenericDstEnd.Name, SrcRefName, DstRefName); writer.WriteLine(sb.ToString(), true); if ((type == Serializer.Type.SubGraph || type == Serializer.Type.Children) && this is Interfaces.Container) { writer.Depth++; // serialize child objects foreach (Interfaces.Base b in (this as Interfaces.Container).AllChildren) { if (type == Serializer.Type.SubGraph) { b.Serialize(writer, type); } else if (type == Serializer.Type.Children) { b.Serialize(writer, Serializer.Type.OnlyThisObject); } } writer.Depth--; } }
public virtual void Serialize( ISIS.GME.Common.IndentedStreamWriter writer, Func <IEnumerable <Interfaces.Base>, IEnumerable <Interfaces.Base> > filter, Serializer.Type type = Serializer.Type.Children, bool includeCurrentObject = true) { if (includeCurrentObject) { // serialize this object writer.WriteLine(Name, true); } if ((type == Serializer.Type.SubGraph || type == Serializer.Type.Children) && this is Interfaces.Container) { writer.Depth++; // serialize child objects var filtered = filter((this as Interfaces.Container).AllChildren); bool include = false; foreach (Interfaces.Base b in (this as Interfaces.Container).AllChildren) { if (filtered.Contains(b)) { include = true; } else { include = false; } if (type == Serializer.Type.SubGraph) { b.Serialize(writer, filter, type, include); } else if (type == Serializer.Type.Children) { b.Serialize(writer, filter, Serializer.Type.OnlyThisObject, include); } } writer.Depth--; } }