Files
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Private.CoreLib
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
Assembly
CommonCrypto
CoreFoundation
Documentation
LinkerDescriptor
Microsoft.Win32
Mono
Mono.Globalization.Unicode
Mono.Interop
Mono.Security
Mono.Security.Cryptography
Mono.Xml
ReferenceSources
System
System.Configuration.Assemblies
System.Deployment.Internal
System.Diagnostics
System.Diagnostics.SymbolStore
System.Diagnostics.Tracing
System.Globalization
System.IO
System.IO.Enumeration
System.IO.IsolatedStorage
System.Reflection
System.Reflection.Emit
System.Reflection.Metadata
System.Resources
System.Runtime
System.Runtime.CompilerServices
System.Runtime.Hosting
System.Runtime.InteropServices
System.Runtime.InteropServices.RuntimeInformation
System.Runtime.InteropServices.WindowsRuntime
System.Runtime.Remoting
System.Runtime.Remoting.Activation
System.Runtime.Remoting.Channels
System.Runtime.Remoting.Contexts
System.Runtime.Remoting.Lifetime
System.Runtime.Remoting.Messaging
ArgInfo.cs
AsyncResult.cs
CADMessages.cs
ClientContextTerminatorSink.cs
ConstructionCall.cs
ConstructionCallDictionary.cs
ConstructionResponse.cs
EnvoyTerminatorSink.cs
ErrorMessage.cs
Header.cs
HeaderHandler.cs
IInternalMessage.cs
IMessage.cs
IMessageCtrl.cs
IMessageSink.cs
IMethodCallMessage.cs
IMethodMessage.cs
IMethodReturnMessage.cs
IRemotingFormatter.cs
ISerializationRootObject.cs
InternalMessageWrapper.cs
MessageSurrogateFilter.cs
MethodCall.cs
MethodCallDictionary.cs
MethodCallMessageWrapper.cs
MethodDictionary.cs
MethodResponse.cs
MethodReturnDictionary.cs
MethodReturnMessageWrapper.cs
MonoMethodMessage.cs
OneWayAttribute.cs
RemotingSurrogate.cs
RemotingSurrogateSelector.cs
ReturnMessage.cs
ServerContextTerminatorSink.cs
ServerObjectTerminatorSink.cs
StackBuilderSink.cs
System.Runtime.Remoting.Metadata
System.Runtime.Remoting.Metadata.W3cXsd2001
System.Runtime.Remoting.Proxies
System.Runtime.Remoting.Services
System.Runtime.Versioning
System.Security
System.Security.AccessControl
System.Security.Cryptography
System.Security.Cryptography.X509Certificates
System.Security.Permissions
System.Security.Policy
System.Security.Principal
System.Text
System.Threading
Test
coreclr
corefx
corert
il
legacy
resources
Makefile
System.IO.platformnotsupported.sources
corlib.dll.sources.REMOVED.git-id
corlib_test.dll.sources
corlib_xtest.dll.sources
linux_build_corlib.dll.exclude.sources
linux_build_corlib.dll.sources
linux_net_4_x_corlib.dll.exclude.sources
linux_net_4_x_corlib.dll.sources
macos_build_corlib.dll.exclude.sources
macos_build_corlib.dll.sources
macos_net_4_x_corlib.dll.exclude.sources
macos_net_4_x_corlib.dll.sources
mobile_tests.exclude.sources
monodroid_corlib.dll.exclude.sources
monodroid_corlib.dll.sources
monodroid_corlib_test.dll.exclude.sources
monodroid_corlib_xtest.dll.exclude.sources
monotouch_corlib.dll.exclude.sources
monotouch_corlib.dll.sources
monotouch_corlib_test.dll.exclude.sources
monotouch_corlib_xtest.dll.exclude.sources
monotouch_runtime_corlib.dll.exclude.sources
monotouch_runtime_corlib.dll.sources
monotouch_tv_corlib.dll.exclude.sources
monotouch_tv_corlib.dll.sources
monotouch_tv_corlib_test.dll.exclude.sources
monotouch_tv_corlib_xtest.dll.exclude.sources
monotouch_tv_runtime_corlib.dll.exclude.sources
monotouch_tv_runtime_corlib.dll.sources
monotouch_watch_corlib.dll.exclude.sources
monotouch_watch_corlib.dll.sources
monotouch_watch_corlib_test.dll.exclude.sources
monotouch_watch_corlib_xtest.dll.exclude.sources
monotouch_watch_runtime_corlib.dll.exclude.sources
monotouch_watch_runtime_corlib.dll.sources
net_4_x_corlib.dll.sources
orbis_corlib.dll.exclude.sources
orbis_corlib.dll.sources
orbis_corlib_test.dll.exclude.sources
testing_aot_common_corlib.dll.exclude.sources
testing_aot_common_corlib.dll.sources
testing_aot_common_corlib_test.dll.exclude.sources
testing_aot_full_corlib.dll.exclude.sources
testing_aot_full_corlib.dll.sources
testing_aot_full_corlib_test.dll.exclude.sources
testing_aot_full_interp_corlib.dll.exclude.sources
testing_aot_full_interp_corlib.dll.sources
testing_aot_full_interp_corlib_test.dll.exclude.sources
testing_aot_hybrid_corlib.dll.exclude.sources
testing_aot_hybrid_corlib.dll.sources
testing_aot_hybrid_corlib_test.dll.exclude.sources
unix_build_corlib.dll.exclude.sources
unix_build_corlib.dll.sources
unix_net_4_x_corlib.dll.exclude.sources
unix_net_4_x_corlib.dll.sources
unreal_corlib.dll.exclude.sources
unreal_corlib.dll.sources
wasm_corlib.dll.exclude.sources
wasm_corlib.dll.sources
wasm_corlib_test.dll.exclude.sources
wasm_corlib_xtest.dll.exclude.sources
win32_build_corlib.dll.exclude.sources
win32_build_corlib.dll.sources
win32_monodroid_corlib.dll.exclude.sources
win32_monodroid_corlib.dll.sources
win32_monodroid_corlib_test.dll.exclude.sources
win32_net_4_x_corlib.dll.exclude.sources
win32_net_4_x_corlib.dll.sources
win32_net_4_x_corlib_test.dll.exclude.sources
win32_net_4_x_corlib_test.dll.sources
win32_net_4_x_corlib_xtest.dll.sources
winaot_corlib.dll.exclude.sources
winaot_corlib.dll.sources
winaot_corlib_test.dll.exclude.sources
winaot_corlib_test.dll.sources
xammac_corlib.dll.exclude.sources
xammac_corlib.dll.sources
xammac_corlib_test.dll.exclude.sources
xammac_corlib_xtest.dll.exclude.sources
xammac_net_4_5_corlib.dll.exclude.sources
xammac_net_4_5_corlib.dll.sources
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs

