Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / Entity / Design / AspNet / EntityDesignerBuildProvider.cs / 1305376 / EntityDesignerBuildProvider.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Collections.Generic; using System.CodeDom; using System.CodeDom.Compiler; using System.Globalization; using System.IO; using System.Text; using System.Web.Hosting; using System.Web.Compilation; using System.Xml; using System.Data.Metadata.Edm; namespace System.Data.Entity.Design.AspNet { ////// The ASP .NET Build provider for the CSDL in ADO .NET /// /// [BuildProviderAppliesTo(BuildProviderAppliesTo.Code)] public class EntityDesignerBuildProvider : System.Web.Compilation.BuildProvider { ////// Default constructor /// public EntityDesignerBuildProvider() { } ////// We want ASP .NET to always reset the app domain when we have to rebuild /// /// ///public override BuildProviderResultFlags GetResultFlags(CompilerResults results) { return BuildProviderResultFlags.ShutdownAppDomainOnChange; } /// /// Extract the CSDL, SSDL and MSL nodes from the EDMX file and store them /// as embedded resources /// /// public override void GenerateCode(AssemblyBuilder assemblyBuilder) { using (StreamReader edmxInputStream = new StreamReader(VirtualPathProvider.OpenFile(base.VirtualPath))) { // load up an XML document representing the edmx file XmlElement conceptualSchemaElement; XmlElement mappingElement; XmlElement storageSchemaElement; string embedAsResourcePropertyValue; EntityDesignerUtils.ExtractConceptualMappingAndStorageNodes(edmxInputStream, out conceptualSchemaElement, out mappingElement, out storageSchemaElement, out embedAsResourcePropertyValue); if (null == conceptualSchemaElement) { throw new XmlException("No Conceptual Schema node to embed as a resource", null, 0, 0); } if (null == storageSchemaElement) { throw new XmlException("No Storage Schema node to embed as a resource", null, 0, 0); } if (null == mappingElement) { throw new XmlException("No Mapping node to embed as a resource", null, 0, 0); } // construct output paths where the CSDL/MSL/SSDL resources will be placed string virtualPathPrefix = base.VirtualPath.Replace(EntityDesignerUtils._edmxFileExtension, String.Empty); string csdlResourceName = BuildProviderUtils.GetResourceNameForVirtualPath(virtualPathPrefix + XmlConstants.CSpaceSchemaExtension); string ssdlResourceName = BuildProviderUtils.GetResourceNameForVirtualPath(virtualPathPrefix + XmlConstants.SSpaceSchemaExtension); string mslResourceName = BuildProviderUtils.GetResourceNameForVirtualPath(virtualPathPrefix + XmlConstants.CSSpaceSchemaExtension); SetupEmbeddedResource(assemblyBuilder, this, conceptualSchemaElement, csdlResourceName); SetupEmbeddedResource(assemblyBuilder, this, storageSchemaElement, ssdlResourceName); SetupEmbeddedResource(assemblyBuilder, this, mappingElement, mslResourceName); } } private static void SetupEmbeddedResource(AssemblyBuilder assemblyBuilder, BuildProvider prov, XmlElement xmlElement, string resourceName) { using (Stream resStream = assemblyBuilder.CreateEmbeddedResource(prov, resourceName)) { EntityDesignerUtils.OutputXmlElementToStream(xmlElement, resStream); } } } } // 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
- BrushMappingModeValidation.cs
- GridViewHeaderRowPresenter.cs
- BitSet.cs
- TextClipboardData.cs
- SweepDirectionValidation.cs
- BitmapEffectOutputConnector.cs
- followingsibling.cs
- Rotation3DAnimationUsingKeyFrames.cs
- XmlNamedNodeMap.cs
- KnownIds.cs
- ColorAnimation.cs
- BufferedWebEventProvider.cs
- RuleInfoComparer.cs
- ExpressionBindings.cs
- Int32Collection.cs
- OutputCacheProfile.cs
- ImageAnimator.cs
- XmlCDATASection.cs
- XsdValidatingReader.cs
- TableRowsCollectionEditor.cs
- DmlSqlGenerator.cs
- ByteArrayHelperWithString.cs
- ToolStripScrollButton.cs
- VerificationAttribute.cs
- XmlSchemaExternal.cs
- DataViewSettingCollection.cs
- StreamAsIStream.cs
- PingReply.cs
- XmlChildEnumerator.cs
- PagesChangedEventArgs.cs
- ExternalException.cs
- SessionStateUtil.cs
- ImageMetadata.cs
- ApplicationCommands.cs
- DoubleStorage.cs
- SourceFilter.cs
- MenuAdapter.cs
- ExpandCollapseProviderWrapper.cs
- SqlDataSourceSelectingEventArgs.cs
- LinkAreaEditor.cs
- XslCompiledTransform.cs
- TableCellAutomationPeer.cs
- cookieexception.cs
- ControlAdapter.cs
- PropertyGroupDescription.cs
- X509Certificate2Collection.cs
- HandlerBase.cs
- IODescriptionAttribute.cs
- ContourSegment.cs
- DesignerSerializationOptionsAttribute.cs
- SeverityFilter.cs
- DataKeyCollection.cs
- QilStrConcat.cs
- SqlProviderUtilities.cs
- InitializingNewItemEventArgs.cs
- FreezableOperations.cs
- PassportIdentity.cs
- SqlCacheDependencyDatabase.cs
- TargetParameterCountException.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- RouteItem.cs
- TextModifierScope.cs
- _NestedMultipleAsyncResult.cs
- VisualProxy.cs
- CultureInfo.cs
- PersonalizationStateQuery.cs
- FixUp.cs
- PageAsyncTaskManager.cs
- XmlParserContext.cs
- DesignerVerbCollection.cs
- FamilyMapCollection.cs
- SizeAnimationUsingKeyFrames.cs
- DescendantBaseQuery.cs
- CacheHelper.cs
- IssuanceLicense.cs
- CookielessHelper.cs
- TryCatch.cs
- BitmapEffectCollection.cs
- MenuStrip.cs
- DebugInfoGenerator.cs
- ByteArrayHelperWithString.cs
- XPathBinder.cs
- UInt64.cs
- MimeMapping.cs
- EndpointIdentityExtension.cs
- TypeInitializationException.cs
- Latin1Encoding.cs
- XamlPointCollectionSerializer.cs
- ConnectionsZone.cs
- Facet.cs
- WSFederationHttpBinding.cs
- SQLBinaryStorage.cs
- XMLSchema.cs
- LookupNode.cs
- ObjectManager.cs
- webclient.cs
- BuildTopDownAttribute.cs
- ScrollBar.cs
- JsonWriter.cs
- ButtonBaseAutomationPeer.cs