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
- MailHeaderInfo.cs
- OleDbConnection.cs
- MediaScriptCommandRoutedEventArgs.cs
- UnsafeMethods.cs
- DocumentProperties.cs
- DebugView.cs
- FormViewUpdateEventArgs.cs
- HttpWebResponse.cs
- SqlServer2KCompatibilityCheck.cs
- COAUTHIDENTITY.cs
- RootNamespaceAttribute.cs
- CapiSymmetricAlgorithm.cs
- PolyQuadraticBezierSegment.cs
- XpsImage.cs
- CompilerHelpers.cs
- XamlUtilities.cs
- Model3DCollection.cs
- DataGridTextBox.cs
- ErrorFormatterPage.cs
- SelfIssuedSamlTokenFactory.cs
- UriTemplateClientFormatter.cs
- MessageFilter.cs
- PrimitiveCodeDomSerializer.cs
- Descriptor.cs
- TitleStyle.cs
- _SSPISessionCache.cs
- CfgRule.cs
- PropertiesTab.cs
- CodeTypeOfExpression.cs
- CommandExpr.cs
- ThousandthOfEmRealPoints.cs
- LabelEditEvent.cs
- TextWriterTraceListener.cs
- PerformanceCounterLib.cs
- PointUtil.cs
- StringSource.cs
- DefaultProxySection.cs
- CounterNameConverter.cs
- WorkflowOwnerAsyncResult.cs
- ILGenerator.cs
- CodeEventReferenceExpression.cs
- AliasExpr.cs
- Material.cs
- PerformanceCountersElement.cs
- HttpStreamXmlDictionaryReader.cs
- GroupBox.cs
- XmlSchemaComplexType.cs
- PageContent.cs
- AttributeCollection.cs
- MaskInputRejectedEventArgs.cs
- DesignerTransaction.cs
- DataBindingHandlerAttribute.cs
- _HeaderInfo.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- SQLInt16.cs
- SQLDateTime.cs
- XmlSchemaGroupRef.cs
- VectorCollection.cs
- SortAction.cs
- SchemaTableOptionalColumn.cs
- TypeListConverter.cs
- ArgumentNullException.cs
- mediaclock.cs
- UrlPath.cs
- Point3DConverter.cs
- TextStore.cs
- SetUserPreferenceRequest.cs
- DataGridCellInfo.cs
- InstanceData.cs
- TextEditorDragDrop.cs
- DesignerImageAdapter.cs
- PreviousTrackingServiceAttribute.cs
- InternalCache.cs
- PropertySegmentSerializer.cs
- ListItemConverter.cs
- ListViewHitTestInfo.cs
- Renderer.cs
- SemaphoreSecurity.cs
- AtomMaterializerLog.cs
- DurableInstanceProvider.cs
- BitmapSource.cs
- XPathParser.cs
- Visual3D.cs
- ReadContentAsBinaryHelper.cs
- precedingquery.cs
- SoapIgnoreAttribute.cs
- TextCollapsingProperties.cs
- CodeIdentifiers.cs
- RpcAsyncResult.cs
- AutomationAttributeInfo.cs
- EntityAdapter.cs
- JsonFaultDetail.cs
- Constants.cs
- FieldNameLookup.cs
- UidManager.cs
- BaseProcessor.cs
- WizardStepBase.cs
- OpenTypeMethods.cs
- SchemaType.cs
- HtmlControlPersistable.cs