Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / ValueTypeFieldReference.cs / 1305376 / ValueTypeFieldReference.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Expressions { using System.ComponentModel; using System.Reflection; using System.Runtime; using System.Runtime.Serialization; public sealed class ValueTypeFieldReference: CodeActivity > { FieldInfo fieldInfo; public ValueTypeFieldReference() : base() { } [DefaultValue(null)] public string FieldName { get; set; } [DefaultValue(null)] public InOutArgument OperandLocation { get; set; } protected override void CacheMetadata(CodeActivityMetadata metadata) { bool isRequired = false; if (!typeof(TOperand).IsValueType) { metadata.AddValidationError(SR.TypeMustbeValueType(typeof(TOperand).Name)); } if (typeof(TOperand).IsEnum) { metadata.AddValidationError(SR.TargetTypeCannotBeEnum(this.GetType().Name, this.DisplayName)); } if (string.IsNullOrEmpty(this.FieldName)) { metadata.AddValidationError(SR.ActivityPropertyMustBeSet("FieldName", this.DisplayName)); } else { this.fieldInfo = typeof(TOperand).GetField(this.FieldName); isRequired = this.fieldInfo != null && !this.fieldInfo.IsStatic; if (this.fieldInfo == null) { metadata.AddValidationError(SR.MemberNotFound(this.FieldName, typeof(TOperand).Name)); } else if (this.fieldInfo.IsInitOnly) { metadata.AddValidationError(SR.MemberIsReadOnly(this.FieldName, typeof(TOperand).Name)); } } MemberExpressionHelper.AddOperandLocationArgument (metadata, this.OperandLocation, isRequired); } protected override Location Execute(CodeActivityContext context) { Location operandLocationValue = this.OperandLocation.GetLocation(context); Fx.Assert(operandLocationValue != null, "OperandLocation must not be null"); Fx.Assert(this.fieldInfo != null, "fieldInfo must not be null."); return new FieldLocation(this.fieldInfo, operandLocationValue); } [DataContract] class FieldLocation : Location { [DataMember] FieldInfo fieldInfo; [DataMember(EmitDefaultValue = false)] Location ownerLocation; public FieldLocation(FieldInfo fieldInfo, Location ownerLocation) : base() { this.fieldInfo = fieldInfo; this.ownerLocation = ownerLocation; } public override TResult Value { get { return (TResult)this.fieldInfo.GetValue(this.ownerLocation.Value); } set { object copy = this.ownerLocation.Value; this.fieldInfo.SetValue(copy, value); this.ownerLocation.Value = (TOperand)copy; } } } } } // 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
- WebPartZone.cs
- PersonalizationStateInfoCollection.cs
- _Events.cs
- WinFormsComponentEditor.cs
- XpsS0ValidatingLoader.cs
- ProxyWebPart.cs
- UInt64Storage.cs
- _LazyAsyncResult.cs
- GridLengthConverter.cs
- CodeComment.cs
- _ConnectOverlappedAsyncResult.cs
- HwndStylusInputProvider.cs
- PointLight.cs
- WebAdminConfigurationHelper.cs
- InteropDesigner.xaml.cs
- _FtpDataStream.cs
- OrderedDictionary.cs
- WindowsPrincipal.cs
- CultureSpecificStringDictionary.cs
- ImpersonationContext.cs
- RubberbandSelector.cs
- SqlInfoMessageEvent.cs
- ObjectNotFoundException.cs
- UpdateEventArgs.cs
- HMACRIPEMD160.cs
- Base64Encoder.cs
- Config.cs
- SystemInfo.cs
- DesignerSerializationManager.cs
- TagMapCollection.cs
- SqlClientWrapperSmiStream.cs
- DataRowChangeEvent.cs
- TransformationRules.cs
- Fx.cs
- PanelDesigner.cs
- ScopeElementCollection.cs
- ColorPalette.cs
- CommandID.cs
- ImageCreator.cs
- RepeatEnumerable.cs
- HandlerWithFactory.cs
- NativeCppClassAttribute.cs
- DefaultBinder.cs
- OrderingQueryOperator.cs
- ValidatingReaderNodeData.cs
- DrawingCollection.cs
- StatusBar.cs
- PrincipalPermissionMode.cs
- NameScopePropertyAttribute.cs
- ParserOptions.cs
- GeneratedContractType.cs
- AsyncPostBackTrigger.cs
- CollectionConverter.cs
- BitmapPalettes.cs
- ResXResourceSet.cs
- UICuesEvent.cs
- DeferredElementTreeState.cs
- FamilyTypefaceCollection.cs
- FormatConvertedBitmap.cs
- SettingsProviderCollection.cs
- Variant.cs
- WebHttpBinding.cs
- LinqDataSourceSelectEventArgs.cs
- TraceEventCache.cs
- BevelBitmapEffect.cs
- Grid.cs
- AsyncContentLoadedEventArgs.cs
- TranslateTransform.cs
- RealizationDrawingContextWalker.cs
- MostlySingletonList.cs
- Speller.cs
- ServiceDescriptions.cs
- PlanCompiler.cs
- WebPartMinimizeVerb.cs
- DataGridViewLinkColumn.cs
- Base64Encoder.cs
- DynamicQueryableWrapper.cs
- StyleModeStack.cs
- DecoderReplacementFallback.cs
- AuthenticationModuleElementCollection.cs
- DelegatingConfigHost.cs
- TableRowGroupCollection.cs
- ResourceDisplayNameAttribute.cs
- ObjectItemCollection.cs
- StrongNameIdentityPermission.cs
- JoinGraph.cs
- FrugalList.cs
- ValueConversionAttribute.cs
- Rectangle.cs
- SingleObjectCollection.cs
- ImageClickEventArgs.cs
- LogReserveAndAppendState.cs
- HttpCachePolicy.cs
- Tablet.cs
- XmlElementElementCollection.cs
- Vector3DAnimation.cs
- MailMessage.cs
- XsltQilFactory.cs
- XPathSelfQuery.cs
- Reference.cs