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
- Expr.cs
- TypePresenter.xaml.cs
- PerformanceCounterLib.cs
- ServiceInfoCollection.cs
- ScrollContentPresenter.cs
- PolicyUtility.cs
- PageCodeDomTreeGenerator.cs
- UserNameSecurityTokenAuthenticator.cs
- FocusManager.cs
- WebRequestModulesSection.cs
- LayoutEditorPart.cs
- BrowserTree.cs
- SQLDecimalStorage.cs
- QueryExecutionOption.cs
- SmiEventSink_DeferedProcessing.cs
- XmlWrappingReader.cs
- SoapEnvelopeProcessingElement.cs
- XmlILOptimizerVisitor.cs
- HtmlFormWrapper.cs
- MultipartIdentifier.cs
- DynamicDocumentPaginator.cs
- HMACSHA384.cs
- InkCanvasSelectionAdorner.cs
- TcpSocketManager.cs
- RowToFieldTransformer.cs
- InvalidEnumArgumentException.cs
- RawStylusInputCustomDataList.cs
- CustomTypeDescriptor.cs
- MsmqIntegrationInputChannel.cs
- returneventsaver.cs
- StrongNameUtility.cs
- BaseCodePageEncoding.cs
- RelativeSource.cs
- BasePattern.cs
- XsltArgumentList.cs
- SmiConnection.cs
- AppSecurityManager.cs
- RegisteredArrayDeclaration.cs
- WinInetCache.cs
- ConfigUtil.cs
- SimpleHandlerFactory.cs
- WebPartMenuStyle.cs
- CFStream.cs
- NamespaceDecl.cs
- VoiceObjectToken.cs
- DataControlCommands.cs
- TextServicesPropertyRanges.cs
- WebServiceData.cs
- TransactionFlowBindingElementImporter.cs
- PreviewPrintController.cs
- SqlTriggerAttribute.cs
- IIS7WorkerRequest.cs
- FileSystemEventArgs.cs
- ZipIOLocalFileBlock.cs
- WebPartConnectionsConfigureVerb.cs
- AssemblyBuilderData.cs
- TextServicesProperty.cs
- DocumentPaginator.cs
- ContextConfiguration.cs
- OutputCache.cs
- Parsers.cs
- ObjectContextServiceProvider.cs
- SchemaElementDecl.cs
- TagMapInfo.cs
- ObservableCollection.cs
- CustomError.cs
- MenuScrollingVisibilityConverter.cs
- LineServices.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- ColumnResizeAdorner.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- HostedHttpTransportManager.cs
- DecoratedNameAttribute.cs
- PropertyBuilder.cs
- UnsafeNetInfoNativeMethods.cs
- SystemWebExtensionsSectionGroup.cs
- ListControlStringCollectionEditor.cs
- QueueProcessor.cs
- MutexSecurity.cs
- CharacterHit.cs
- SspiNegotiationTokenAuthenticatorState.cs
- Token.cs
- CfgParser.cs
- AnonymousIdentificationSection.cs
- WhereQueryOperator.cs
- RotationValidation.cs
- Compilation.cs
- SecurityStateEncoder.cs
- ZipIOLocalFileBlock.cs
- _SslSessionsCache.cs
- TreeViewHitTestInfo.cs
- Matrix.cs
- ReadWriteSpinLock.cs
- SessionPageStateSection.cs
- RC2CryptoServiceProvider.cs
- FormViewModeEventArgs.cs
- GcSettings.cs
- CombinedGeometry.cs
- SystemWebSectionGroup.cs
- VectorAnimation.cs