// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Harvesters.Serialize { using System; using System.Collections; using System.Xml; /// /// Interface for generated schema elements. /// public interface ISchemaElement { /// /// Gets and sets the parent of this element. May be null. /// /// An ISchemaElement that has this element as a child. ISchemaElement ParentElement { get; set; } /// /// Outputs xml representing this element, including the associated attributes /// and any nested elements. /// /// XmlWriter to be used when outputting the element. void OutputXml(XmlWriter writer); } /// /// Interface for generated schema elements. Implemented by elements that have child /// elements. /// public interface IParentElement { /// /// Gets an enumerable collection of the children of this element. /// /// An enumerable collection of the children of this element. IEnumerable Children { get; } /// /// Gets an enumerable collection of the children of this element, filtered /// by the passed in type. /// /// The type of children to retrieve. IEnumerable this[Type childType] { get; } /// /// Adds a child to this element. /// /// Child to add. void AddChild(ISchemaElement child); /// /// Removes a child from this element. /// /// Child to remove. void RemoveChild(ISchemaElement child); } /// /// Interface for generated schema elements. Implemented by classes with attributes. /// public interface ISetAttributes { /// /// Sets the attribute with the given name to the given value. The value here is /// a string, and is converted to the strongly-typed version inside this method. /// /// The name of the attribute to set. /// The value to assign to the attribute. void SetAttribute(string name, string value); } /// /// Interface for generated schema elements. Implemented by classes with children. /// public interface ICreateChildren { /// /// Creates an instance of the child with the passed in name. /// /// String matching the element name of the child when represented in XML. /// An instance of that child. ISchemaElement CreateChild(string childName); } }