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
- Pen.cs
- AmbientLight.cs
- SuppressMessageAttribute.cs
- DbConnectionHelper.cs
- NameService.cs
- HttpDictionary.cs
- ZipIOExtraFieldZip64Element.cs
- DomNameTable.cs
- ReturnValue.cs
- WebPartUtil.cs
- NonBatchDirectoryCompiler.cs
- DesignTimeHTMLTextWriter.cs
- NavigatingCancelEventArgs.cs
- Table.cs
- RMEnrollmentPage1.cs
- EntityModelBuildProvider.cs
- ReadOnlyDictionary.cs
- ExtendedPropertiesHandler.cs
- QuaternionValueSerializer.cs
- Attachment.cs
- AnchorEditor.cs
- XmlDesigner.cs
- Polygon.cs
- StylusShape.cs
- InitializerFacet.cs
- ContentElementCollection.cs
- HttpCachePolicy.cs
- Color.cs
- ISAPIApplicationHost.cs
- ElasticEase.cs
- RequestNavigateEventArgs.cs
- VerticalAlignConverter.cs
- RelationshipDetailsRow.cs
- DataSourceExpression.cs
- WebConfigurationManager.cs
- SemanticTag.cs
- SystemIPInterfaceProperties.cs
- FtpWebResponse.cs
- WindowsTab.cs
- wgx_render.cs
- HttpListenerContext.cs
- FlowDocumentReaderAutomationPeer.cs
- XmlNullResolver.cs
- UnsafeNativeMethodsPenimc.cs
- SrgsRule.cs
- MenuItemBinding.cs
- SocketInformation.cs
- HyperLink.cs
- MonthChangedEventArgs.cs
- PropertySourceInfo.cs
- SpellerStatusTable.cs
- CodeRegionDirective.cs
- RelOps.cs
- DesignConnection.cs
- DeadCharTextComposition.cs
- WebPartConnectionsEventArgs.cs
- CompositeControlDesigner.cs
- ProbeDuplexAsyncResult.cs
- DesignerTransactionCloseEvent.cs
- CodeDomLoader.cs
- WebServicesSection.cs
- XhtmlCssHandler.cs
- CurrentChangingEventManager.cs
- ProxySimple.cs
- PropertyPath.cs
- StrongNameIdentityPermission.cs
- Animatable.cs
- Currency.cs
- TextTreeUndoUnit.cs
- CanonicalizationDriver.cs
- ErrorRuntimeConfig.cs
- MatrixTransform.cs
- MetaTableHelper.cs
- StringOutput.cs
- MaskInputRejectedEventArgs.cs
- HandlerBase.cs
- TransformDescriptor.cs
- ProcessHostMapPath.cs
- ConfigXmlCDataSection.cs
- ProvidersHelper.cs
- RuntimeHandles.cs
- XLinq.cs
- RenderDataDrawingContext.cs
- PersonalizablePropertyEntry.cs
- JournalEntry.cs
- AttributeAction.cs
- _BufferOffsetSize.cs
- XmlSchemaAnnotation.cs
- RemotingSurrogateSelector.cs
- Publisher.cs
- DataTableNewRowEvent.cs
- FullTextLine.cs
- ServiceOperation.cs
- RuntimeComponentFilter.cs
- Sentence.cs
- ClientSettingsSection.cs
- TableItemStyle.cs
- DocumentSequenceHighlightLayer.cs
- FlowDocumentScrollViewer.cs
- PointCollection.cs