Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Compilation / ExpressionBuilder.cs / 1 / ExpressionBuilder.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Compilation { using System; using System.Security.Permissions; using System.CodeDom; using System.Collections; using System.Collections.Specialized; using System.ComponentModel.Design; using System.Web.Configuration; using System.Reflection; using System.Web; using System.Web.Hosting; #if !FEATURE_PAL using System.Web.UI.Design; #endif // !FEATURE_PAL using System.Web.UI; using System.Web.Util; [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public abstract class ExpressionBuilder { private static ExpressionBuilder dataBindingExpressionBuilder; internal virtual void BuildExpression(BoundPropertyEntry bpe, ControlBuilder controlBuilder, CodeExpression controlReference, CodeStatementCollection methodStatements, CodeStatementCollection statements, CodeLinePragma linePragma, ref bool hasTempObject) { CodeExpression codeExpression = GetCodeExpression(bpe, bpe.ParsedExpressionData, new ExpressionBuilderContext(controlBuilder.VirtualPath)); CodeDomUtility.CreatePropertySetStatements(methodStatements, statements, controlReference, bpe.Name, bpe.Type, codeExpression, linePragma); } internal static ExpressionBuilder GetExpressionBuilder(string expressionPrefix, VirtualPath virtualPath) { return GetExpressionBuilder(expressionPrefix, virtualPath, null); } internal static ExpressionBuilder GetExpressionBuilder(string expressionPrefix, VirtualPath virtualPath, IDesignerHost host) { // If there is no expressionPrefix, it's a v1 style databinding expression if (expressionPrefix.Length == 0) { if (dataBindingExpressionBuilder == null) { dataBindingExpressionBuilder = new DataBindingExpressionBuilder(); } return dataBindingExpressionBuilder; } CompilationSection config = null; // If we are in the designer, we need to access IWebApplication config instead #if !FEATURE_PAL // FEATURE_PAL does not support designer-based features if (host != null) { IWebApplication webapp = (IWebApplication)host.GetService(typeof(IWebApplication)); if (webapp != null) { config = webapp.OpenWebConfiguration(true).GetSection("system.web/compilation") as CompilationSection; } } #endif // !FEATURE_PAL // If we failed to get config from the designer, fall back on runtime config always if (config == null) { config = RuntimeConfig.GetConfig(virtualPath).Compilation; } System.Web.Configuration.ExpressionBuilder builder = config.ExpressionBuilders[expressionPrefix]; if (builder == null) { throw new HttpParseException(SR.GetString(SR.InvalidExpressionPrefix, expressionPrefix)); } Type expressionBuilderType = null; if (host != null) { // If we are in the designer, we have to use the type resolution service ITypeResolutionService ts = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (ts != null) { expressionBuilderType = ts.GetType(builder.Type); } } if (expressionBuilderType == null) { expressionBuilderType = builder.TypeInternal; } Debug.Assert(expressionBuilderType != null, "expressionBuilderType should not be null"); if (!typeof(ExpressionBuilder).IsAssignableFrom(expressionBuilderType)) { throw new HttpParseException(SR.GetString(SR.ExpressionBuilder_InvalidType, expressionBuilderType.FullName)); } ExpressionBuilder expressionBuilder = (ExpressionBuilder)HttpRuntime.FastCreatePublicInstance(expressionBuilderType); return expressionBuilder; } // // Public API // public virtual bool SupportsEvaluate { get { return false; } } public virtual object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context) { return null; } public abstract CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context); public virtual object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context) { return null; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AssertFilter.cs
- OdbcConnectionStringbuilder.cs
- TdsParserHelperClasses.cs
- WebHttpDispatchOperationSelectorData.cs
- SqlDataSourceStatusEventArgs.cs
- MimeTypeMapper.cs
- ArcSegment.cs
- ListItemCollection.cs
- StatusBarItem.cs
- WebPartConnectVerb.cs
- UIInitializationException.cs
- XmlSchemaSet.cs
- QueryableFilterRepeater.cs
- ClrProviderManifest.cs
- DBCommandBuilder.cs
- EventArgs.cs
- _SslSessionsCache.cs
- OptimizerPatterns.cs
- UpdateCompiler.cs
- XmlHierarchyData.cs
- QilIterator.cs
- SystemMulticastIPAddressInformation.cs
- SqlMethodTransformer.cs
- CreateRefExpr.cs
- Message.cs
- NodeFunctions.cs
- XmlQueryStaticData.cs
- ButtonBase.cs
- RtfControlWordInfo.cs
- RouteParameter.cs
- ExpressionPrinter.cs
- AssociationType.cs
- CalloutQueueItem.cs
- SrgsRulesCollection.cs
- DecimalKeyFrameCollection.cs
- XmlWrappingReader.cs
- hresults.cs
- VariantWrapper.cs
- RuntimeHelpers.cs
- DBConnection.cs
- ClientOptions.cs
- HtmlButton.cs
- EdmSchemaError.cs
- DataPagerFieldCommandEventArgs.cs
- ISAPIRuntime.cs
- UnknownWrapper.cs
- AmbientEnvironment.cs
- DesignSurfaceCollection.cs
- SQLBytesStorage.cs
- EmptyControlCollection.cs
- SiteMapDataSourceDesigner.cs
- SpeechSynthesizer.cs
- DataControlCommands.cs
- XPathDocument.cs
- TrackingDataItemValue.cs
- codemethodreferenceexpression.cs
- DataGridViewRowsAddedEventArgs.cs
- DbConnectionPoolGroupProviderInfo.cs
- SortedDictionary.cs
- PagesSection.cs
- Rfc2898DeriveBytes.cs
- StatusBarPanelClickEvent.cs
- RedistVersionInfo.cs
- DataControlCommands.cs
- MenuRendererStandards.cs
- CodeDirectiveCollection.cs
- XamlTreeBuilderBamlRecordWriter.cs
- Calendar.cs
- DataGridPagerStyle.cs
- DataGridViewRowsAddedEventArgs.cs
- ItemCheckEvent.cs
- SortedList.cs
- ListSourceHelper.cs
- ContainerAction.cs
- HtmlImageAdapter.cs
- CodeDomConfigurationHandler.cs
- TextModifier.cs
- HttpStaticObjectsCollectionWrapper.cs
- RNGCryptoServiceProvider.cs
- ResourceReferenceKeyNotFoundException.cs
- DbConnectionStringBuilder.cs
- NativeMethods.cs
- BrowserTree.cs
- Decimal.cs
- RoutedEventValueSerializer.cs
- Repeater.cs
- ProjectionPath.cs
- CodeSnippetExpression.cs
- CssStyleCollection.cs
- TraceHelpers.cs
- ICspAsymmetricAlgorithm.cs
- WebPartConnectionsConfigureVerb.cs
- ByteAnimation.cs
- AnimationTimeline.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- CngAlgorithm.cs
- MemoryMappedViewAccessor.cs
- DiscoveryDocumentSerializer.cs
- BufferBuilder.cs
- _ListenerResponseStream.cs