Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / Statements / MethodExecutor.cs / 1305376 / MethodExecutor.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Statements { using System; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime; // Inverted Template Method pattern. MethodExecutor is the base class for executing a method; created by MethodResolver. // Private concrete implementations are created by MethodResolver, but this is the "public" API used by InvokeMethod. abstract class MethodExecutor { // Used for creating tracing messages w/ DisplayName Activity invokingActivity; // We may still need to know targetType if we're autocreating targets during ExecuteMethod Type targetType; InArgument targetObject; Collectionparameters; RuntimeArgument returnObject; public MethodExecutor(Activity invokingActivity, Type targetType, InArgument targetObject, Collection parameters, RuntimeArgument returnObject) { Fx.Assert(invokingActivity != null, "Must provide invokingActivity"); Fx.Assert(targetType != null || (targetObject != null), "Must provide targetType or targetObject"); Fx.Assert(parameters != null, "Must provide parameters"); // returnObject is optional this.invokingActivity = invokingActivity; this.targetType = targetType; this.targetObject = targetObject; this.parameters = parameters; this.returnObject = returnObject; } public abstract bool MethodIsStatic { get; } protected abstract IAsyncResult BeginMakeMethodCall(AsyncCodeActivityContext context, object target, AsyncCallback callback, object state); protected abstract void EndMakeMethodCall(AsyncCodeActivityContext context, IAsyncResult result); static bool HaveParameterArray(ParameterInfo[] parameters) { if (parameters.Length > 0) { ParameterInfo last = parameters[parameters.Length - 1]; return last.GetCustomAttributes(typeof(ParamArrayAttribute), true).GetLength(0) > 0; } else { return false; } } protected object[] EvaluateAndPackParameters(CodeActivityContext context, MethodInfo method, bool usingAsyncPattern) { ParameterInfo[] formalParameters = method.GetParameters(); int formalParamCount = formalParameters.Length; object[] actualParameters = new object[formalParamCount]; if (usingAsyncPattern) { formalParamCount -= 2; } bool haveParameterArray = HaveParameterArray(formalParameters); for (int i = 0; i < formalParamCount; i++) { if (i == formalParamCount - 1 && !usingAsyncPattern && haveParameterArray) { int paramArrayCount = this.parameters.Count - formalParamCount + 1; // If params are given explicitly, that's okay. if (paramArrayCount == 1 && TypeHelper.AreTypesCompatible(this.parameters[i].ArgumentType, formalParameters[i].ParameterType)) { actualParameters[i] = this.parameters[i].Get
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Encoder.cs
- RegexGroupCollection.cs
- BookmarkNameHelper.cs
- XmlNodeChangedEventManager.cs
- ChannelBinding.cs
- StringAnimationUsingKeyFrames.cs
- BamlRecords.cs
- MetadataSet.cs
- ToolStripPanelRenderEventArgs.cs
- EventWaitHandleSecurity.cs
- ColorConverter.cs
- LayoutSettings.cs
- ParserStack.cs
- Preprocessor.cs
- SafeLocalAllocation.cs
- ValidationHelpers.cs
- NullableConverter.cs
- xmlsaver.cs
- DataGridDetailsPresenterAutomationPeer.cs
- SelectionProviderWrapper.cs
- PixelShader.cs
- DependencyPropertyKind.cs
- XmlTextEncoder.cs
- TrackingWorkflowEventArgs.cs
- UInt64Storage.cs
- TreeViewBindingsEditor.cs
- FlowLayoutSettings.cs
- Single.cs
- handlecollector.cs
- ObjectStateEntryDbDataRecord.cs
- NumberAction.cs
- XmlNodeReader.cs
- GradientBrush.cs
- RegexNode.cs
- ContainerCodeDomSerializer.cs
- RectAnimation.cs
- RightsManagementEncryptionTransform.cs
- WindowsMenu.cs
- ListBase.cs
- WindowsFormsSectionHandler.cs
- InteropAutomationProvider.cs
- TextBoxRenderer.cs
- ElementHost.cs
- LogEntryHeaderSerializer.cs
- RefreshEventArgs.cs
- XmlTypeAttribute.cs
- Matrix3D.cs
- GridItemPatternIdentifiers.cs
- InvalidOperationException.cs
- WindowsToolbarItemAsMenuItem.cs
- InstanceDescriptor.cs
- EqualityComparer.cs
- DeviceContext.cs
- GlyphsSerializer.cs
- SafeNativeMethods.cs
- _AcceptOverlappedAsyncResult.cs
- MessageQueueCriteria.cs
- LayoutEditorPart.cs
- CombinedGeometry.cs
- ScalarConstant.cs
- WindowsGrip.cs
- ExceptionHandler.cs
- ScrollItemProviderWrapper.cs
- FileDialog_Vista.cs
- Select.cs
- StringComparer.cs
- Configuration.cs
- SafeMILHandle.cs
- FormattedText.cs
- BinaryObjectWriter.cs
- OracleConnectionStringBuilder.cs
- UnitySerializationHolder.cs
- DoubleCollection.cs
- DbBuffer.cs
- SqlFunctionAttribute.cs
- ArrayList.cs
- ValidationPropertyAttribute.cs
- FileCodeGroup.cs
- OpenTypeMethods.cs
- CodeChecksumPragma.cs
- LongPath.cs
- RelationHandler.cs
- ExternalException.cs
- IndependentAnimationStorage.cs
- ControlPager.cs
- WebPartDisplayModeEventArgs.cs
- Executor.cs
- WebResourceAttribute.cs
- RenderingBiasValidation.cs
- TransformValueSerializer.cs
- StreamReader.cs
- ButtonBase.cs
- ArgumentValueSerializer.cs
- ListBox.cs
- CodeCommentStatement.cs
- InkCanvasSelectionAdorner.cs
- ParentQuery.cs
- NavigationPropertyEmitter.cs
- ScriptReference.cs
- BidirectionalDictionary.cs