436 lines
8.6 KiB
C#
Raw Normal View History

//
// System.Runtime.Remoting.Messaging.MonoMethodMessage.cs
//
// Author:
// Dietmar Maurer (dietmar@ximian.com)
// Patrik Torstensson
//
// (C) Ximian, Inc. http://www.ximian.com
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Runtime.Remoting.Messaging {
[Serializable]
[StructLayout (LayoutKind.Sequential)]
internal class MonoMethodMessage
#if !DISABLE_REMOTING
: IMethodCallMessage, IMethodReturnMessage, IInternalMessage
#endif
{
#pragma warning disable 649
#region keep in sync with MonoMessage in object-internals.h
RuntimeMethodInfo method;
object [] args;
string [] names;
byte [] arg_types; /* 1 == IN; 2 == OUT; 3 == INOUT; 4 == COPY OUT */
public LogicalCallContext ctx;
public object rval;
public Exception exc;
AsyncResult asyncResult;
CallType call_type;
#endregion
#pragma warning restore 649
string uri;
#if !DISABLE_REMOTING
MCMDictionary properties;
Identity identity;
#endif
Type[] methodSignature;
internal void InitMessage (RuntimeMethodInfo method, object [] out_args)
{
this.method = method;
ParameterInfo[] paramInfo = method.GetParametersInternal ();
int param_count = paramInfo.Length;
args = new object[param_count];
arg_types = new byte[param_count];
asyncResult = null;
call_type = CallType.Sync;
names = new string[param_count];
for (int i = 0; i < param_count; i++) {
names[i] = paramInfo[i].Name;
}
bool hasOutArgs = out_args != null;
int j = 0;
for (int i = 0; i < param_count; i++) {
byte arg_type;
bool isOut = paramInfo[i].IsOut;
if (paramInfo[i].ParameterType.IsByRef) {
if (hasOutArgs)
args[i] = out_args[j++];
arg_type = 2; // OUT
if (!isOut)
arg_type |= 1; // INOUT
} else {
arg_type = 1; // IN
if (isOut)
arg_type |= 4; // IN, COPY OUT
}
arg_types[i] = arg_type;
}
}
public MonoMethodMessage (MethodBase method, object [] out_args)
{
if (method != null)
InitMessage ((RuntimeMethodInfo)method, out_args);
else
args = null;
}
internal MonoMethodMessage (MethodInfo minfo, object [] in_args, object [] out_args)
{
InitMessage ((RuntimeMethodInfo)minfo, out_args);
int len = in_args.Length;
for (int i = 0; i < len; i++) {
args [i] = in_args [i];
}
}
private static MethodInfo GetMethodInfo (Type type, string methodName)
{
// fixme: consider arg types
MethodInfo minfo = type.GetMethod(methodName);
if (minfo == null)
throw new ArgumentException (String.Format("Could not find '{0}' in {1}", methodName, type), "methodName");
return minfo;
}
public MonoMethodMessage (Type type, string methodName, object [] in_args)
: this (GetMethodInfo (type, methodName), in_args, null)
{
}
public IDictionary Properties {
get {
#if DISABLE_REMOTING
throw new PlatformNotSupportedException ();
#else
if (properties == null) properties = new MCMDictionary (this);
return properties;
#endif
}
}
public int ArgCount {
get {
if (CallType == CallType.EndInvoke)
return -1;
if (null == args)
return 0;
return args.Length;
}
}
public object [] Args {
get {
return args;
}
}
public bool HasVarArgs {
get {
return false;
}
}
public LogicalCallContext LogicalCallContext {
get {
return ctx;
}
set {
ctx = value;
}
}
public MethodBase MethodBase {
get {
return method;
}
}
public string MethodName {
get {
if (null == method)
return String.Empty;
return method.Name;
}
}
public object MethodSignature {
get {
if (methodSignature == null) {
ParameterInfo[] parameters = method.GetParameters();
methodSignature = new Type[parameters.Length];
for (int n=0; n<parameters.Length; n++)
methodSignature[n] = parameters[n].ParameterType;
}
return methodSignature;
}
}
public string TypeName {
get {
if (null == method)
return String.Empty;
return method.DeclaringType.AssemblyQualifiedName;
}
}
public string Uri {
get {
return uri;
}
set {
uri = value;
}
}
public object GetArg (int arg_num)
{
if (null == args)
return null;
return args [arg_num];
}
public string GetArgName (int arg_num)
{
if (null == args)
return String.Empty;
return names [arg_num];
}
public int InArgCount {
get {
if (CallType == CallType.EndInvoke)
return -1;
if (null == args)
return 0;
int count = 0;
foreach (byte t in arg_types) {
if ((t & 1) != 0) count++;
}
return count;
}
}
public object [] InArgs {
get {
int i, j, count = InArgCount;
object [] inargs = new object [count];
i = j = 0;
foreach (byte t in arg_types) {
if ((t & 1) != 0)
inargs [j++] = args [i];
i++;
}
return inargs;
}
}
public object GetInArg (int arg_num)
{
int i = 0, j = 0;
foreach (byte t in arg_types) {
if ((t & 1) != 0) {
if (j++ == arg_num)
return args [i];
}
i++;
}
return null;
}
public string GetInArgName (int arg_num)
{
int i = 0, j = 0;
foreach (byte t in arg_types) {
if ((t & 1) != 0) {
if (j++ == arg_num)
return names [i];
}
i++;
}
return null;
}
public Exception Exception {
get {
return exc;
}
}
public int OutArgCount {
get {
if (null == args)
return 0;
int count = 0;
foreach (byte t in arg_types) {
if ((t & 2) != 0) count++;
}
return count;
}
}
public object [] OutArgs {
get {
if (null == args)
return null;
int i, j, count = OutArgCount;
object [] outargs = new object [count];
i = j = 0;
foreach (byte t in arg_types) {
if ((t & 2) != 0)
outargs [j++] = args [i];
i++;
}
return outargs;
}
}
public object ReturnValue {
get {
return rval;
}
}
public object GetOutArg (int arg_num)
{
int i = 0, j = 0;
foreach (byte t in arg_types) {
if ((t & 2) != 0) {
if (j++ == arg_num)
return args [i];
}
i++;
}
return null;
}
public string GetOutArgName (int arg_num)
{
int i = 0, j = 0;
foreach (byte t in arg_types) {
if ((t & 2) != 0) {
if (j++ == arg_num)
return names [i];
}
i++;
}
return null;
}
#if !DISABLE_REMOTING
Identity IInternalMessage.TargetIdentity
{
get { return identity; }
set { identity = value; }
}
bool IInternalMessage.HasProperties()
{
return properties != null;
}
#endif
public bool IsAsync
{
get { return asyncResult != null; }
}
public AsyncResult AsyncResult
{
get { return asyncResult; }
}
internal CallType CallType
{
get
{
// FIXME: ideally, the OneWay type would be set by the runtime
#if !DISABLE_REMOTING
if (call_type == CallType.Sync && RemotingServices.IsOneWay (method))
call_type = CallType.OneWay;
#endif
return call_type;
}
}
public bool NeedsOutProcessing (out int outCount) {
bool res = false;
outCount = 0;
foreach (byte t in arg_types) {
if ((t & 2) != 0)
outCount++;
else if ((t & 4) != 0)
res = true;
}
return outCount > 0 || res;
}
}
internal enum CallType: int
{
Sync = 0,
BeginInvoke = 1,
EndInvoke = 2,
OneWay = 3
}
}