aboutsummaryrefslogtreecommitdiff
path: root/src/internal/WixBuildTools.XsdGen/CodeDomInterfaces.cs
blob: 850839d44924c69cf6a16d36f8fbff6b75fed311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 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.Serialize
{
    using System;
    using System.Collections;
    using System.Xml;

    /// <summary>
    /// Interface for generated schema elements.
    /// </summary>
    public interface ISchemaElement
    {
        /// <summary>
        /// Gets and sets the parent of this element. May be null.
        /// </summary>
        /// <value>An ISchemaElement that has this element as a child.</value>
        ISchemaElement ParentElement
        {
            get;
            set;
        }
    
        /// <summary>
        /// Outputs xml representing this element, including the associated attributes
        /// and any nested elements.
        /// </summary>
        /// <param name="writer">XmlTextWriter to be used when outputting the element.</param>
        void OutputXml(XmlWriter writer);
    }

    /// <summary>
    /// Interface for generated schema elements. Implemented by elements that have child
    /// elements.
    /// </summary>
    public interface IParentElement
    {
        /// <summary>
        /// Gets an enumerable collection of the children of this element.
        /// </summary>
        /// <value>An enumerable collection of the children of this element.</value>
        IEnumerable Children
        {
            get;
        }

        /// <summary>
        /// Gets an enumerable collection of the children of this element, filtered
        /// by the passed in type.
        /// </summary>
        /// <param name="childType">The type of children to retrieve.</param>
        IEnumerable this[Type childType]
        {
            get;
        }

        /// <summary>
        /// Adds a child to this element.
        /// </summary>
        /// <param name="child">Child to add.</param>
        void AddChild(ISchemaElement child);

        /// <summary>
        /// Removes a child from this element.
        /// </summary>
        /// <param name="child">Child to remove.</param>
        void RemoveChild(ISchemaElement child);
    }

    /// <summary>
    /// Interface for generated schema elements. Implemented by classes with attributes.
    /// </summary>
    public interface ISetAttributes
    {
        /// <summary>
        /// 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.
        /// </summary>
        /// <param name="name">The name of the attribute to set.</param>
        /// <param name="value">The value to assign to the attribute.</param>
        void SetAttribute(string name, string value);
    }

    /// <summary>
    /// Interface for generated schema elements. Implemented by classes with children.
    /// </summary>
    public interface ICreateChildren
    {
        /// <summary>
        /// Creates an instance of the child with the passed in name.
        /// </summary>
        /// <param name="childName">String matching the element name of the child when represented in XML.</param>
        /// <returns>An instance of that child.</returns>
        ISchemaElement CreateChild(string childName);
    }
}