Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Expressions / InvokeMethod.cs / 1305376 / InvokeMethod.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Expressions { using System.Activities.Statements; using System.Activities.Validation; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.Collections; using System.Windows.Markup; using System.Runtime; [ContentProperty("Parameters")] public sealed class InvokeMethod: AsyncCodeActivity { Collection parameters; Collection genericTypeArguments; MethodResolver methodResolver; MethodExecutor methodExecutor; RuntimeArgument resultArgument; public InvokeMethod() : base() { } public Collection GenericTypeArguments { get { if (this.genericTypeArguments == null) { this.genericTypeArguments = new ValidatingCollection { // disallow null values OnAddValidationCallback = item => { if (item == null) { throw FxTrace.Exception.ArgumentNull("item"); } } }; } return this.genericTypeArguments; } } public string MethodName { get; set; } public Collection Parameters { get { if (this.parameters == null) { this.parameters = new ValidatingCollection { // disallow null values OnAddValidationCallback = item => { if (item == null) { throw FxTrace.Exception.ArgumentNull("item"); } } }; } return this.parameters; } } [DefaultValue(null)] public InArgument TargetObject { get; set; } [DefaultValue(null)] public Type TargetType { get; set; } [DefaultValue(false)] public bool RunAsynchronously { get; set; } protected override void CacheMetadata(CodeActivityMetadata metadata) { Collection arguments = new Collection (); Type targetObjectType = TypeHelper.ObjectType; if (this.TargetObject != null) { targetObjectType = this.TargetObject.ArgumentType; } RuntimeArgument targetObjectArgument = new RuntimeArgument("TargetObject", targetObjectType, ArgumentDirection.In); metadata.Bind(this.TargetObject, targetObjectArgument); arguments.Add(targetObjectArgument); this.resultArgument = new RuntimeArgument("Result", typeof(TResult), ArgumentDirection.Out); metadata.Bind(this.Result, this.resultArgument); arguments.Add(this.resultArgument); // Parameters are named according to MethodInfo name if DetermineMethodInfo // succeeds, otherwise arbitrary names are used. this.methodResolver = CreateMethodResolver(); this.methodResolver.DetermineMethodInfo(metadata, out this.methodExecutor); this.methodResolver.RegisterParameters(arguments); metadata.SetArgumentsCollection(arguments); this.methodResolver.Trace(); if (this.methodExecutor != null) { this.methodExecutor.Trace(this); } } protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { return this.methodExecutor.BeginExecuteMethod(context, callback, state); } protected override TResult EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { this.methodExecutor.EndExecuteMethod(context, result); return this.Result.Get(context); } MethodResolver CreateMethodResolver() { return new MethodResolver { MethodName = this.MethodName, RunAsynchronously = this.RunAsynchronously, TargetType = this.TargetType, TargetObject = this.TargetObject, GenericTypeArguments = this.GenericTypeArguments, Parameters = this.Parameters, Result = this.resultArgument, ResultType = typeof(TResult), Parent = this }; } } } // 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
- AutoGeneratedFieldProperties.cs
- GraphicsPath.cs
- CodeGeneratorOptions.cs
- HttpConfigurationContext.cs
- XamlPoint3DCollectionSerializer.cs
- MapPathBasedVirtualPathProvider.cs
- InstanceHandleConflictException.cs
- SetIterators.cs
- DataMemberConverter.cs
- Size.cs
- SqlMethodAttribute.cs
- LinqDataSourceStatusEventArgs.cs
- FixedDocumentSequencePaginator.cs
- SaveFileDialog.cs
- AutomationPropertyInfo.cs
- FontStyleConverter.cs
- DbConnectionPoolGroup.cs
- AutomationPeer.cs
- OracleMonthSpan.cs
- SystemIPv4InterfaceProperties.cs
- StatusBar.cs
- ExtenderProvidedPropertyAttribute.cs
- UInt64Converter.cs
- WebBrowserEvent.cs
- EmptyReadOnlyDictionaryInternal.cs
- VersionUtil.cs
- WebEventCodes.cs
- SQlBooleanStorage.cs
- AsyncOperation.cs
- EventProviderClassic.cs
- TypeUtil.cs
- EdgeProfileValidation.cs
- RSAPKCS1SignatureDeformatter.cs
- ZipIORawDataFileBlock.cs
- TextTrailingCharacterEllipsis.cs
- ScriptBehaviorDescriptor.cs
- _ScatterGatherBuffers.cs
- FormsAuthenticationUser.cs
- SafeReadContext.cs
- SchemaTypeEmitter.cs
- Helper.cs
- KerberosSecurityTokenProvider.cs
- log.cs
- DisplayNameAttribute.cs
- HtmlInputHidden.cs
- SspiHelper.cs
- DesignerPerfEventProvider.cs
- CommonDialog.cs
- Menu.cs
- NativeWrapper.cs
- Rect3D.cs
- CanExecuteRoutedEventArgs.cs
- SwitchAttribute.cs
- TypeSystemProvider.cs
- UnaryOperationBinder.cs
- ListMarkerSourceInfo.cs
- ScrollData.cs
- TdsParserSafeHandles.cs
- ExtensionSimplifierMarkupObject.cs
- DbReferenceCollection.cs
- VolatileEnlistmentState.cs
- ProfilePropertySettings.cs
- EntityViewGenerator.cs
- ToolStripPanelCell.cs
- EUCJPEncoding.cs
- OracleInternalConnection.cs
- UnsupportedPolicyOptionsException.cs
- ClockGroup.cs
- NTAccount.cs
- ContextQuery.cs
- ListItemCollection.cs
- _NestedSingleAsyncResult.cs
- RegisteredHiddenField.cs
- ConfigurationValue.cs
- ResourceContainerWrapper.cs
- ViewValidator.cs
- TransportChannelListener.cs
- OAVariantLib.cs
- FlowLayout.cs
- BindMarkupExtensionSerializer.cs
- GroupBoxRenderer.cs
- CompositeDataBoundControl.cs
- DbMetaDataColumnNames.cs
- PostBackOptions.cs
- HMACSHA1.cs
- _ListenerAsyncResult.cs
- XmlSchemaCollection.cs
- AdPostCacheSubstitution.cs
- EdmError.cs
- DataControlPagerLinkButton.cs
- SqlDelegatedTransaction.cs
- FaultContext.cs
- EncryptedType.cs
- NetworkInterface.cs
- SqlTypeSystemProvider.cs
- DBCSCodePageEncoding.cs
- RadioButtonList.cs
- xmlsaver.cs
- WindowsEditBoxRange.cs
- TagNameToTypeMapper.cs