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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
|
//---------------------------------------------------------------------
// <copyright file="MetadataArtifactLoaderComposite.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//
// @owner Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Data.Mapping;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Collections.ObjectModel;
namespace System.Data.Metadata.Edm
{
/// <summary>
/// This class represents a super-collection (a collection of collections)
/// of artifact resources. Typically, this "meta-collection" would contain
/// artifacts represented as individual files, directories (which are in
/// turn collections of files), and embedded resources.
/// </summary>
/// <remarks>This is the root class for access to all loader objects.</remarks>
internal class MetadataArtifactLoaderComposite : MetadataArtifactLoader, IEnumerable<MetadataArtifactLoader>
{
/// <summary>
/// The list of loaders aggregated by the composite.
/// </summary>
private readonly ReadOnlyCollection<MetadataArtifactLoader> _children;
/// <summary>
/// Constructor - loads all resources into the _children collection
/// </summary>
/// <param name="children">A list of collections to aggregate</param>
public MetadataArtifactLoaderComposite(List<MetadataArtifactLoader> children)
{
Debug.Assert(children != null);
_children = new List<MetadataArtifactLoader>(children).AsReadOnly();
}
public override string Path
{
get { return string.Empty; }
}
public override void CollectFilePermissionPaths(List<string> paths, DataSpace spaceToGet)
{
foreach (MetadataArtifactLoader loader in _children)
{
loader.CollectFilePermissionPaths(paths, spaceToGet);
}
}
public override bool IsComposite
{
get
{
return true;
}
}
/// <summary>
/// Get the list of paths to all artifacts in the original, unexpanded form
/// </summary>
/// <returns>A List of strings identifying paths to all resources</returns>
public override List<string> GetOriginalPaths()
{
List<string> list = new List<string>();
foreach (MetadataArtifactLoader loader in _children)
{
list.AddRange(loader.GetOriginalPaths());
}
return list;
}
/// <summary>
/// Get paths to artifacts for a specific DataSpace, in the original, unexpanded
/// form
/// </summary>
/// <param name="spaceToGet">The DataSpace for the artifacts of interest</param>
/// <returns>A List of strings identifying paths to all artifacts for a specific DataSpace</returns>
public override List<string> GetOriginalPaths(DataSpace spaceToGet)
{
List<string> list = new List<string>();
foreach (MetadataArtifactLoader loader in _children)
{
list.AddRange(loader.GetOriginalPaths(spaceToGet));
}
return list;
}
/// <summary>
/// Get paths to artifacts for a specific DataSpace.
/// </summary>
/// <param name="spaceToGet">The DataSpace for the artifacts of interest</param>
/// <returns>A List of strings identifying paths to all artifacts for a specific DataSpace</returns>
public override List<string> GetPaths(DataSpace spaceToGet)
{
List<string> list = new List<string>();
foreach (MetadataArtifactLoader loader in _children)
{
list.AddRange(loader.GetPaths(spaceToGet));
}
return list;
}
/// <summary>
/// Get paths to all artifacts
/// </summary>
/// <returns>A List of strings identifying paths to all resources</returns>
public override List<string> GetPaths()
{
List<string> list = new List<string>();
foreach (MetadataArtifactLoader resource in _children)
{
list.AddRange(resource.GetPaths());
}
return list;
}
/// <summary>
/// Aggregates all resource streams from the _children collection
/// </summary>
/// <returns>A List of XmlReader objects; cannot be null</returns>
public override List<XmlReader> GetReaders(Dictionary<MetadataArtifactLoader, XmlReader> sourceDictionary)
{
List<XmlReader> list = new List<XmlReader>();
foreach (MetadataArtifactLoader resource in _children)
{
list.AddRange(resource.GetReaders(sourceDictionary));
}
return list;
}
/// <summary>
/// Get XmlReaders for a specific DataSpace.
/// </summary>
/// <param name="spaceToGet">The DataSpace corresponding to the requested artifacts</param>
/// <returns>A List of XmlReader objects</returns>
public override List<XmlReader> CreateReaders(DataSpace spaceToGet)
{
List<XmlReader> list = new List<XmlReader>();
foreach (MetadataArtifactLoader resource in _children)
{
list.AddRange(resource.CreateReaders(spaceToGet));
}
return list;
}
#region IEnumerable<MetadataArtifactLoader> Members
public IEnumerator<MetadataArtifactLoader> GetEnumerator()
{
return this._children.GetEnumerator();
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
return this._children.GetEnumerator();
}
#endregion
}
}
|