Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Compilation / SimpleHandlerBuildProvider.cs / 2 / 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;
#if ORCAS
using System.Web.UI.Imaging;
#endif
[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);
}
}
//
// 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);
}
}
#if ORCAS
internal class ImageGeneratorBuildProvider: SimpleHandlerBuildProvider {
private ImageGeneratorParser _parser;
protected override SimpleWebHandlerParser CreateParser() {
_parser = new ImageGeneratorParser(VirtualPath);
return _parser;
}
internal override BuildResultCompiledType CreateBuildResult(Type t) {
return new ImageGeneratorBuildResultCompiledType(t);
}
internal override BuildResult CreateBuildResult(CompilerResults results) {
ImageGeneratorBuildResultCompiledType result = (ImageGeneratorBuildResultCompiledType)base.CreateBuildResult(results);
result.OutputCacheInfo = _parser.OutputCacheDirective;
result.CustomErrorImageUrl = _parser.CustomErrorImageUrl;
return result;
}
}
#endif
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.
//------------------------------------------------------------------------------
//
// 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;
#if ORCAS
using System.Web.UI.Imaging;
#endif
[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);
}
}
//
// 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);
}
}
#if ORCAS
internal class ImageGeneratorBuildProvider: SimpleHandlerBuildProvider {
private ImageGeneratorParser _parser;
protected override SimpleWebHandlerParser CreateParser() {
_parser = new ImageGeneratorParser(VirtualPath);
return _parser;
}
internal override BuildResultCompiledType CreateBuildResult(Type t) {
return new ImageGeneratorBuildResultCompiledType(t);
}
internal override BuildResult CreateBuildResult(CompilerResults results) {
ImageGeneratorBuildResultCompiledType result = (ImageGeneratorBuildResultCompiledType)base.CreateBuildResult(results);
result.OutputCacheInfo = _parser.OutputCacheDirective;
result.CustomErrorImageUrl = _parser.CustomErrorImageUrl;
return result;
}
}
#endif
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGrid.cs
- HandlerMappingMemo.cs
- PointValueSerializer.cs
- SHA1Managed.cs
- GraphicsContainer.cs
- TextFormatterImp.cs
- RightsManagementLicense.cs
- CssClassPropertyAttribute.cs
- parserscommon.cs
- Shape.cs
- XhtmlBasicCalendarAdapter.cs
- HtmlDocument.cs
- ApplicationContext.cs
- DeferrableContentConverter.cs
- ReflectEventDescriptor.cs
- FixedTextPointer.cs
- TiffBitmapEncoder.cs
- SetterBaseCollection.cs
- MetaDataInfo.cs
- LOSFormatter.cs
- FigureParagraph.cs
- LocalIdKeyIdentifierClause.cs
- PersistenceException.cs
- SmtpNtlmAuthenticationModule.cs
- RowUpdatedEventArgs.cs
- ShimAsPublicXamlType.cs
- HttpListenerRequest.cs
- ModuleConfigurationInfo.cs
- WebPartTransformerAttribute.cs
- OdbcEnvironment.cs
- Point.cs
- OptionalColumn.cs
- ConnectionInterfaceCollection.cs
- DuplicateWaitObjectException.cs
- Registry.cs
- KeyInterop.cs
- TextViewSelectionProcessor.cs
- Deflater.cs
- EntityModelBuildProvider.cs
- ClientTargetCollection.cs
- TypeReference.cs
- RelationshipType.cs
- Ref.cs
- sortedlist.cs
- DataGridItem.cs
- Helpers.cs
- HttpListenerPrefixCollection.cs
- ByteAnimationUsingKeyFrames.cs
- WebPartChrome.cs
- SignedInfo.cs
- WindowsListViewGroupHelper.cs
- XmlSchemaSimpleTypeUnion.cs
- MessagingDescriptionAttribute.cs
- HttpContextWrapper.cs
- PartialArray.cs
- ClientScriptManager.cs
- RectangleGeometry.cs
- Color.cs
- Event.cs
- Material.cs
- WindowVisualStateTracker.cs
- Calendar.cs
- StateChangeEvent.cs
- SourceElementsCollection.cs
- ComAdminInterfaces.cs
- SourceFileBuildProvider.cs
- Accessible.cs
- FixedSOMFixedBlock.cs
- OrderedDictionaryStateHelper.cs
- BuildProvidersCompiler.cs
- MemberDescriptor.cs
- BitmapData.cs
- XmlSchemaObjectTable.cs
- QilVisitor.cs
- ScriptingProfileServiceSection.cs
- ObjectHandle.cs
- Propagator.cs
- RelatedPropertyManager.cs
- DynamicDataExtensions.cs
- SupportingTokenBindingElement.cs
- coordinator.cs
- SqlMethods.cs
- DataSourceHelper.cs
- HwndSubclass.cs
- SourceLocationProvider.cs
- ElementUtil.cs
- DateTimeConverter2.cs
- UndoManager.cs
- DbMetaDataColumnNames.cs
- UriSection.cs
- TraceProvider.cs
- SimpleLine.cs
- TextOutput.cs
- TypeConverter.cs
- Int32Converter.cs
- WebPartEditorOkVerb.cs
- XPathExpr.cs
- SQLInt64.cs
- GridViewColumnCollection.cs
- EventMappingSettingsCollection.cs