Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Metadata / MetadataArtifactLoaderFile.cs / 2 / MetadataArtifactLoaderFile.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
//---------------------------------------------------------------------
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.Security.Cryptography;
using System.Data.EntityModel.SchemaObjectModel;
using System.Threading;
namespace System.Data.Metadata.Edm
{
///
/// This class represents one file-based artifact item to be loaded.
///
internal class MetadataArtifactLoaderFile : MetadataArtifactLoader, IComparable
{
///
/// This member indicates whether the file-based artifact has already been loaded.
/// It is used to prevent other instances of this class from (re)loading the same
/// artifact. See comment in the MetadataArtifactLoaderFile c'tor below.
///
private readonly bool _alreadyLoaded = false;
private readonly string _path;
///
/// Constructor
///
/// The path to the resource to load
/// The global registry of URIs
public MetadataArtifactLoaderFile(string path, ICollection uriRegistry)
{
_path = path;
_alreadyLoaded = uriRegistry.Contains(_path);
if (!_alreadyLoaded)
{
uriRegistry.Add(_path);
// '_alreadyLoaded' is not set because while we would like to prevent
// other instances of MetadataArtifactLoaderFile that wrap the same
// _path from being added to the list of paths/readers, we do want to
// include this particular instance.
}
}
public override string Path
{
get { return _path; }
}
///
/// Implementation of IComparable.CompareTo()
///
/// The object to compare to
/// 0 if the loaders are "equal" (i.e., have the same _path value)
public int CompareTo(object obj)
{
MetadataArtifactLoaderFile loader = obj as MetadataArtifactLoaderFile;
if (loader != null)
{
return string.Compare(_path, loader._path, StringComparison.OrdinalIgnoreCase);
}
Debug.Assert(false, "object is not a MetadataArtifactLoaderFile");
return -1;
}
///
/// Equals() returns true if the objects have the same _path value
///
/// The object to compare to
/// true if the objects have the same _path value
public override bool Equals(object obj)
{
return this.CompareTo(obj) == 0;
}
///
/// GetHashCode override that defers the result to the _path member variable.
///
///
public override int GetHashCode()
{
return _path.GetHashCode();
}
public override void CollectFilePermissionPaths(List paths, DataSpace spaceToGet)
{
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
paths.Add(_path);
}
}
///
/// Get paths to artifacts for a specific DataSpace.
///
/// The DataSpace for the artifacts of interest
/// A List of strings identifying paths to all artifacts for a specific DataSpace
public override List GetPaths(DataSpace spaceToGet)
{
List list = new List();
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
list.Add(_path);
}
return list;
}
///
/// Get paths to all artifacts
///
/// A List of strings identifying paths to all resources
public override List GetPaths()
{
List list = new List();
if (!_alreadyLoaded)
{
list.Add(_path);
}
return list;
}
///
/// Create and return an XmlReader around the file represented by this instance.
///
/// A List of XmlReaders for all resources
public override List GetReaders(Dictionary sourceDictionary)
{
List list = new List();
if (!_alreadyLoaded)
{
XmlReader reader = CreateXmlReader();
list.Add(reader);
if (sourceDictionary != null)
{
sourceDictionary.Add(this, reader);
}
}
return list;
}
///
/// Create and return an XmlReader around the file represented by this instance
/// if it is of the requested DataSpace type.
///
/// The DataSpace corresponding to the requested artifacts
/// A List of XmlReader objects
public override List CreateReaders(DataSpace spaceToGet)
{
List list = new List();
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
XmlReader reader = CreateXmlReader();
list.Add(reader);
}
return list;
}
///
/// Create an XmlReader around the artifact file
///
/// An XmlReader that wraps a file
private XmlReader CreateXmlReader()
{
XmlReaderSettings readerSettings = Schema.CreateEdmStandardXmlReaderSettings();
// we know that we aren't reading a fragment
readerSettings.ConformanceLevel = ConformanceLevel.Document;
return XmlReader.Create(_path, readerSettings);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
//---------------------------------------------------------------------
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.Security.Cryptography;
using System.Data.EntityModel.SchemaObjectModel;
using System.Threading;
namespace System.Data.Metadata.Edm
{
///
/// This class represents one file-based artifact item to be loaded.
///
internal class MetadataArtifactLoaderFile : MetadataArtifactLoader, IComparable
{
///
/// This member indicates whether the file-based artifact has already been loaded.
/// It is used to prevent other instances of this class from (re)loading the same
/// artifact. See comment in the MetadataArtifactLoaderFile c'tor below.
///
private readonly bool _alreadyLoaded = false;
private readonly string _path;
///
/// Constructor
///
/// The path to the resource to load
/// The global registry of URIs
public MetadataArtifactLoaderFile(string path, ICollection uriRegistry)
{
_path = path;
_alreadyLoaded = uriRegistry.Contains(_path);
if (!_alreadyLoaded)
{
uriRegistry.Add(_path);
// '_alreadyLoaded' is not set because while we would like to prevent
// other instances of MetadataArtifactLoaderFile that wrap the same
// _path from being added to the list of paths/readers, we do want to
// include this particular instance.
}
}
public override string Path
{
get { return _path; }
}
///
/// Implementation of IComparable.CompareTo()
///
/// The object to compare to
/// 0 if the loaders are "equal" (i.e., have the same _path value)
public int CompareTo(object obj)
{
MetadataArtifactLoaderFile loader = obj as MetadataArtifactLoaderFile;
if (loader != null)
{
return string.Compare(_path, loader._path, StringComparison.OrdinalIgnoreCase);
}
Debug.Assert(false, "object is not a MetadataArtifactLoaderFile");
return -1;
}
///
/// Equals() returns true if the objects have the same _path value
///
/// The object to compare to
/// true if the objects have the same _path value
public override bool Equals(object obj)
{
return this.CompareTo(obj) == 0;
}
///
/// GetHashCode override that defers the result to the _path member variable.
///
///
public override int GetHashCode()
{
return _path.GetHashCode();
}
public override void CollectFilePermissionPaths(List paths, DataSpace spaceToGet)
{
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
paths.Add(_path);
}
}
///
/// Get paths to artifacts for a specific DataSpace.
///
/// The DataSpace for the artifacts of interest
/// A List of strings identifying paths to all artifacts for a specific DataSpace
public override List GetPaths(DataSpace spaceToGet)
{
List list = new List();
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
list.Add(_path);
}
return list;
}
///
/// Get paths to all artifacts
///
/// A List of strings identifying paths to all resources
public override List GetPaths()
{
List list = new List();
if (!_alreadyLoaded)
{
list.Add(_path);
}
return list;
}
///
/// Create and return an XmlReader around the file represented by this instance.
///
/// A List of XmlReaders for all resources
public override List GetReaders(Dictionary sourceDictionary)
{
List list = new List();
if (!_alreadyLoaded)
{
XmlReader reader = CreateXmlReader();
list.Add(reader);
if (sourceDictionary != null)
{
sourceDictionary.Add(this, reader);
}
}
return list;
}
///
/// Create and return an XmlReader around the file represented by this instance
/// if it is of the requested DataSpace type.
///
/// The DataSpace corresponding to the requested artifacts
/// A List of XmlReader objects
public override List CreateReaders(DataSpace spaceToGet)
{
List list = new List();
if (!_alreadyLoaded && MetadataArtifactLoader.IsArtifactOfDataSpace(_path, spaceToGet))
{
XmlReader reader = CreateXmlReader();
list.Add(reader);
}
return list;
}
///
/// Create an XmlReader around the artifact file
///
/// An XmlReader that wraps a file
private XmlReader CreateXmlReader()
{
XmlReaderSettings readerSettings = Schema.CreateEdmStandardXmlReaderSettings();
// we know that we aren't reading a fragment
readerSettings.ConformanceLevel = ConformanceLevel.Document;
return XmlReader.Create(_path, readerSettings);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- odbcmetadatafactory.cs
- QuerySubExprEliminator.cs
- InputBinding.cs
- SoapFault.cs
- SafeArrayTypeMismatchException.cs
- BindingList.cs
- XamlGridLengthSerializer.cs
- CriticalExceptions.cs
- InkCanvas.cs
- Encoder.cs
- CodeDirectionExpression.cs
- ParsedRoute.cs
- ListenerPerfCounters.cs
- QueryOperatorEnumerator.cs
- ToolStripPanelCell.cs
- XsltArgumentList.cs
- CombinedTcpChannel.cs
- CacheDependency.cs
- SystemIPv6InterfaceProperties.cs
- XPathNodeHelper.cs
- Vector3DCollection.cs
- GatewayDefinition.cs
- GPPOINTF.cs
- CompilationUtil.cs
- IPAddress.cs
- DesignerWidgets.cs
- BaseParser.cs
- StrongNameMembershipCondition.cs
- InstallerTypeAttribute.cs
- HtmlUtf8RawTextWriter.cs
- X509CertificateChain.cs
- SpeechSynthesizer.cs
- TrackingDataItem.cs
- ParameterRefs.cs
- Stackframe.cs
- DataPagerField.cs
- DbConnectionPoolCounters.cs
- MouseButtonEventArgs.cs
- RemotingAttributes.cs
- ContentValidator.cs
- TablePattern.cs
- ClientOperationFormatterProvider.cs
- ToolStripSeparator.cs
- OleDbWrapper.cs
- TreeNodeMouseHoverEvent.cs
- ErrorWebPart.cs
- ExceptionValidationRule.cs
- RestClientProxyHandler.cs
- TransformValueSerializer.cs
- OSFeature.cs
- UserCancellationException.cs
- ReadOnlyAttribute.cs
- VisualStyleTypesAndProperties.cs
- Control.cs
- followingquery.cs
- XmlObjectSerializerReadContextComplex.cs
- Int32Storage.cs
- PropertyStore.cs
- _ProxyRegBlob.cs
- DataStorage.cs
- Control.cs
- XmlMapping.cs
- Latin1Encoding.cs
- BulletChrome.cs
- GroupBoxAutomationPeer.cs
- odbcmetadatacolumnnames.cs
- ObjectViewFactory.cs
- GradientBrush.cs
- HttpStaticObjectsCollectionWrapper.cs
- Viewport3DVisual.cs
- ProcessHostFactoryHelper.cs
- ValueProviderWrapper.cs
- SafeSecurityHandles.cs
- DataGridViewImageColumn.cs
- FocusTracker.cs
- SqlError.cs
- webclient.cs
- ScaleTransform3D.cs
- Permission.cs
- TextPointerBase.cs
- WindowsListViewScroll.cs
- PolyQuadraticBezierSegment.cs
- QuaternionValueSerializer.cs
- XmlSchemaAnnotated.cs
- Evidence.cs
- RemoteWebConfigurationHostStream.cs
- Context.cs
- DbProviderSpecificTypePropertyAttribute.cs
- JapaneseCalendar.cs
- QuaternionAnimationBase.cs
- FixedElement.cs
- SerializableTypeCodeDomSerializer.cs
- BamlRecordWriter.cs
- PathFigure.cs
- XPathEmptyIterator.cs
- ButtonPopupAdapter.cs
- UrlAuthFailedErrorFormatter.cs
- SpeakInfo.cs
- TransformProviderWrapper.cs
- TraceContext.cs