Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / Compilation / XsdBuildProvider.cs / 1 / XsdBuildProvider.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Compilation { using System; using System.IO; using System.Data; using System.Data.Design; using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Reflection; using System.CodeDom; using System.CodeDom.Compiler; using System.Web.Hosting; using System.Web.Configuration; using System.Collections; using Util=System.Web.UI.Util; #if !FEATURE_PAL // FEATURE_PAL does not support System.Data.Design using TypedDataSetGenerator=System.Data.Design.TypedDataSetGenerator; #endif // !FEATURE_PAL [BuildProviderAppliesTo(BuildProviderAppliesTo.Code)] internal class XsdBuildProvider: BuildProvider { public override void GenerateCode(AssemblyBuilder assemblyBuilder) { #if !FEATURE_PAL // FEATURE_PAL does not support System.Data.Design // Get the namespace that we will use string ns = Util.GetNamespaceFromVirtualPath(VirtualPathObject); // We need to use XmlDocument to parse the xsd file is order to open it with the // correct encoding (VSWhidbey 566286) XmlDocument doc = new XmlDocument(); using (Stream stream = OpenStream()) { doc.Load(stream); } String content = doc.OuterXml; // Generate a CodeCompileUnit from the dataset CodeCompileUnit codeCompileUnit = new CodeCompileUnit(); CodeNamespace codeNamespace = new CodeNamespace(ns); codeCompileUnit.Namespaces.Add(codeNamespace); // Devdiv 18365 // Call a different Generate method if compiler version is v3.5 bool isVer35 = CompilationUtil.IsCompilerVersion35(assemblyBuilder.CodeDomProvider.GetType()); if (isVer35) { TypedDataSetGenerator.GenerateOption generateOptions = TypedDataSetGenerator.GenerateOption.None; generateOptions |= TypedDataSetGenerator.GenerateOption.HierarchicalUpdate; generateOptions |= TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets; Hashtable customDBProviders = null; TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider, customDBProviders, generateOptions); } else { TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider); } // Add all the assembly references needed by the generated code if (TypedDataSetGenerator.ReferencedAssemblies != null) { foreach (Assembly a in TypedDataSetGenerator.ReferencedAssemblies) { assemblyBuilder.AddAssemblyReference(a); } } // Add the CodeCompileUnit to the compilation assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit); #else // !FEATURE_PAL throw new NotImplementedException("System.Data.Design - ROTORTODO"); #endif // !FEATURE_PAL } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Compilation { using System; using System.IO; using System.Data; using System.Data.Design; using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Reflection; using System.CodeDom; using System.CodeDom.Compiler; using System.Web.Hosting; using System.Web.Configuration; using System.Collections; using Util=System.Web.UI.Util; #if !FEATURE_PAL // FEATURE_PAL does not support System.Data.Design using TypedDataSetGenerator=System.Data.Design.TypedDataSetGenerator; #endif // !FEATURE_PAL [BuildProviderAppliesTo(BuildProviderAppliesTo.Code)] internal class XsdBuildProvider: BuildProvider { public override void GenerateCode(AssemblyBuilder assemblyBuilder) { #if !FEATURE_PAL // FEATURE_PAL does not support System.Data.Design // Get the namespace that we will use string ns = Util.GetNamespaceFromVirtualPath(VirtualPathObject); // We need to use XmlDocument to parse the xsd file is order to open it with the // correct encoding (VSWhidbey 566286) XmlDocument doc = new XmlDocument(); using (Stream stream = OpenStream()) { doc.Load(stream); } String content = doc.OuterXml; // Generate a CodeCompileUnit from the dataset CodeCompileUnit codeCompileUnit = new CodeCompileUnit(); CodeNamespace codeNamespace = new CodeNamespace(ns); codeCompileUnit.Namespaces.Add(codeNamespace); // Devdiv 18365 // Call a different Generate method if compiler version is v3.5 bool isVer35 = CompilationUtil.IsCompilerVersion35(assemblyBuilder.CodeDomProvider.GetType()); if (isVer35) { TypedDataSetGenerator.GenerateOption generateOptions = TypedDataSetGenerator.GenerateOption.None; generateOptions |= TypedDataSetGenerator.GenerateOption.HierarchicalUpdate; generateOptions |= TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets; Hashtable customDBProviders = null; TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider, customDBProviders, generateOptions); } else { TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider); } // Add all the assembly references needed by the generated code if (TypedDataSetGenerator.ReferencedAssemblies != null) { foreach (Assembly a in TypedDataSetGenerator.ReferencedAssemblies) { assemblyBuilder.AddAssemblyReference(a); } } // Add the CodeCompileUnit to the compilation assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit); #else // !FEATURE_PAL throw new NotImplementedException("System.Data.Design - ROTORTODO"); #endif // !FEATURE_PAL } } } // 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
- LedgerEntry.cs
- WebPartsPersonalization.cs
- GeometryCollection.cs
- DataViewManagerListItemTypeDescriptor.cs
- ZipIOLocalFileDataDescriptor.cs
- XmlSchemaAny.cs
- BindValidator.cs
- CollectionCodeDomSerializer.cs
- ReadOnlyCollectionBase.cs
- XmlEntityReference.cs
- TypeAccessException.cs
- uribuilder.cs
- ModelUtilities.cs
- CustomTypeDescriptor.cs
- QuaternionKeyFrameCollection.cs
- NameValueSectionHandler.cs
- PreviewPrintController.cs
- GeometryModel3D.cs
- ISessionStateStore.cs
- XNodeValidator.cs
- ParentUndoUnit.cs
- AttributeData.cs
- CollectionChangeEventArgs.cs
- SHA1CryptoServiceProvider.cs
- LabelAutomationPeer.cs
- HtmlTableRow.cs
- SpellCheck.cs
- CheckBoxStandardAdapter.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- XmlCollation.cs
- AnchoredBlock.cs
- Light.cs
- DiscoveryClientDuplexChannel.cs
- AsyncPostBackTrigger.cs
- MatrixAnimationUsingPath.cs
- LineMetrics.cs
- TemplateControlCodeDomTreeGenerator.cs
- ConvertEvent.cs
- TriggerAction.cs
- ParameterElement.cs
- HatchBrush.cs
- MatrixTransform.cs
- ScriptResourceAttribute.cs
- HostElement.cs
- DbUpdateCommandTree.cs
- SqlFunctions.cs
- QuadraticBezierSegment.cs
- BindingMAnagerBase.cs
- ApplicationManager.cs
- IndependentlyAnimatedPropertyMetadata.cs
- QilList.cs
- ItemAutomationPeer.cs
- _ListenerAsyncResult.cs
- AttachedPropertyBrowsableAttribute.cs
- EntityTypeEmitter.cs
- Cursors.cs
- ObjectDataSourceDisposingEventArgs.cs
- UDPClient.cs
- CurrencyManager.cs
- ReceiveSecurityHeader.cs
- TogglePattern.cs
- MethodCallTranslator.cs
- TreeNodeMouseHoverEvent.cs
- SliderAutomationPeer.cs
- XmlSchemaDocumentation.cs
- DocumentPage.cs
- Line.cs
- ZipPackagePart.cs
- ReachSerializableProperties.cs
- CacheChildrenQuery.cs
- ControlDesigner.cs
- PropertyMapper.cs
- MappingSource.cs
- MobileControlDesigner.cs
- ItemChangedEventArgs.cs
- ProcessModelSection.cs
- DictionaryKeyPropertyAttribute.cs
- AsyncContentLoadedEventArgs.cs
- BorderGapMaskConverter.cs
- ActivationServices.cs
- KeyConstraint.cs
- NTAccount.cs
- TypeRestriction.cs
- elementinformation.cs
- GridView.cs
- Wizard.cs
- CodeDefaultValueExpression.cs
- PageCatalogPart.cs
- HttpModuleAction.cs
- StringWriter.cs
- ControlTemplate.cs
- MetadataFile.cs
- DataObjectSettingDataEventArgs.cs
- AncestorChangedEventArgs.cs
- IPGlobalProperties.cs
- DataGridHelper.cs
- FormsAuthenticationModule.cs
- DataTableMappingCollection.cs
- DataBindingCollectionConverter.cs
- StrokeDescriptor.cs