Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewRowsAddedEventArgs.cs
- RawAppCommandInputReport.cs
- QueryGenerator.cs
- Mapping.cs
- MultiView.cs
- TrackPoint.cs
- RawStylusInputCustomData.cs
- SharedPersonalizationStateInfo.cs
- XmlWrappingWriter.cs
- AttachInfo.cs
- TemporaryBitmapFile.cs
- PointHitTestResult.cs
- SEHException.cs
- EntityDataSourceEntitySetNameItem.cs
- filewebrequest.cs
- DataSourceComponent.cs
- SizeAnimationClockResource.cs
- TextViewElement.cs
- CodeAssignStatement.cs
- DateBoldEvent.cs
- AtomContentProperty.cs
- SoapTypeAttribute.cs
- XmlCodeExporter.cs
- EngineSite.cs
- RequestCachePolicy.cs
- XmlStringTable.cs
- WebPartConnectionsEventArgs.cs
- AttributeUsageAttribute.cs
- RtfFormatStack.cs
- MemberCollection.cs
- ResourcesBuildProvider.cs
- Margins.cs
- BitmapSource.cs
- MethodAccessException.cs
- WebBrowserUriTypeConverter.cs
- WebHttpBindingElement.cs
- BrowserCapabilitiesFactory.cs
- MostlySingletonList.cs
- Translator.cs
- RelationshipSet.cs
- SafeHandles.cs
- SplineKeyFrames.cs
- Compiler.cs
- LineSegment.cs
- RemoteWebConfigurationHostServer.cs
- KeyGestureConverter.cs
- IisTraceListener.cs
- DateTimeFormat.cs
- SessionEndingEventArgs.cs
- TimelineGroup.cs
- JsonWriter.cs
- FileEnumerator.cs
- SubordinateTransaction.cs
- CoreSwitches.cs
- TextAnchor.cs
- odbcmetadatafactory.cs
- ProviderConnectionPoint.cs
- SendSecurityHeader.cs
- TableParagraph.cs
- UIElement.cs
- LocalizableResourceBuilder.cs
- DataGridViewCell.cs
- ClientSession.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- DesignerGenericWebPart.cs
- ObjectSet.cs
- ValidationRuleCollection.cs
- DataGridViewDataErrorEventArgs.cs
- AuthenticatedStream.cs
- AstNode.cs
- SqlDataSourceSelectingEventArgs.cs
- ListControlConvertEventArgs.cs
- HwndSourceParameters.cs
- ToolStripSystemRenderer.cs
- ArithmeticException.cs
- DockPanel.cs
- InternalConfigSettingsFactory.cs
- SiteMapNodeItem.cs
- followingsibling.cs
- DoubleMinMaxAggregationOperator.cs
- WebEvents.cs
- PasswordBox.cs
- AutomationPatternInfo.cs
- SubMenuStyleCollection.cs
- SmiConnection.cs
- ClientTarget.cs
- ZipIOCentralDirectoryBlock.cs
- CodeDOMProvider.cs
- SrgsElementList.cs
- DoubleIndependentAnimationStorage.cs
- HttpAsyncResult.cs
- SoapExtensionImporter.cs
- SystemColors.cs
- SqlComparer.cs
- CodeSubDirectory.cs
- IDictionary.cs
- GradientStopCollection.cs
- ToolStripSplitStackLayout.cs
- EventItfInfo.cs
- XmlAttributeCollection.cs