Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Compilation / SimpleHandlerBuildProvider.cs / 1305376 / SimpleHandlerBuildProvider.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Compilation { using System; using System.IO; using System.Collections; using System.Reflection; using System.CodeDom; using System.CodeDom.Compiler; using System.Web.Configuration; using System.Web.Util; using System.Web.UI; [BuildProviderAppliesTo(BuildProviderAppliesTo.Web)] internal abstract class SimpleHandlerBuildProvider: InternalBuildProvider { private SimpleWebHandlerParser _parser; internal override IAssemblyDependencyParser AssemblyDependencyParser { get { return _parser; } } protected abstract SimpleWebHandlerParser CreateParser(); public override CompilerType CodeCompilerType { get { Debug.Assert(_parser == null); _parser = CreateParser(); _parser.SetBuildProvider(this); _parser.IgnoreParseErrors = IgnoreParseErrors; _parser.Parse(ReferencedAssemblies); return _parser.CompilerType; } } protected internal override CodeCompileUnit GetCodeCompileUnit(out IDictionary linePragmasTable) { Debug.Assert(_parser != null); CodeCompileUnit ccu = _parser.GetCodeModel(); linePragmasTable = _parser.GetLinePragmasTable(); return ccu; } public override void GenerateCode(AssemblyBuilder assemblyBuilder) { CodeCompileUnit codeCompileUnit = _parser.GetCodeModel(); // Bail if we have nothing we need to compile if (codeCompileUnit == null) return; assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit); // Add all the assemblies if (_parser.AssemblyDependencies != null) { foreach (Assembly assembly in _parser.AssemblyDependencies) { assemblyBuilder.AddAssemblyReference(assembly, codeCompileUnit); } } // NOTE: we can't actually generate the fast factory because it would give // a really bad error if the user specifies a classname which doesn't match // the actual class they define. A bit unfortunate, but not that big a deal... // tell the host to generate a fast factory for this type (if any) //string generatedTypeName = _parser.GeneratedTypeName; //if (generatedTypeName != null) // assemblyBuilder.GenerateTypeFactory(generatedTypeName); } public override Type GetGeneratedType(CompilerResults results) { Type t; if (_parser.HasInlineCode) { // This is the case where the asmx/ashx has code in the file, and it // has been compiled. Debug.Assert(results != null); t = _parser.GetTypeToCache(results.CompiledAssembly); } else { // This is the case where the asmx/ashx has no code and is simply // pointing to an existing assembly. Set the UsesExistingAssembly // flag accordingly. t = _parser.GetTypeToCache(null); } return t; } public override ICollection VirtualPathDependencies { get { return _parser.SourceDependencies; } } internal CompilerType GetDefaultCompilerTypeForLanguageInternal(string language) { return GetDefaultCompilerTypeForLanguage(language); } internal CompilerType GetDefaultCompilerTypeInternal() { return GetDefaultCompilerType(); } internal TextReader OpenReaderInternal() { return OpenReader(); } internal override ICollection GetGeneratedTypeNames() { // Note that _parser.TypeName does not necessarily point to the type defined in the handler file, // it could be any type that can be referenced at runtime, App_Code for example. return new SingleObjectCollection(_parser.TypeName); } } internal class WebServiceBuildProvider: SimpleHandlerBuildProvider { protected override SimpleWebHandlerParser CreateParser() { return new WebServiceParser(VirtualPath); } } internal class WebHandlerBuildProvider: SimpleHandlerBuildProvider { protected override SimpleWebHandlerParser CreateParser() { return new WebHandlerParser(VirtualPath); } } } // 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.Collections; using System.Reflection; using System.CodeDom; using System.CodeDom.Compiler; using System.Web.Configuration; using System.Web.Util; using System.Web.UI; [BuildProviderAppliesTo(BuildProviderAppliesTo.Web)] internal abstract class SimpleHandlerBuildProvider: InternalBuildProvider { private SimpleWebHandlerParser _parser; internal override IAssemblyDependencyParser AssemblyDependencyParser { get { return _parser; } } protected abstract SimpleWebHandlerParser CreateParser(); public override CompilerType CodeCompilerType { get { Debug.Assert(_parser == null); _parser = CreateParser(); _parser.SetBuildProvider(this); _parser.IgnoreParseErrors = IgnoreParseErrors; _parser.Parse(ReferencedAssemblies); return _parser.CompilerType; } } protected internal override CodeCompileUnit GetCodeCompileUnit(out IDictionary linePragmasTable) { Debug.Assert(_parser != null); CodeCompileUnit ccu = _parser.GetCodeModel(); linePragmasTable = _parser.GetLinePragmasTable(); return ccu; } public override void GenerateCode(AssemblyBuilder assemblyBuilder) { CodeCompileUnit codeCompileUnit = _parser.GetCodeModel(); // Bail if we have nothing we need to compile if (codeCompileUnit == null) return; assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit); // Add all the assemblies if (_parser.AssemblyDependencies != null) { foreach (Assembly assembly in _parser.AssemblyDependencies) { assemblyBuilder.AddAssemblyReference(assembly, codeCompileUnit); } } // NOTE: we can't actually generate the fast factory because it would give // a really bad error if the user specifies a classname which doesn't match // the actual class they define. A bit unfortunate, but not that big a deal... // tell the host to generate a fast factory for this type (if any) //string generatedTypeName = _parser.GeneratedTypeName; //if (generatedTypeName != null) // assemblyBuilder.GenerateTypeFactory(generatedTypeName); } public override Type GetGeneratedType(CompilerResults results) { Type t; if (_parser.HasInlineCode) { // This is the case where the asmx/ashx has code in the file, and it // has been compiled. Debug.Assert(results != null); t = _parser.GetTypeToCache(results.CompiledAssembly); } else { // This is the case where the asmx/ashx has no code and is simply // pointing to an existing assembly. Set the UsesExistingAssembly // flag accordingly. t = _parser.GetTypeToCache(null); } return t; } public override ICollection VirtualPathDependencies { get { return _parser.SourceDependencies; } } internal CompilerType GetDefaultCompilerTypeForLanguageInternal(string language) { return GetDefaultCompilerTypeForLanguage(language); } internal CompilerType GetDefaultCompilerTypeInternal() { return GetDefaultCompilerType(); } internal TextReader OpenReaderInternal() { return OpenReader(); } internal override ICollection GetGeneratedTypeNames() { // Note that _parser.TypeName does not necessarily point to the type defined in the handler file, // it could be any type that can be referenced at runtime, App_Code for example. return new SingleObjectCollection(_parser.TypeName); } } internal class WebServiceBuildProvider: SimpleHandlerBuildProvider { protected override SimpleWebHandlerParser CreateParser() { return new WebServiceParser(VirtualPath); } } internal class WebHandlerBuildProvider: SimpleHandlerBuildProvider { protected override SimpleWebHandlerParser CreateParser() { return new WebHandlerParser(VirtualPath); } } } // 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
- CellConstant.cs
- SEHException.cs
- ConnectionPointGlyph.cs
- AsyncResult.cs
- Normalization.cs
- TimelineCollection.cs
- SQLInt32Storage.cs
- BufferedGraphicsManager.cs
- RecognizerBase.cs
- StyleXamlParser.cs
- Helpers.cs
- WebPartCatalogCloseVerb.cs
- MLangCodePageEncoding.cs
- BitmapEffectInput.cs
- WorkflowMessageEventHandler.cs
- ParameterToken.cs
- StrokeNodeOperations2.cs
- XamlGridLengthSerializer.cs
- WinEventHandler.cs
- InternalControlCollection.cs
- storepermissionattribute.cs
- IdentityModelStringsVersion1.cs
- Translator.cs
- EntityDataSourceDesignerHelper.cs
- Cursors.cs
- Context.cs
- DataGridViewRowStateChangedEventArgs.cs
- FixedDocument.cs
- DataAdapter.cs
- DPAPIProtectedConfigurationProvider.cs
- VectorAnimationBase.cs
- VideoDrawing.cs
- OleDbReferenceCollection.cs
- SqlProfileProvider.cs
- CellParaClient.cs
- RealizationContext.cs
- x509store.cs
- StrongName.cs
- ThreadInterruptedException.cs
- UnsafeNativeMethodsTablet.cs
- DataGridViewBand.cs
- ListCollectionView.cs
- MobileControlBuilder.cs
- Win32KeyboardDevice.cs
- MetadataUtil.cs
- EmptyQuery.cs
- RequestStatusBarUpdateEventArgs.cs
- SettingsBase.cs
- SamlAction.cs
- ToolStripItemEventArgs.cs
- SplineKeyFrames.cs
- DocumentCollection.cs
- SoapElementAttribute.cs
- DefaultValueConverter.cs
- DbReferenceCollection.cs
- SqlBooleanizer.cs
- Compilation.cs
- ScrollProperties.cs
- ListViewHitTestInfo.cs
- Certificate.cs
- DllNotFoundException.cs
- Utilities.cs
- HiddenFieldPageStatePersister.cs
- ListCollectionView.cs
- OperationPickerDialog.designer.cs
- OAVariantLib.cs
- QuaternionRotation3D.cs
- WebServiceClientProxyGenerator.cs
- SchemaLookupTable.cs
- DecoderExceptionFallback.cs
- ScriptControlDescriptor.cs
- InvokeBase.cs
- SapiRecoInterop.cs
- WebHttpDispatchOperationSelectorData.cs
- SmtpCommands.cs
- IEnumerable.cs
- TableItemPattern.cs
- CatalogZoneBase.cs
- LineUtil.cs
- FixUpCollection.cs
- ProfilePropertySettingsCollection.cs
- EditBehavior.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- CompiledXpathExpr.cs
- ToolboxComponentsCreatedEventArgs.cs
- BaseComponentEditor.cs
- GridViewCellAutomationPeer.cs
- PointIndependentAnimationStorage.cs
- StylusLogic.cs
- ErrorsHelper.cs
- DataGridCommandEventArgs.cs
- DefaultAsyncDataDispatcher.cs
- MessageBox.cs
- BitmapDownload.cs
- CroppedBitmap.cs
- ResourceDictionary.cs
- DataGridHeaderBorder.cs
- ProcessModelInfo.cs
- StrongNameUtility.cs
- OleDbFactory.cs