Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TrackingStringDictionary.cs
- hebrewshape.cs
- CompositionCommandSet.cs
- PerformanceCounter.cs
- ClaimTypeElement.cs
- GridView.cs
- Rotation3D.cs
- StoreConnection.cs
- TagPrefixCollection.cs
- UnsafeNativeMethods.cs
- QueueProcessor.cs
- StorageBasedPackageProperties.cs
- DecoratedNameAttribute.cs
- PositiveTimeSpanValidatorAttribute.cs
- _SafeNetHandles.cs
- Privilege.cs
- ControlPropertyNameConverter.cs
- SubpageParagraph.cs
- Compiler.cs
- MeasurementDCInfo.cs
- SecureStringHasher.cs
- DataSetUtil.cs
- SettingsPropertyIsReadOnlyException.cs
- Types.cs
- _Rfc2616CacheValidators.cs
- NCryptNative.cs
- PointLight.cs
- LookupNode.cs
- ConfigPathUtility.cs
- WindowsGraphics.cs
- OutOfProcStateClientManager.cs
- FileUpload.cs
- LinqDataSourceContextEventArgs.cs
- RootBrowserWindowAutomationPeer.cs
- AnnotationResource.cs
- AnimatedTypeHelpers.cs
- ECDsaCng.cs
- ActivationArguments.cs
- _NegotiateClient.cs
- CurrentChangingEventManager.cs
- CompositionTarget.cs
- TdsParserHelperClasses.cs
- DataGridViewRowPrePaintEventArgs.cs
- LineServices.cs
- DataGridHelper.cs
- TypeConverters.cs
- DoubleIndependentAnimationStorage.cs
- OletxEnlistment.cs
- CodeIterationStatement.cs
- XPathParser.cs
- Int64AnimationBase.cs
- AnnotationResourceChangedEventArgs.cs
- Splitter.cs
- MultiAsyncResult.cs
- PeerChannelFactory.cs
- GenericNameHandler.cs
- WindowsListBox.cs
- DirectoryInfo.cs
- Win32Native.cs
- Guid.cs
- XmlSchemaImport.cs
- SqlUDTStorage.cs
- SocketAddress.cs
- RuntimeEnvironment.cs
- DelegateSerializationHolder.cs
- DataGridViewColumn.cs
- SafePEFileHandle.cs
- ServiceContractListItemList.cs
- WindowsSolidBrush.cs
- EdmSchemaAttribute.cs
- HttpCapabilitiesBase.cs
- util.cs
- RightsManagementEncryptedStream.cs
- ObjectQueryProvider.cs
- WindowsListViewScroll.cs
- SyndicationDeserializer.cs
- As.cs
- ListContractAdapter.cs
- LassoHelper.cs
- CaseStatementSlot.cs
- MaterialCollection.cs
- SafeMILHandle.cs
- TypeElement.cs
- SHA512Managed.cs
- ImmutableObjectAttribute.cs
- ProgressiveCrcCalculatingStream.cs
- TouchEventArgs.cs
- VectorCollectionConverter.cs
- IndependentlyAnimatedPropertyMetadata.cs
- AuthenticationService.cs
- XPathException.cs
- CharConverter.cs
- ChangeBlockUndoRecord.cs
- ServerTooBusyException.cs
- RepeatBehaviorConverter.cs
- VariableDesigner.xaml.cs
- _ShellExpression.cs
- Journaling.cs
- SqlVersion.cs
- EdmToObjectNamespaceMap.cs