Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / Entity / Design / MetadataItemCollectionFactory.cs / 1305376 / MetadataItemCollectionFactory.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Entity; using System.Data.EntityModel; using System.Xml; using System.Collections.Generic; using System.Data.Common; using System.Data.Metadata.Edm; using System.Data.Mapping; using System.Data.Entity.Design.Common; using Microsoft.Build.Utilities; using System.Data.Entity.Design.SsdlGenerator; using System.Diagnostics; using System.Linq; namespace System.Data.Entity.Design { ////// Factory for creating ItemCollections. This class is to be used for /// design time scenarios. The consumers of the methods in this class /// will get an error list instead of an exception if there are errors in schema files. /// [CLSCompliant(false)] public static class MetadataItemCollectionFactory { ////// Create an EdmItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")] public static EdmItemCollection CreateEdmItemCollection(IEnumerable readers, out IList errors) { System.Collections.ObjectModel.ReadOnlyCollection filePaths = null; return new EdmItemCollection(readers, filePaths, out errors); } /// /// Create an EdmItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")] public static EdmItemCollection CreateEdmItemCollection(IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); EdmItemCollection edmItemCollection = CreateEdmItemCollection(readers, out errors); if (!errors.Any(e => e.Severity == EdmSchemaErrorSeverity.Error)) { CheckActualVersionAgainstTarget(targetEntityFrameworkVersion, EntityFrameworkVersions.ConvertToVersion(edmItemCollection.EdmVersion), errors); } return edmItemCollection; } private static void CheckActualVersionAgainstTarget(Version maxExpectedVersion, Version actualVersion, IList errors) { if (!(actualVersion <= maxExpectedVersion)) { errors.Add(new EdmSchemaError(Strings.TargetVersionSchemaVersionMismatch(maxExpectedVersion, actualVersion), (int)ModelBuilderErrorCode.SchemaVersionHigherThanTargetVersion, EdmSchemaErrorSeverity.Error)); } } /// /// Create an StoreItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// ///public static StoreItemCollection CreateStoreItemCollection(IEnumerable readers, out IList errors) { return new StoreItemCollection(readers, null, out errors); } /// /// Create an StoreItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// ///public static StoreItemCollection CreateStoreItemCollection( IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); return CreateStoreItemCollection(readers, out errors); } /// /// Create a StorageMappingItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "edm")] public static StorageMappingItemCollection CreateStorageMappingItemCollection(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable readers, out IList errors) { return new StorageMappingItemCollection(edmCollection, storeCollection, readers, null, out errors); } /// /// Create a StorageMappingItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "edm")] public static StorageMappingItemCollection CreateStorageMappingItemCollection( EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckArgumentNull(edmCollection, "edmCollection"); EDesignUtil.CheckArgumentNull(storeCollection, "storeCollection"); EDesignUtil.CheckArgumentNull(readers, "readers"); EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); if (EntityFrameworkVersions.ConvertToVersion(edmCollection.EdmVersion) > targetEntityFrameworkVersion) { throw EDesignUtil.Argument("edmCollection"); } StorageMappingItemCollection storageMappingItemCollection = CreateStorageMappingItemCollection(edmCollection, storeCollection, readers, out errors); if (!errors.Any(e => e.Severity == EdmSchemaErrorSeverity.Error)) { CheckActualVersionAgainstTarget(targetEntityFrameworkVersion, EntityFrameworkVersions.ConvertToVersion(storageMappingItemCollection.MappingVersion), errors); } return storageMappingItemCollection; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Data.Entity; using System.Data.EntityModel; using System.Xml; using System.Collections.Generic; using System.Data.Common; using System.Data.Metadata.Edm; using System.Data.Mapping; using System.Data.Entity.Design.Common; using Microsoft.Build.Utilities; using System.Data.Entity.Design.SsdlGenerator; using System.Diagnostics; using System.Linq; namespace System.Data.Entity.Design { ////// Factory for creating ItemCollections. This class is to be used for /// design time scenarios. The consumers of the methods in this class /// will get an error list instead of an exception if there are errors in schema files. /// [CLSCompliant(false)] public static class MetadataItemCollectionFactory { ////// Create an EdmItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")] public static EdmItemCollection CreateEdmItemCollection(IEnumerable readers, out IList errors) { System.Collections.ObjectModel.ReadOnlyCollection filePaths = null; return new EdmItemCollection(readers, filePaths, out errors); } /// /// Create an EdmItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")] public static EdmItemCollection CreateEdmItemCollection(IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); EdmItemCollection edmItemCollection = CreateEdmItemCollection(readers, out errors); if (!errors.Any(e => e.Severity == EdmSchemaErrorSeverity.Error)) { CheckActualVersionAgainstTarget(targetEntityFrameworkVersion, EntityFrameworkVersions.ConvertToVersion(edmItemCollection.EdmVersion), errors); } return edmItemCollection; } private static void CheckActualVersionAgainstTarget(Version maxExpectedVersion, Version actualVersion, IList errors) { if (!(actualVersion <= maxExpectedVersion)) { errors.Add(new EdmSchemaError(Strings.TargetVersionSchemaVersionMismatch(maxExpectedVersion, actualVersion), (int)ModelBuilderErrorCode.SchemaVersionHigherThanTargetVersion, EdmSchemaErrorSeverity.Error)); } } /// /// Create an StoreItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// ///public static StoreItemCollection CreateStoreItemCollection(IEnumerable readers, out IList errors) { return new StoreItemCollection(readers, null, out errors); } /// /// Create an StoreItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// ///public static StoreItemCollection CreateStoreItemCollection( IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); return CreateStoreItemCollection(readers, out errors); } /// /// Create a StorageMappingItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "edm")] public static StorageMappingItemCollection CreateStorageMappingItemCollection(EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable readers, out IList errors) { return new StorageMappingItemCollection(edmCollection, storeCollection, readers, null, out errors); } /// /// Create a StorageMappingItemCollection with the passed in parameters. /// Add any errors caused during the ItemCollection creation /// to the error list passed in. /// /// /// /// /// /// ///[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "edm")] public static StorageMappingItemCollection CreateStorageMappingItemCollection( EdmItemCollection edmCollection, StoreItemCollection storeCollection, IEnumerable readers, Version targetEntityFrameworkVersion, out IList errors) { EDesignUtil.CheckArgumentNull(edmCollection, "edmCollection"); EDesignUtil.CheckArgumentNull(storeCollection, "storeCollection"); EDesignUtil.CheckArgumentNull(readers, "readers"); EDesignUtil.CheckTargetEntityFrameworkVersionArgument(targetEntityFrameworkVersion, "targetEntityFrameworkVersion"); if (EntityFrameworkVersions.ConvertToVersion(edmCollection.EdmVersion) > targetEntityFrameworkVersion) { throw EDesignUtil.Argument("edmCollection"); } StorageMappingItemCollection storageMappingItemCollection = CreateStorageMappingItemCollection(edmCollection, storeCollection, readers, out errors); if (!errors.Any(e => e.Severity == EdmSchemaErrorSeverity.Error)) { CheckActualVersionAgainstTarget(targetEntityFrameworkVersion, EntityFrameworkVersions.ConvertToVersion(storageMappingItemCollection.MappingVersion), errors); } return storageMappingItemCollection; } } } // 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
- ScrollData.cs
- SqlFileStream.cs
- ScrollProperties.cs
- SqlDataSourceFilteringEventArgs.cs
- TreeNode.cs
- SoapElementAttribute.cs
- EdgeProfileValidation.cs
- Trace.cs
- ItemDragEvent.cs
- CurrentChangingEventManager.cs
- DocumentViewerAutomationPeer.cs
- TypeSystem.cs
- UriExt.cs
- WeakKeyDictionary.cs
- PageCodeDomTreeGenerator.cs
- RangeValueProviderWrapper.cs
- DBSchemaTable.cs
- MediaTimeline.cs
- UserMapPath.cs
- HelpEvent.cs
- XhtmlBasicLinkAdapter.cs
- SiteMembershipCondition.cs
- SqlBulkCopy.cs
- FormViewInsertEventArgs.cs
- ProfessionalColorTable.cs
- TypeConverters.cs
- TextBoxAutomationPeer.cs
- MetadataResolver.cs
- ExtensionSurface.cs
- OptionUsage.cs
- ModelChangedEventArgsImpl.cs
- ObjectReferenceStack.cs
- TransformProviderWrapper.cs
- SqlDataAdapter.cs
- SimpleWorkerRequest.cs
- ImageIndexConverter.cs
- TraceShell.cs
- AspCompat.cs
- StrokeSerializer.cs
- RenderDataDrawingContext.cs
- SqlUserDefinedTypeAttribute.cs
- DataServiceQueryOfT.cs
- FileChangesMonitor.cs
- HttpProcessUtility.cs
- XmlQualifiedName.cs
- SmiEventSink_Default.cs
- WindowsHyperlink.cs
- Geometry.cs
- DiagnosticsConfigurationHandler.cs
- AddInEnvironment.cs
- basenumberconverter.cs
- UserControl.cs
- PasswordRecovery.cs
- ThreadInterruptedException.cs
- SynchronizationLockException.cs
- Set.cs
- XmlAttributeOverrides.cs
- SemanticBasicElement.cs
- OdbcConnectionOpen.cs
- FilterElement.cs
- SafeRightsManagementHandle.cs
- LinearGradientBrush.cs
- InstanceLockQueryResult.cs
- ReachDocumentReferenceSerializerAsync.cs
- TextElementEnumerator.cs
- TTSEvent.cs
- ControlIdConverter.cs
- LoginName.cs
- DownloadProgressEventArgs.cs
- PopupControlService.cs
- Sql8ExpressionRewriter.cs
- DataColumnCollection.cs
- SafeSecurityHandles.cs
- ConfigurationElementCollection.cs
- WebBaseEventKeyComparer.cs
- CalendarDateRangeChangingEventArgs.cs
- BitmapEffectGeneralTransform.cs
- SHA384CryptoServiceProvider.cs
- RtfNavigator.cs
- RestClientProxyHandler.cs
- TextEditorSpelling.cs
- KeyMatchBuilder.cs
- DrawingContextWalker.cs
- SessionStateModule.cs
- GridToolTip.cs
- VirtualizingStackPanel.cs
- OverrideMode.cs
- AdapterUtil.cs
- SQLResource.cs
- StrokeCollection.cs
- ToolStripActionList.cs
- CommandPlan.cs
- LogWriteRestartAreaAsyncResult.cs
- GroupBoxRenderer.cs
- DependentList.cs
- EntityContainerAssociationSet.cs
- RSAOAEPKeyExchangeFormatter.cs
- InkCanvasSelection.cs
- GridViewDeletedEventArgs.cs
- ObjectAssociationEndMapping.cs