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
- ManipulationDevice.cs
- _Semaphore.cs
- WindowsProgressbar.cs
- XmlHelper.cs
- CharacterString.cs
- DbDataAdapter.cs
- DataBindingsDialog.cs
- ConfigurationPropertyAttribute.cs
- BindingContext.cs
- MessageDesigner.cs
- DoubleAnimationBase.cs
- InvalidEnumArgumentException.cs
- BoolExpr.cs
- InputBinder.cs
- User.cs
- PageAsyncTaskManager.cs
- IIS7UserPrincipal.cs
- ReadOnlyHierarchicalDataSourceView.cs
- Binding.cs
- MenuCommand.cs
- SoapHeaderAttribute.cs
- FlowDocumentView.cs
- PackageRelationship.cs
- PrePrepareMethodAttribute.cs
- SplineKeyFrames.cs
- JsonReaderDelegator.cs
- codemethodreferenceexpression.cs
- SingletonInstanceContextProvider.cs
- ObjectComplexPropertyMapping.cs
- XmlHierarchicalEnumerable.cs
- DbMetaDataCollectionNames.cs
- ListMarkerLine.cs
- DefaultAuthorizationContext.cs
- AutoResetEvent.cs
- SendActivityDesigner.cs
- CompletionCallbackWrapper.cs
- DesignerAttribute.cs
- InvokeMethodActivityDesigner.cs
- GifBitmapEncoder.cs
- Utils.cs
- CodeGroup.cs
- ObjectQuery_EntitySqlExtensions.cs
- XmlException.cs
- ValidateNames.cs
- XmlSchemaCompilationSettings.cs
- SourceLineInfo.cs
- UmAlQuraCalendar.cs
- XPathSelectionIterator.cs
- TemplateBamlRecordReader.cs
- WebPartConnectionsEventArgs.cs
- HtmlMobileTextWriter.cs
- KeyEvent.cs
- DispatcherFrame.cs
- SessionParameter.cs
- UserUseLicenseDictionaryLoader.cs
- FormsAuthenticationConfiguration.cs
- FormViewPagerRow.cs
- QilTypeChecker.cs
- PartialTrustVisibleAssembliesSection.cs
- RenderingEventArgs.cs
- LicFileLicenseProvider.cs
- NotFiniteNumberException.cs
- precedingquery.cs
- LinqExpressionNormalizer.cs
- TemplateField.cs
- XmlSubtreeReader.cs
- CodeStatement.cs
- GlyphingCache.cs
- RectValueSerializer.cs
- SoapElementAttribute.cs
- ExeContext.cs
- ErrorHandler.cs
- IISMapPath.cs
- GridViewRowCollection.cs
- EnterpriseServicesHelper.cs
- WebPartConnectionsEventArgs.cs
- ValidationPropertyAttribute.cs
- XmlBindingWorker.cs
- SingleQueryOperator.cs
- Selector.cs
- SHA512.cs
- CaseExpr.cs
- XmlLanguageConverter.cs
- Int64.cs
- IDQuery.cs
- TextParagraphCache.cs
- Byte.cs
- BindingOperations.cs
- DBSqlParserTable.cs
- AutoFocusStyle.xaml.cs
- OracleTransaction.cs
- TypeBuilderInstantiation.cs
- DataObjectSettingDataEventArgs.cs
- DSASignatureFormatter.cs
- Vector3dCollection.cs
- Hyperlink.cs
- MaskDescriptors.cs
- GACMembershipCondition.cs
- TableCellCollection.cs
- SizeKeyFrameCollection.cs