Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / InvokeMethod.cs / 1305376 / InvokeMethod.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace 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 { Collectionparameters; 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 OutArgument Result { get; set; } [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); Type resultType = TypeHelper.ObjectType; if (this.Result != null) { resultType = this.Result.ArgumentType; } this.resultArgument = new RuntimeArgument("Result", resultType, ArgumentDirection.Out); metadata.Bind(this.Result, this.resultArgument); arguments.Add(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 void EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { this.methodExecutor.EndExecuteMethod(context, result); } MethodResolver CreateMethodResolver() { MethodResolver resolver = new MethodResolver { MethodName = this.MethodName, RunAsynchronously = this.RunAsynchronously, TargetType = this.TargetType, TargetObject = this.TargetObject, GenericTypeArguments = this.GenericTypeArguments, Parameters = this.Parameters, Result = this.resultArgument, Parent = this }; if (this.Result != null) { resolver.ResultType = this.Result.ArgumentType; } else { resolver.ResultType = typeof(object); } return resolver; } } } // 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
- ChangeDirector.cs
- DynamicResourceExtensionConverter.cs
- MulticastIPAddressInformationCollection.cs
- WebPartZoneCollection.cs
- UnsafeMethods.cs
- NonBatchDirectoryCompiler.cs
- CodeSpit.cs
- InheritablePropertyChangeInfo.cs
- SqlDependencyListener.cs
- LinkLabel.cs
- ToolStripDropDownMenu.cs
- IChannel.cs
- GlyphInfoList.cs
- XamlBuildProvider.cs
- BitmapEffect.cs
- ChameleonKey.cs
- ITextView.cs
- GenericRootAutomationPeer.cs
- TemplateManager.cs
- SqlProviderManifest.cs
- IODescriptionAttribute.cs
- ProtocolProfile.cs
- DockPanel.cs
- DataMisalignedException.cs
- BaseTemplateParser.cs
- InvokeMemberBinder.cs
- TypeForwardedToAttribute.cs
- FilteredDataSetHelper.cs
- TypeConverterHelper.cs
- OrderByLifter.cs
- ObjectViewFactory.cs
- SelfIssuedTokenFactoryCredential.cs
- ConstructorNeedsTagAttribute.cs
- BooleanSwitch.cs
- OpenFileDialog.cs
- NullableIntSumAggregationOperator.cs
- XmlEncoding.cs
- AmbientLight.cs
- x509utils.cs
- MachineKeyConverter.cs
- CodeSubDirectoriesCollection.cs
- ImageAttributes.cs
- ConfigurationStrings.cs
- CriticalHandle.cs
- WebPartZone.cs
- NameSpaceEvent.cs
- SystemIcmpV6Statistics.cs
- XXXOnTypeBuilderInstantiation.cs
- QuadraticBezierSegment.cs
- ProtocolsSection.cs
- SchemaComplexType.cs
- RoleManagerEventArgs.cs
- PreviewPageInfo.cs
- BaseCAMarshaler.cs
- AggregateNode.cs
- ObjectViewEntityCollectionData.cs
- AssociationEndMember.cs
- DataGridCheckBoxColumn.cs
- MissingSatelliteAssemblyException.cs
- DelegatingConfigHost.cs
- Selector.cs
- precedingquery.cs
- ExpressionBindingCollection.cs
- precedingsibling.cs
- RegistrationServices.cs
- TransactionInterop.cs
- BaseCollection.cs
- GeneratedCodeAttribute.cs
- PassportIdentity.cs
- ReflectTypeDescriptionProvider.cs
- ConsumerConnectionPointCollection.cs
- ResourceProviderFactory.cs
- HwndSourceKeyboardInputSite.cs
- SecurityException.cs
- Lazy.cs
- RijndaelManagedTransform.cs
- StatusBarDrawItemEvent.cs
- ProcessHostServerConfig.cs
- Int32Rect.cs
- TemplateGroupCollection.cs
- PartialArray.cs
- UITypeEditor.cs
- WindowsListViewSubItem.cs
- VisualStateChangedEventArgs.cs
- CodeMethodReturnStatement.cs
- CodeCatchClauseCollection.cs
- DocumentOrderComparer.cs
- SupportingTokenParameters.cs
- WindowsListViewItemStartMenu.cs
- FilterFactory.cs
- SafeThemeHandle.cs
- SBCSCodePageEncoding.cs
- ScrollBarRenderer.cs
- CustomWebEventKey.cs
- BaseTransportHeaders.cs
- PtsPage.cs
- TimeZoneNotFoundException.cs
- TransformCryptoHandle.cs
- TrackingQueryElement.cs
- InstanceKeyView.cs