Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / XmlSchemaResource.cs / 1305376 / XmlSchemaResource.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Diagnostics;
using System.Data.Mapping;
using System.Data.Metadata.Edm;
using System.Collections.Generic;
namespace System.Data.EntityModel.SchemaObjectModel
{
internal struct XmlSchemaResource
{
private static XmlSchemaResource[] EmptyImportList = new XmlSchemaResource[0];
public XmlSchemaResource(string namespaceUri, string resourceName, XmlSchemaResource[] importedSchemas)
{
Debug.Assert(!string.IsNullOrEmpty(namespaceUri), "namespaceUri is null or empty");
Debug.Assert(!string.IsNullOrEmpty(resourceName), "resourceName is null or empty");
Debug.Assert(importedSchemas != null, "importedSchemas is null");
NamespaceUri = namespaceUri;
ResourceName = resourceName;
ImportedSchemas = importedSchemas;
}
public XmlSchemaResource(string namespaceUri, string resourceName)
{
Debug.Assert(!string.IsNullOrEmpty(namespaceUri), "namespaceUri is null or empty");
Debug.Assert(!string.IsNullOrEmpty(resourceName), "resourceName is null or empty");
NamespaceUri = namespaceUri;
ResourceName = resourceName;
ImportedSchemas = EmptyImportList;
}
internal string NamespaceUri;
internal string ResourceName;
internal XmlSchemaResource[] ImportedSchemas;
///
/// Builds a dictionary from XmlNamespace to XmlSchemaResource of both C and S space schemas
///
/// The built XmlNamespace to XmlSchemaResource dictionary.
internal static Dictionary GetMetadataSchemaResourceMap(double schemaVersion)
{
Dictionary schemaResourceMap = new Dictionary(StringComparer.Ordinal);
AddEdmSchemaResourceMapEntries(schemaResourceMap, schemaVersion);
AddStoreSchemaResourceMapEntries(schemaResourceMap, schemaVersion);
return schemaResourceMap;
}
///
/// Adds Store schema resource entries to the given XmlNamespace to XmlSchemaResoure map
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddStoreSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource[] ssdlImports = { new XmlSchemaResource(XmlConstants.EntityStoreSchemaGeneratorNamespace, "System.Data.Resources.EntityStoreSchemaGenerator.xsd") };
XmlSchemaResource ssdlSchema = new XmlSchemaResource(XmlConstants.TargetNamespace_1, "System.Data.Resources.SSDLSchema.xsd", ssdlImports);
schemaResourceMap.Add(ssdlSchema.NamespaceUri, ssdlSchema);
if (schemaVersion == XmlConstants.StoreVersionForV2)
{
XmlSchemaResource ssdlSchema2 = new XmlSchemaResource(XmlConstants.TargetNamespace_2, "System.Data.Resources.SSDLSchema_2.xsd", ssdlImports);
schemaResourceMap.Add(ssdlSchema2.NamespaceUri, ssdlSchema2);
}
XmlSchemaResource providerManifest = new XmlSchemaResource(XmlConstants.ProviderManifestNamespace, "System.Data.Resources.ProviderServices.ProviderManifest.xsd");
schemaResourceMap.Add(providerManifest.NamespaceUri, providerManifest);
}
///
/// Adds Mapping schema resource entries to the given XmlNamespace to XmlSchemaResoure map
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddMappingSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource msl1 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV1, StorageMslConstructs.ResourceXsdNameV1);
schemaResourceMap.Add(msl1.NamespaceUri, msl1);
if (schemaVersion == XmlConstants.EdmVersionForV2)
{
XmlSchemaResource msl2 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV2, StorageMslConstructs.ResourceXsdNameV2);
schemaResourceMap.Add(msl2.NamespaceUri, msl2);
}
}
///
/// Adds Edm schema resource entries to the given XmlNamespace to XmlSchemaResoure map,
/// when calling from SomSchemaSetHelper.ComputeSchemaSet(), all the imported xsd will be included
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddEdmSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource[] csdlImports = { new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd") };
XmlSchemaResource[] csdl2Imports = {
new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
new XmlSchemaResource(XmlConstants.AnnotationNamespace, "System.Data.Resources.AnnotationSchema.xsd") };
XmlSchemaResource csdlSchema_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1, "System.Data.Resources.CSDLSchema_1.xsd", csdlImports);
schemaResourceMap.Add(csdlSchema_1.NamespaceUri, csdlSchema_1);
XmlSchemaResource csdlSchema_1_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1_1, "System.Data.Resources.CSDLSchema_1_1.xsd", csdlImports);
schemaResourceMap.Add(csdlSchema_1_1.NamespaceUri, csdlSchema_1_1);
if (schemaVersion == XmlConstants.EdmVersionForV2)
{
XmlSchemaResource csdlSchema_2 = new XmlSchemaResource(XmlConstants.ModelNamespace_2, "System.Data.Resources.CSDLSchema_2.xsd", csdl2Imports);
schemaResourceMap.Add(csdlSchema_2.NamespaceUri, csdlSchema_2);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Diagnostics;
using System.Data.Mapping;
using System.Data.Metadata.Edm;
using System.Collections.Generic;
namespace System.Data.EntityModel.SchemaObjectModel
{
internal struct XmlSchemaResource
{
private static XmlSchemaResource[] EmptyImportList = new XmlSchemaResource[0];
public XmlSchemaResource(string namespaceUri, string resourceName, XmlSchemaResource[] importedSchemas)
{
Debug.Assert(!string.IsNullOrEmpty(namespaceUri), "namespaceUri is null or empty");
Debug.Assert(!string.IsNullOrEmpty(resourceName), "resourceName is null or empty");
Debug.Assert(importedSchemas != null, "importedSchemas is null");
NamespaceUri = namespaceUri;
ResourceName = resourceName;
ImportedSchemas = importedSchemas;
}
public XmlSchemaResource(string namespaceUri, string resourceName)
{
Debug.Assert(!string.IsNullOrEmpty(namespaceUri), "namespaceUri is null or empty");
Debug.Assert(!string.IsNullOrEmpty(resourceName), "resourceName is null or empty");
NamespaceUri = namespaceUri;
ResourceName = resourceName;
ImportedSchemas = EmptyImportList;
}
internal string NamespaceUri;
internal string ResourceName;
internal XmlSchemaResource[] ImportedSchemas;
///
/// Builds a dictionary from XmlNamespace to XmlSchemaResource of both C and S space schemas
///
/// The built XmlNamespace to XmlSchemaResource dictionary.
internal static Dictionary GetMetadataSchemaResourceMap(double schemaVersion)
{
Dictionary schemaResourceMap = new Dictionary(StringComparer.Ordinal);
AddEdmSchemaResourceMapEntries(schemaResourceMap, schemaVersion);
AddStoreSchemaResourceMapEntries(schemaResourceMap, schemaVersion);
return schemaResourceMap;
}
///
/// Adds Store schema resource entries to the given XmlNamespace to XmlSchemaResoure map
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddStoreSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource[] ssdlImports = { new XmlSchemaResource(XmlConstants.EntityStoreSchemaGeneratorNamespace, "System.Data.Resources.EntityStoreSchemaGenerator.xsd") };
XmlSchemaResource ssdlSchema = new XmlSchemaResource(XmlConstants.TargetNamespace_1, "System.Data.Resources.SSDLSchema.xsd", ssdlImports);
schemaResourceMap.Add(ssdlSchema.NamespaceUri, ssdlSchema);
if (schemaVersion == XmlConstants.StoreVersionForV2)
{
XmlSchemaResource ssdlSchema2 = new XmlSchemaResource(XmlConstants.TargetNamespace_2, "System.Data.Resources.SSDLSchema_2.xsd", ssdlImports);
schemaResourceMap.Add(ssdlSchema2.NamespaceUri, ssdlSchema2);
}
XmlSchemaResource providerManifest = new XmlSchemaResource(XmlConstants.ProviderManifestNamespace, "System.Data.Resources.ProviderServices.ProviderManifest.xsd");
schemaResourceMap.Add(providerManifest.NamespaceUri, providerManifest);
}
///
/// Adds Mapping schema resource entries to the given XmlNamespace to XmlSchemaResoure map
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddMappingSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource msl1 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV1, StorageMslConstructs.ResourceXsdNameV1);
schemaResourceMap.Add(msl1.NamespaceUri, msl1);
if (schemaVersion == XmlConstants.EdmVersionForV2)
{
XmlSchemaResource msl2 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV2, StorageMslConstructs.ResourceXsdNameV2);
schemaResourceMap.Add(msl2.NamespaceUri, msl2);
}
}
///
/// Adds Edm schema resource entries to the given XmlNamespace to XmlSchemaResoure map,
/// when calling from SomSchemaSetHelper.ComputeSchemaSet(), all the imported xsd will be included
///
/// The XmlNamespace to XmlSchemaResource map to add entries to.
internal static void AddEdmSchemaResourceMapEntries(Dictionary schemaResourceMap, double schemaVersion)
{
XmlSchemaResource[] csdlImports = { new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd") };
XmlSchemaResource[] csdl2Imports = {
new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
new XmlSchemaResource(XmlConstants.AnnotationNamespace, "System.Data.Resources.AnnotationSchema.xsd") };
XmlSchemaResource csdlSchema_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1, "System.Data.Resources.CSDLSchema_1.xsd", csdlImports);
schemaResourceMap.Add(csdlSchema_1.NamespaceUri, csdlSchema_1);
XmlSchemaResource csdlSchema_1_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1_1, "System.Data.Resources.CSDLSchema_1_1.xsd", csdlImports);
schemaResourceMap.Add(csdlSchema_1_1.NamespaceUri, csdlSchema_1_1);
if (schemaVersion == XmlConstants.EdmVersionForV2)
{
XmlSchemaResource csdlSchema_2 = new XmlSchemaResource(XmlConstants.ModelNamespace_2, "System.Data.Resources.CSDLSchema_2.xsd", csdl2Imports);
schemaResourceMap.Add(csdlSchema_2.NamespaceUri, csdlSchema_2);
}
}
}
}
// 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
- CustomAttributeBuilder.cs
- SettingsSection.cs
- OleDbError.cs
- UnknownBitmapEncoder.cs
- DoubleUtil.cs
- securitycriticaldataClass.cs
- unsafeIndexingFilterStream.cs
- DirectionalLight.cs
- PenCursorManager.cs
- WorkflowRuntimeEndpoint.cs
- DetailsViewPageEventArgs.cs
- WebAdminConfigurationHelper.cs
- TextParaClient.cs
- WindowsScrollBar.cs
- xsdvalidator.cs
- SafeEventLogWriteHandle.cs
- UniqueTransportManagerRegistration.cs
- IndentedTextWriter.cs
- MruCache.cs
- InvokeMethodActivityDesigner.cs
- WindowsUpDown.cs
- LinqDataSource.cs
- SoapObjectInfo.cs
- RSAPKCS1SignatureDeformatter.cs
- IdleTimeoutMonitor.cs
- ProxyWebPart.cs
- HTMLTagNameToTypeMapper.cs
- ContextMarshalException.cs
- Pair.cs
- SoapHeaderException.cs
- Point4DConverter.cs
- VisualState.cs
- recordstatefactory.cs
- HtmlElementErrorEventArgs.cs
- UnsafeNativeMethods.cs
- SystemColors.cs
- SystemThemeKey.cs
- XmlParserContext.cs
- Line.cs
- ConfigsHelper.cs
- Win32.cs
- XpsFontSubsetter.cs
- RowCache.cs
- TreeNodeBindingCollection.cs
- QuaternionAnimation.cs
- ScrollPattern.cs
- PlatformCulture.cs
- IconBitmapDecoder.cs
- TabControlDesigner.cs
- KeyValueConfigurationCollection.cs
- RoleGroupCollection.cs
- HtmlElementCollection.cs
- LinkedList.cs
- InfoCardKeyedHashAlgorithm.cs
- SimpleHandlerFactory.cs
- bindurihelper.cs
- PolicyStatement.cs
- WinEventWrap.cs
- HasCopySemanticsAttribute.cs
- CmsInterop.cs
- StackOverflowException.cs
- DecimalFormatter.cs
- RemoteWebConfigurationHostStream.cs
- FlowNode.cs
- DictionaryBase.cs
- _RequestCacheProtocol.cs
- ResumeStoryboard.cs
- EntitySetDataBindingList.cs
- FamilyTypeface.cs
- EditorPartChrome.cs
- DynamicQueryableWrapper.cs
- AudienceUriMode.cs
- ImageList.cs
- CompilerInfo.cs
- MethodCallConverter.cs
- RichTextBoxAutomationPeer.cs
- SQLDoubleStorage.cs
- CodeSnippetExpression.cs
- LinkTarget.cs
- SystemEvents.cs
- RawAppCommandInputReport.cs
- DataExpression.cs
- UInt16Storage.cs
- WindowAutomationPeer.cs
- WsdlWriter.cs
- KeyValuePair.cs
- SystemSounds.cs
- DataTableReaderListener.cs
- SessionPageStateSection.cs
- SqlInfoMessageEvent.cs
- DataGridViewCellParsingEventArgs.cs
- TreeViewAutomationPeer.cs
- WebBrowserBase.cs
- EventNotify.cs
- TextRangeAdaptor.cs
- System.Data.OracleClient_BID.cs
- ProjectionPruner.cs
- CollectionType.cs
- DataGridItemCollection.cs
- RootBrowserWindow.cs