/// <summary> /// Indicates whether the container contains an element /// that is of one of the specified types or inherited. /// </summary> /// <param name="coll">The collection to search.</param> /// <param name="types">The types to find within the collection.</param> /// <returns>True, if an object of one of the given types is found within the collection.</returns> internal static bool CollectionContainsObjectAssignableTo(DocumentObjectCollection coll, params Type[] types) { foreach (object obj in coll) { foreach (Type type in types) { if (type.IsAssignableFrom(obj.GetType())) return true; } } return false; }
/// <summary> /// Implements the deep copy of the object. /// </summary> protected override object DeepCopy() { DocumentObjectCollection coll = (DocumentObjectCollection)base.DeepCopy(); int count = Count; coll._elements = new List <object>(count); for (int index = 0; index < count; ++index) { DocumentObject doc = this[index]; if (doc != null) { doc = doc.Clone() as DocumentObject; doc._parent = coll; } coll._elements.Add(doc); } return(coll); }
/// <summary> /// Writes a DocumentObjectCollection type object to a DDL file. Indent a new block by /// indent + initialIndent characters. /// </summary> public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename, int indent, int initialIndent) { DdlWriter wrt = null; try { wrt = new DdlWriter(filename); wrt.Indent = indent; wrt.InitialIndent = initialIndent; wrt.WriteDocument(docObjectContainer); } finally { if (wrt != null) wrt.Close(); } }
/// <summary> /// Writes a DocumentObjectCollection type object to a DDL file. Indent a new block by /// indent + initialIndent characters. /// </summary> public static void WriteToFile(DocumentObjectCollection docObjectContainer, string filename, int indent) { WriteToFile(docObjectContainer, filename, indent, 0); }
/// <summary> /// Writes a DocumentObjectCollection type object to string. Indent a new block by /// indent + initialIndent characters. /// </summary> public static string WriteToString(DocumentObjectCollection docObjectContainer, int indent, int initialIndent) { StringBuilder strBuilder = new StringBuilder(); StringWriter writer = null; DdlWriter wrt = null; try { writer = new StringWriter(strBuilder); wrt = new DdlWriter(writer); wrt.Indent = indent; wrt.InitialIndent = initialIndent; wrt.WriteDocument(docObjectContainer); wrt.Close(); } finally { if (wrt != null) wrt.Close(); if (writer != null) writer.Close(); } return strBuilder.ToString(); }
/// <summary> /// Writes a DocumentObjectCollection type object to string. Indent a new block by _indent characters. /// </summary> public static string WriteToString(DocumentObjectCollection docObjectContainer, int indent) { return WriteToString(docObjectContainer, indent, 0); }
/// <summary> /// Writes the specified DocumentObjectCollection to DDL. /// </summary> public void WriteDocument(DocumentObjectCollection documentObjectContainer) { documentObjectContainer.Serialize(this.serializer); this.serializer.Flush(); }