Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / SimplePropertyEntry.cs / 1 / SimplePropertyEntry.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System.CodeDom; using System.Web.Compilation; using Debug=System.Web.Util.Debug; using System.Security.Permissions; ////// PropertyEntry for simple attributes /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class SimplePropertyEntry : PropertyEntry { private string _persistedValue; private bool _useSetAttribute; private object _value; internal SimplePropertyEntry() { } ////// // public string PersistedValue { get { return _persistedValue; } set { _persistedValue = value; } } ////// public bool UseSetAttribute { get { return _useSetAttribute; } set { _useSetAttribute = value; } } ////// public object Value { get { return _value; } set { _value = value; } } // Build the statement that assigns this property internal CodeStatement GetCodeStatement(BaseTemplateCodeDomTreeGenerator generator, CodeExpression ctrlRefExpr) { // If we don't have a type, use IAttributeAccessor.SetAttribute if (UseSetAttribute) { // e.g. ((IAttributeAccessor)__ctrl).SetAttribute("{{_name}}", "{{_value}}"); CodeMethodInvokeExpression methCallExpression = new CodeMethodInvokeExpression( new CodeCastExpression(typeof(IAttributeAccessor), ctrlRefExpr), "SetAttribute"); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Name)); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Value)); return new CodeExpressionStatement(methCallExpression); } CodeExpression leftExpr, rightExpr = null; if (PropertyInfo != null) { leftExpr = CodeDomUtility.BuildPropertyReferenceExpression(ctrlRefExpr, Name); } else { // In case of a field, there should only be one (unlike properties) Debug.Assert(Name.IndexOf('.') < 0, "_name.IndexOf('.') < 0"); leftExpr = new CodeFieldReferenceExpression(ctrlRefExpr, Name); } if (Type == typeof(string)) { rightExpr = generator.BuildStringPropertyExpression(this); } else { rightExpr = CodeDomUtility.GenerateExpressionForValue(PropertyInfo, Value, Type); } // Now that we have both side, add the assignment return new CodeAssignStatement(leftExpr, rightExpr); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System.CodeDom; using System.Web.Compilation; using Debug=System.Web.Util.Debug; using System.Security.Permissions; ////// PropertyEntry for simple attributes /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class SimplePropertyEntry : PropertyEntry { private string _persistedValue; private bool _useSetAttribute; private object _value; internal SimplePropertyEntry() { } ////// // public string PersistedValue { get { return _persistedValue; } set { _persistedValue = value; } } ////// public bool UseSetAttribute { get { return _useSetAttribute; } set { _useSetAttribute = value; } } ////// public object Value { get { return _value; } set { _value = value; } } // Build the statement that assigns this property internal CodeStatement GetCodeStatement(BaseTemplateCodeDomTreeGenerator generator, CodeExpression ctrlRefExpr) { // If we don't have a type, use IAttributeAccessor.SetAttribute if (UseSetAttribute) { // e.g. ((IAttributeAccessor)__ctrl).SetAttribute("{{_name}}", "{{_value}}"); CodeMethodInvokeExpression methCallExpression = new CodeMethodInvokeExpression( new CodeCastExpression(typeof(IAttributeAccessor), ctrlRefExpr), "SetAttribute"); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Name)); methCallExpression.Parameters.Add(new CodePrimitiveExpression(Value)); return new CodeExpressionStatement(methCallExpression); } CodeExpression leftExpr, rightExpr = null; if (PropertyInfo != null) { leftExpr = CodeDomUtility.BuildPropertyReferenceExpression(ctrlRefExpr, Name); } else { // In case of a field, there should only be one (unlike properties) Debug.Assert(Name.IndexOf('.') < 0, "_name.IndexOf('.') < 0"); leftExpr = new CodeFieldReferenceExpression(ctrlRefExpr, Name); } if (Type == typeof(string)) { rightExpr = generator.BuildStringPropertyExpression(this); } else { rightExpr = CodeDomUtility.GenerateExpressionForValue(PropertyInfo, Value, Type); } // Now that we have both side, add the assignment return new CodeAssignStatement(leftExpr, rightExpr); } } } // 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
- Parsers.cs
- ISFClipboardData.cs
- StrictAndMessageFilter.cs
- ReferenceEqualityComparer.cs
- DetailsViewModeEventArgs.cs
- SQLGuid.cs
- FileDialogCustomPlace.cs
- _SafeNetHandles.cs
- ImageIndexConverter.cs
- NamedElement.cs
- JulianCalendar.cs
- Graph.cs
- LabelLiteral.cs
- CodeGeneratorAttribute.cs
- ItemsControlAutomationPeer.cs
- SatelliteContractVersionAttribute.cs
- GZipStream.cs
- SchemaElement.cs
- XslTransform.cs
- KnownBoxes.cs
- Function.cs
- DataKey.cs
- VoiceChangeEventArgs.cs
- MetadataProperty.cs
- DataTableReaderListener.cs
- AppDomainCompilerProxy.cs
- ToolboxComponentsCreatingEventArgs.cs
- TagMapCollection.cs
- ContourSegment.cs
- ServiceBusyException.cs
- DbConnectionPoolCounters.cs
- AllMembershipCondition.cs
- WebPartCancelEventArgs.cs
- WebEventTraceProvider.cs
- TimeSpanSecondsConverter.cs
- PageClientProxyGenerator.cs
- ChannelDispatcher.cs
- CursorConverter.cs
- RelatedEnd.cs
- StringAnimationUsingKeyFrames.cs
- JoinQueryOperator.cs
- WindowsTitleBar.cs
- XmlSchemaImport.cs
- ValidatorCompatibilityHelper.cs
- TableLayoutSettings.cs
- SafeHandle.cs
- DataGridViewTextBoxEditingControl.cs
- PropertyPath.cs
- ExpandSegment.cs
- TraceContext.cs
- ApplicationDirectory.cs
- AsyncWaitHandle.cs
- TopClause.cs
- BroadcastEventHelper.cs
- BookmarkOptionsHelper.cs
- StorageInfo.cs
- MobileRedirect.cs
- TypeLibConverter.cs
- ComponentResourceManager.cs
- IdentityHolder.cs
- InstalledFontCollection.cs
- ViewEvent.cs
- ImageClickEventArgs.cs
- ObjectStorage.cs
- DataViewSetting.cs
- BitmapEffectInputData.cs
- PenLineCapValidation.cs
- ReflectionHelper.cs
- safelinkcollection.cs
- RemoteHelper.cs
- DocumentViewerHelper.cs
- AssertSection.cs
- DataSourceXmlClassAttribute.cs
- ListViewTableRow.cs
- InstallerTypeAttribute.cs
- ScriptResourceHandler.cs
- ServiceReference.cs
- LocalizabilityAttribute.cs
- EnlistmentTraceIdentifier.cs
- NetMsmqSecurity.cs
- RangeValidator.cs
- SQLCharsStorage.cs
- ColorAnimation.cs
- KeySpline.cs
- Timeline.cs
- PDBReader.cs
- Rotation3D.cs
- EntityStoreSchemaGenerator.cs
- BaseDataBoundControlDesigner.cs
- cookiecontainer.cs
- ExpressionHelper.cs
- SQLInt16Storage.cs
- ExceptionHelpers.cs
- ConstraintStruct.cs
- PropertyInformation.cs
- CounterCreationData.cs
- XmlSchemaRedefine.cs
- RightsManagementEncryptionTransform.cs
- ProxyWebPart.cs
- FileDialogCustomPlace.cs