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
- SystemInfo.cs
- CellCreator.cs
- InfoCardTraceRecord.cs
- BindingCompleteEventArgs.cs
- CompositeScriptReferenceEventArgs.cs
- CultureSpecificStringDictionary.cs
- FileUtil.cs
- NeutralResourcesLanguageAttribute.cs
- RtfFormatStack.cs
- SerialStream.cs
- HandledMouseEvent.cs
- CapabilitiesUse.cs
- SafeCryptoHandles.cs
- ProfileProvider.cs
- ScriptManagerProxy.cs
- StorageInfo.cs
- IntSecurity.cs
- SystemNetworkInterface.cs
- Calendar.cs
- TextEditorContextMenu.cs
- ReadOnlyMetadataCollection.cs
- ApplicationCommands.cs
- EntityTransaction.cs
- KnownIds.cs
- WebPartExportVerb.cs
- ListViewItemEventArgs.cs
- XPathBuilder.cs
- SmiEventSink.cs
- InertiaTranslationBehavior.cs
- DbSourceParameterCollection.cs
- DbException.cs
- SmtpFailedRecipientException.cs
- LateBoundBitmapDecoder.cs
- XmlDocumentViewSchema.cs
- WinCategoryAttribute.cs
- ProviderConnectionPoint.cs
- DefaultParameterValueAttribute.cs
- Stack.cs
- PageEventArgs.cs
- SystemFonts.cs
- SplashScreen.cs
- CustomPopupPlacement.cs
- PrintingPermission.cs
- HtmlTableRowCollection.cs
- PointF.cs
- RsaKeyIdentifierClause.cs
- VariableElement.cs
- UserControl.cs
- objectresult_tresulttype.cs
- XmlText.cs
- GCHandleCookieTable.cs
- ToolStripRenderEventArgs.cs
- StringToken.cs
- XmlHelper.cs
- iisPickupDirectory.cs
- Facet.cs
- LockedHandleGlyph.cs
- MonitorWrapper.cs
- DialogWindow.cs
- BaseCodePageEncoding.cs
- StylusDevice.cs
- XNameTypeConverter.cs
- OracleException.cs
- CodeThrowExceptionStatement.cs
- DeferredElementTreeState.cs
- DataGridViewComboBoxCell.cs
- EdgeProfileValidation.cs
- hresults.cs
- MsmqTransportBindingElement.cs
- MsmqAppDomainProtocolHandler.cs
- ArgumentNullException.cs
- ContractAdapter.cs
- CompletedAsyncResult.cs
- LinqDataSourceView.cs
- RealProxy.cs
- IISMapPath.cs
- ListSortDescription.cs
- SqlMethodTransformer.cs
- UserControlBuildProvider.cs
- SqlMethodAttribute.cs
- MeasureItemEvent.cs
- TabItemWrapperAutomationPeer.cs
- Padding.cs
- SpecularMaterial.cs
- DataGridColumnCollection.cs
- SecUtil.cs
- OrderablePartitioner.cs
- VersionPair.cs
- NullExtension.cs
- DetailsViewRowCollection.cs
- SinglePageViewer.cs
- Image.cs
- ZoneLinkButton.cs
- HttpResponseInternalBase.cs
- BuildManager.cs
- FormCollection.cs
- XmlTextEncoder.cs
- ThreadSafeList.cs
- EntityDataSourceChangedEventArgs.cs
- EntityDataSourceSelectingEventArgs.cs