Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / PropertyValue.cs / 1305376 / PropertyValue.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Expressions { using System.Activities; using System.Activities.Validation; using System.ComponentModel; using System.Reflection; using System.Runtime; public sealed class PropertyValue: CodeActivity { Func operationFunction; public InArgument Operand { get; set; } [DefaultValue(null)] public string PropertyName { get; set; } protected override void CacheMetadata(CodeActivityMetadata metadata) { bool isRequired = false; if (typeof(TOperand).IsEnum) { metadata.AddValidationError(SR.TargetTypeCannotBeEnum(this.GetType().Name, this.DisplayName)); } if (string.IsNullOrEmpty(this.PropertyName)) { metadata.AddValidationError(SR.ActivityPropertyMustBeSet("PropertyName", this.DisplayName)); } else { PropertyInfo propertyInfo = null; Type operandType = typeof(TOperand); propertyInfo = operandType.GetProperty(this.PropertyName); if (propertyInfo == null) { metadata.AddValidationError(SR.MemberNotFound(this.PropertyName, typeof(TOperand).Name)); } else { Fx.Assert(propertyInfo.GetAccessors().Length > 0, "Property should have at least 1 accessor."); isRequired = !propertyInfo.GetAccessors()[0].IsStatic; ValidationError validationError; if (!MemberExpressionHelper.TryGenerateLinqDelegate(this.PropertyName, false, propertyInfo.GetAccessors()[0].IsStatic, out this.operationFunction, out validationError)) { metadata.AddValidationError(validationError); } MethodInfo getMethod = propertyInfo.GetGetMethod(); MethodInfo setMethod = propertyInfo.GetSetMethod(); if ((getMethod != null && !getMethod.IsStatic) || (setMethod != null && !setMethod.IsStatic)) { isRequired = true; } } } MemberExpressionHelper.AddOperandArgument(metadata, this.Operand, isRequired); } protected override TResult Execute(CodeActivityContext context) { TOperand operandValue = this.Operand.Get(context); TResult result = this.operationFunction(operandValue); return result; } } } // 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
- TraceUtility.cs
- Utils.cs
- TextTreeExtractElementUndoUnit.cs
- StreamingContext.cs
- CheckBoxRenderer.cs
- StateRuntime.cs
- RowVisual.cs
- CrossContextChannel.cs
- CounterSample.cs
- peersecuritysettings.cs
- CheckBoxField.cs
- VariantWrapper.cs
- BinaryExpression.cs
- SplitterEvent.cs
- ListBindingConverter.cs
- TraceLog.cs
- ListBox.cs
- OleDbCommandBuilder.cs
- DispatcherExceptionFilterEventArgs.cs
- StylusPointPropertyInfoDefaults.cs
- MaterialCollection.cs
- TCEAdapterGenerator.cs
- ContextMenuStrip.cs
- ThaiBuddhistCalendar.cs
- SelectionWordBreaker.cs
- QilChoice.cs
- SystemIcmpV6Statistics.cs
- recordstate.cs
- AuthenticationSection.cs
- Interlocked.cs
- ResXResourceReader.cs
- SqlBuffer.cs
- SimpleMailWebEventProvider.cs
- baseaxisquery.cs
- dsa.cs
- DataGridHelper.cs
- MessageAction.cs
- DeferredSelectedIndexReference.cs
- SafeNativeMethodsCLR.cs
- OuterGlowBitmapEffect.cs
- SequentialActivityDesigner.cs
- StickyNoteAnnotations.cs
- GlobalEventManager.cs
- XmlSignificantWhitespace.cs
- UriSection.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- ExtensionDataObject.cs
- webproxy.cs
- NavigationPropertyEmitter.cs
- Compilation.cs
- ActivityMarkupSerializationProvider.cs
- ObjectItemLoadingSessionData.cs
- EventRouteFactory.cs
- AsyncSerializedWorker.cs
- BoolExpressionVisitors.cs
- ADMembershipUser.cs
- RegexFCD.cs
- TreeNodeCollection.cs
- CodeSnippetExpression.cs
- Hex.cs
- Viewport2DVisual3D.cs
- precedingquery.cs
- XhtmlConformanceSection.cs
- TranslateTransform3D.cs
- AssemblyAttributesGoHere.cs
- DataServiceOperationContext.cs
- ArithmeticLiteral.cs
- CompressedStack.cs
- Material.cs
- XmlValidatingReaderImpl.cs
- ManipulationLogic.cs
- InvalidContentTypeException.cs
- UnmanagedBitmapWrapper.cs
- TemplateColumn.cs
- ButtonAutomationPeer.cs
- CustomErrorCollection.cs
- ConnectionPoolManager.cs
- JournalEntryStack.cs
- Int64Storage.cs
- OpCodes.cs
- ObjectQuery_EntitySqlExtensions.cs
- ArglessEventHandlerProxy.cs
- DetailsViewRowCollection.cs
- PersistenceException.cs
- WpfKnownType.cs
- CatalogZone.cs
- SoapExtensionTypeElementCollection.cs
- RoleManagerModule.cs
- FileLogRecordStream.cs
- XmlAtomicValue.cs
- ThreadStaticAttribute.cs
- MappingSource.cs
- DesignBindingValueUIHandler.cs
- ToolStripRenderEventArgs.cs
- IdnMapping.cs
- PrinterResolution.cs
- TemplateKeyConverter.cs
- DictionarySectionHandler.cs
- StoreContentChangedEventArgs.cs
- RouteParametersHelper.cs