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
- XmlSortKeyAccumulator.cs
- RowsCopiedEventArgs.cs
- JsonDataContract.cs
- CategoryNameCollection.cs
- DataGridCheckBoxColumn.cs
- SelectedGridItemChangedEvent.cs
- TemplateBindingExtensionConverter.cs
- Lasso.cs
- FontCollection.cs
- ObjectListGeneralPage.cs
- DbMetaDataFactory.cs
- fixedPageContentExtractor.cs
- OneOfConst.cs
- TextParaClient.cs
- EntityEntry.cs
- SmiContext.cs
- LicenseException.cs
- FormViewDeletedEventArgs.cs
- SystemIPInterfaceProperties.cs
- StrokeCollection.cs
- ButtonColumn.cs
- HtmlElement.cs
- FormViewUpdatedEventArgs.cs
- Point.cs
- UnSafeCharBuffer.cs
- StrokeCollection2.cs
- InvalidAsynchronousStateException.cs
- BulletedList.cs
- DataContractSerializerOperationBehavior.cs
- COM2AboutBoxPropertyDescriptor.cs
- XmlNavigatorFilter.cs
- DynamicActivityXamlReader.cs
- PartialClassGenerationTaskInternal.cs
- BuilderElements.cs
- Logging.cs
- UserMapPath.cs
- fixedPageContentExtractor.cs
- IisHelper.cs
- DecoratedNameAttribute.cs
- SchemaCollectionCompiler.cs
- SimpleWebHandlerParser.cs
- NameHandler.cs
- MessageBox.cs
- SQLBinary.cs
- NativeCppClassAttribute.cs
- WebProxyScriptElement.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- CollectionViewProxy.cs
- HwndSubclass.cs
- VersionedStreamOwner.cs
- DataServiceHost.cs
- SqlBulkCopyColumnMappingCollection.cs
- ScrollViewerAutomationPeer.cs
- FtpWebRequest.cs
- PointConverter.cs
- XmlDownloadManager.cs
- DbSetClause.cs
- ScrollEvent.cs
- Overlapped.cs
- SmtpReplyReaderFactory.cs
- TemplatedMailWebEventProvider.cs
- CultureInfo.cs
- ThreadSafeList.cs
- ResourceSetExpression.cs
- FreezableOperations.cs
- RotationValidation.cs
- CompiledRegexRunnerFactory.cs
- TemplateContentLoader.cs
- RSACryptoServiceProvider.cs
- WorkflowTraceTransfer.cs
- Exceptions.cs
- ProcessHostConfigUtils.cs
- PeerNodeTraceRecord.cs
- PolyBezierSegment.cs
- BooleanFunctions.cs
- DeleteWorkflowOwnerCommand.cs
- HtmlHead.cs
- DesignColumnCollection.cs
- CardSpaceException.cs
- DataGridViewCellStyle.cs
- ProcessHostFactoryHelper.cs
- TextEndOfParagraph.cs
- HttpHandlerActionCollection.cs
- MarkupExtensionParser.cs
- SimpleWebHandlerParser.cs
- NavigatorInvalidBodyAccessException.cs
- GridItemCollection.cs
- ObjectListFieldsPage.cs
- DataServiceRequestArgs.cs
- SymDocumentType.cs
- SmiEventSink.cs
- IdentityReference.cs
- TypeSystem.cs
- XmlWriterSettings.cs
- KeyTimeConverter.cs
- CachedFontFamily.cs
- InteropBitmapSource.cs
- BookmarkScopeManager.cs
- DataViewManager.cs
- Rect.cs