We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
- namespace System.Runtime.Remoting.Metadata
- {
- using System.Runtime.Remoting.Messaging;
- using System.Runtime.Remoting.Metadata;
- using System.Reflection;
- using System.Threading;
-
-
-
- internal class RemotingCachedData
- {
- protected object RI;
-
- private SoapAttribute _soapAttr = null;
-
-
- internal RemotingCachedData(object ri)
- {
- RI = ri;
- }
-
-
-
- internal SoapAttribute GetSoapAttribute()
- {
- if (_soapAttr == null) {
- lock (this) {
- if (_soapAttr == null) {
- SoapAttribute tempSoapAttr = null;
-
- ICustomAttributeProvider cap = (ICustomAttributeProvider)RI;
-
- if (RI is Type) {
- object[] attrs = cap.GetCustomAttributes(typeof(SoapTypeAttribute), true);
- if ((attrs != null) && (attrs.Length != 0))
- tempSoapAttr = (SoapAttribute)attrs[0];
- else
- tempSoapAttr = new SoapTypeAttribute();
- }
- else if (RI is MethodBase) {
- object[] attrs = cap.GetCustomAttributes(typeof(SoapMethodAttribute), true);
- if ((attrs != null) && (attrs.Length != 0))
- tempSoapAttr = (SoapAttribute)attrs[0];
- else
- tempSoapAttr = new SoapMethodAttribute();
- }
- else if (RI is FieldInfo) {
- object[] attrs = cap.GetCustomAttributes(typeof(SoapFieldAttribute), false);
- if ((attrs != null) && (attrs.Length != 0))
- tempSoapAttr = (SoapAttribute)attrs[0];
- else
- tempSoapAttr = new SoapFieldAttribute();
- }
- else if (RI is ParameterInfo) {
- object[] attrs = cap.GetCustomAttributes(typeof(SoapParameterAttribute), true);
- if ((attrs != null) && (attrs.Length != 0))
- tempSoapAttr = (SoapParameterAttribute)attrs[0];
- else
- tempSoapAttr = new SoapParameterAttribute();
- }
-
-
-
- tempSoapAttr.SetReflectInfo(RI);
-
- _soapAttr = tempSoapAttr;
- }
-
- }
-
- }
-
- return _soapAttr;
- }
-
-
- }
-
-
-
- internal class RemotingTypeCachedData : RemotingCachedData
- {
-
- private class LastCalledMethodClass
- {
- public string methodName;
- public MethodBase MB;
- }
-
- private LastCalledMethodClass _lastMethodCalled;
-
- private TypeInfo _typeInfo;
-
- private string _qualifiedTypeName;
- private string _assemblyName;
- private string _simpleAssemblyName;
-
-
- internal RemotingTypeCachedData(object ri) : base(ri)
- {
- _lastMethodCalled = null;
- }
-
- internal MethodBase GetLastCalledMethod(string newMeth)
- {
- LastCalledMethodClass lastMeth = _lastMethodCalled;
- if (lastMeth == null)
- return null;
-
- string methodName = lastMeth.methodName;
- MethodBase mbToReturn = lastMeth.MB;
-
- if (mbToReturn == null || methodName == null)
- return null;
-
- if (methodName.Equals(newMeth))
- return mbToReturn;
-
- return null;
- }
-
- internal void SetLastCalledMethod(string newMethName, MethodBase newMB)
- {
- LastCalledMethodClass lastMeth = new LastCalledMethodClass();
- lastMeth.methodName = newMethName;
- lastMeth.MB = newMB;
-
- _lastMethodCalled = lastMeth;
- }
-
-
-
- internal TypeInfo TypeInfo {
- get {
- if (_typeInfo == null)
- _typeInfo = new TypeInfo((Type)RI);
-
- return _typeInfo;
- }
- }
-
-
- internal string QualifiedTypeName {
- get {
- if (_qualifiedTypeName == null)
- _qualifiedTypeName = RemotingServices.DetermineDefaultQualifiedTypeName((Type)RI);
-
- return _qualifiedTypeName;
- }
- }
-
-
- internal string AssemblyName {
- get {
- if (_assemblyName == null)
- _assemblyName = ((Type)RI).Module.Assembly.FullName;
-
- return _assemblyName;
- }
- }
-
-
- internal string SimpleAssemblyName {
- get {
- if (_simpleAssemblyName == null)
- _simpleAssemblyName = ((Type)RI).Module.Assembly.nGetSimpleName();
-
- return _simpleAssemblyName;
- }
- }
-
-
- }
-
-
-
- internal class RemotingMethodCachedData : RemotingCachedData
- {
- ParameterInfo[] _parameters = null;
-
-
- [Flags(), Serializable()]
- private enum MethodCacheFlags
- {
- None = 0,
- CheckedOneWay = 1,
-
- IsOneWay = 2,
-
- CheckedOverloaded = 4,
-
- IsOverloaded = 8,
-
- CheckedForAsync = 16,
-
- CheckedForReturnType = 32
-
- }
-
- MethodCacheFlags flags;
-
-
- string _typeAndAssemblyName = null;
- string _methodName = null;
- Type _returnType = null;
-
-
-
-
-
- int[] _inRefArgMap = null;
-
- int[] _outRefArgMap = null;
-
- int[] _outOnlyArgMap = null;
-
- int[] _nonRefOutArgMap = null;
-
- int[] _marshalRequestMap = null;
-
- int[] _marshalResponseMap = null;
-
- internal RemotingMethodCachedData(object ri) : base(ri)
- {
- }
-
- internal string TypeAndAssemblyName {
- get {
- if (_typeAndAssemblyName == null)
- UpdateNames();
- return _typeAndAssemblyName;
- }
- }
-
- internal string MethodName {
- get {
- if (_methodName == null)
- UpdateNames();
- return _methodName;
- }
- }
-
- private void UpdateNames()
- {
- MethodBase mb = (MethodBase)RI;
- _methodName = mb.Name;
- if (mb.DeclaringType != null) {
- _typeAndAssemblyName = RemotingServices.GetDefaultQualifiedTypeName(mb.DeclaringType);
- }
- }
-
- internal ParameterInfo[] Parameters {
- get {
- if (_parameters == null)
- _parameters = ((MethodBase)RI).GetParameters();
- return _parameters;
- }
- }
-
-
-
- internal int[] OutRefArgMap {
- get {
- if (_outRefArgMap == null)
- GetArgMaps();
- return _outRefArgMap;
- }
- }
-
-
- internal int[] OutOnlyArgMap {
- get {
- if (_outOnlyArgMap == null)
- GetArgMaps();
- return _outOnlyArgMap;
- }
- }
-
-
- internal int[] NonRefOutArgMap {
- get {
- if (_nonRefOutArgMap == null)
- GetArgMaps();
- return _nonRefOutArgMap;
- }
- }
-
-
- internal int[] MarshalRequestArgMap {
- get {
- if (_marshalRequestMap == null)
- GetArgMaps();
- return _marshalRequestMap;
- }
- }
-
-
- internal int[] MarshalResponseArgMap {
- get {
- if (_marshalResponseMap == null)
- GetArgMaps();
- return _marshalResponseMap;
- }
- }
-
-
- private void GetArgMaps()
- {
- lock (this) {
- if (_inRefArgMap == null) {
- int[] inRefArgMap = null;
- int[] outRefArgMap = null;
- int[] outOnlyArgMap = null;
- int[] nonRefOutArgMap = null;
- int[] marshalRequestMap = null;
- int[] marshalResponseMap = null;
-
- ArgMapper.GetParameterMaps(Parameters, out inRefArgMap, out outRefArgMap, out outOnlyArgMap, out nonRefOutArgMap, out marshalRequestMap, out marshalResponseMap);
-
- _inRefArgMap = inRefArgMap;
- _outRefArgMap = outRefArgMap;
- _outOnlyArgMap = outOnlyArgMap;
- _nonRefOutArgMap = nonRefOutArgMap;
- _marshalRequestMap = marshalRequestMap;
- _marshalResponseMap = marshalResponseMap;
-
- }
- }
- }
-
- internal bool IsOneWayMethod()
- {
-
-
-
-
-
- if ((flags & MethodCacheFlags.CheckedOneWay) == 0) {
- MethodCacheFlags isOneWay = MethodCacheFlags.CheckedOneWay;
- object[] attrs = ((ICustomAttributeProvider)RI).GetCustomAttributes(typeof(OneWayAttribute), true);
-
- if ((attrs != null) && (attrs.Length > 0))
- isOneWay |= MethodCacheFlags.IsOneWay;
-
- flags |= isOneWay;
- return (isOneWay & MethodCacheFlags.IsOneWay) != 0;
- }
- return (flags & MethodCacheFlags.IsOneWay) != 0;
- }
-
- internal bool IsOverloaded()
- {
-
-
-
-
-
- if ((flags & MethodCacheFlags.CheckedOverloaded) == 0) {
- MethodCacheFlags isOverloaded = MethodCacheFlags.CheckedOverloaded;
- MethodBase mb = (MethodBase)RI;
-
- if (mb.IsOverloaded)
- isOverloaded |= MethodCacheFlags.IsOverloaded;
- flags |= isOverloaded;
- return (isOverloaded & MethodCacheFlags.IsOverloaded) != 0;
- }
- return (flags & MethodCacheFlags.IsOverloaded) != 0;
- }
-
-
-
-
- internal Type ReturnType {
- get {
- if ((flags & MethodCacheFlags.CheckedForReturnType) == 0) {
- MethodInfo mi = RI as MethodInfo;
- if (mi != null) {
- Type returnType = mi.ReturnType;
- if (returnType != typeof(void))
- _returnType = returnType;
- }
-
- flags |= MethodCacheFlags.CheckedForReturnType;
- }
-
- return _returnType;
- }
- }
-
-
- }
-
-
-
-
-
-
-
- [Flags(), Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum SoapOption
- {
- None = 0,
- AlwaysIncludeTypes = 1,
-
- XsdString = 2,
-
- EmbedAll = 4,
-
- /// <internalonly/>
- Option1 = 8,
-
- /// <internalonly/>
- Option2 = 16
-
- }
-
- /// <internalonly/>
- [Serializable()]
- [System.Runtime.InteropServices.ComVisible(true)]
- public enum XmlFieldOrderOption
- {
- All,
- Sequence,
- Choice
- }
-
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SoapTypeAttribute : SoapAttribute
- {
-
-
- [Flags(), Serializable()]
- private enum ExplicitlySet
- {
- None = 0,
- XmlElementName = 1,
- XmlNamespace = 2,
- XmlTypeName = 4,
- XmlTypeNamespace = 8
- }
-
- private ExplicitlySet _explicitlySet = ExplicitlySet.None;
-
- private SoapOption _SoapOptions = SoapOption.None;
- private string _XmlElementName = null;
- private string _XmlTypeName = null;
- private string _XmlTypeNamespace = null;
- private XmlFieldOrderOption _XmlFieldOrder = XmlFieldOrderOption.All;
-
-
-
- internal bool IsInteropXmlElement()
- {
- return (_explicitlySet & (ExplicitlySet.XmlElementName | ExplicitlySet.XmlNamespace)) != 0;
- }
-
- internal bool IsInteropXmlType()
- {
- return (_explicitlySet & (ExplicitlySet.XmlTypeName | ExplicitlySet.XmlTypeNamespace)) != 0;
- }
-
-
-
- public SoapOption SoapOptions {
- get { return _SoapOptions; }
- set { _SoapOptions = value; }
- }
-
- public string XmlElementName {
- get {
-
- if ((_XmlElementName == null) && (ReflectInfo != null))
- _XmlElementName = GetTypeName((Type)ReflectInfo);
- return _XmlElementName;
- }
-
- set {
- _XmlElementName = value;
- _explicitlySet |= ExplicitlySet.XmlElementName;
- }
- }
-
- public override string XmlNamespace {
- get {
-
- if ((ProtXmlNamespace == null) && (ReflectInfo != null)) {
- ProtXmlNamespace = XmlTypeNamespace;
- }
- return ProtXmlNamespace;
- }
-
- set {
- ProtXmlNamespace = value;
- _explicitlySet |= ExplicitlySet.XmlNamespace;
- }
- }
-
- public string XmlTypeName {
-
- get {
-
- if ((_XmlTypeName == null) && (ReflectInfo != null))
- _XmlTypeName = GetTypeName((Type)ReflectInfo);
- return _XmlTypeName;
- }
-
- set {
- _XmlTypeName = value;
- _explicitlySet |= ExplicitlySet.XmlTypeName;
- }
- }
-
- public string XmlTypeNamespace {
-
- get {
-
- if ((_XmlTypeNamespace == null) && (ReflectInfo != null)) {
- _XmlTypeNamespace = XmlNamespaceEncoder.GetXmlNamespaceForTypeNamespace((Type)ReflectInfo, null);
- }
- return _XmlTypeNamespace;
- }
-
- set {
- _XmlTypeNamespace = value;
- _explicitlySet |= ExplicitlySet.XmlTypeNamespace;
- }
- }
-
- /// <internalonly/>
- public XmlFieldOrderOption XmlFieldOrder {
- get { return _XmlFieldOrder; }
- set { _XmlFieldOrder = value; }
- }
-
- public override bool UseAttribute {
- get { return false; }
- set {
- throw new RemotingException(Environment.GetResourceString("Remoting_Attribute_UseAttributeNotsettable"));
- }
- }
-
- private static string GetTypeName(Type t)
- {
- if (t.IsNested) {
- string name = t.FullName;
- string ns = t.Namespace;
- if (ns == null || ns.Length == 0) {
- return name;
- }
- else {
- name = name.Substring(ns.Length + 1);
- return name;
- }
- }
- return t.Name;
- }
-
- }
-
-
- [AttributeUsage(AttributeTargets.Method)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SoapMethodAttribute : SoapAttribute
- {
- private string _SoapAction = null;
-
- private string _responseXmlElementName = null;
- private string _responseXmlNamespace = null;
- private string _returnXmlElementName = null;
-
- private bool _bSoapActionExplicitySet = false;
-
-
-
-
- internal bool SoapActionExplicitySet {
- get { return _bSoapActionExplicitySet; }
- }
-
- public string SoapAction {
-
- get {
-
- if (_SoapAction == null) {
- _SoapAction = XmlTypeNamespaceOfDeclaringType + "#" + ((MemberInfo)ReflectInfo).Name;
-
- }
- return _SoapAction;
- }
-
- set {
- _SoapAction = value;
- _bSoapActionExplicitySet = true;
- }
- }
-
- public override bool UseAttribute {
- get { return false; }
- set {
- throw new RemotingException(Environment.GetResourceString("Remoting_Attribute_UseAttributeNotsettable"));
- }
- }
-
- public override string XmlNamespace {
- get {
-
- if (ProtXmlNamespace == null) {
- ProtXmlNamespace = XmlTypeNamespaceOfDeclaringType;
- }
- return ProtXmlNamespace;
- }
-
- set { ProtXmlNamespace = value; }
- }
-
-
- public string ResponseXmlElementName {
- get {
-
- if ((_responseXmlElementName == null) && (ReflectInfo != null))
- _responseXmlElementName = ((MemberInfo)ReflectInfo).Name + "Response";
- return _responseXmlElementName;
- }
-
- set { _responseXmlElementName = value; }
- }
-
-
- public string ResponseXmlNamespace {
- get {
-
- if (_responseXmlNamespace == null)
- _responseXmlNamespace = XmlNamespace;
- return _responseXmlNamespace;
- }
-
- set { _responseXmlNamespace = value; }
- }
-
-
- public string ReturnXmlElementName {
- get {
-
- if (_returnXmlElementName == null)
- _returnXmlElementName = "return";
- return _returnXmlElementName;
- }
-
- set { _returnXmlElementName = value; }
- }
-
-
- private string XmlTypeNamespaceOfDeclaringType {
- get {
- if (ReflectInfo != null) {
- Type declaringType = ((MemberInfo)ReflectInfo).DeclaringType;
- return XmlNamespaceEncoder.GetXmlNamespaceForType(declaringType, null);
- }
- else
- return null;
- }
- }
-
- }
-
-
- [AttributeUsage(AttributeTargets.Field)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SoapFieldAttribute : SoapAttribute
- {
-
-
- [Flags(), Serializable()]
- private enum ExplicitlySet
- {
- None = 0,
- XmlElementName = 1
- }
-
- private ExplicitlySet _explicitlySet = ExplicitlySet.None;
-
-
- private string _xmlElementName = null;
- private int _order;
-
-
-
-
- public bool IsInteropXmlElement()
- {
- return (_explicitlySet & ExplicitlySet.XmlElementName) != 0;
- }
-
-
- public string XmlElementName {
- get {
-
- if ((_xmlElementName == null) && (ReflectInfo != null))
- _xmlElementName = ((FieldInfo)ReflectInfo).Name;
- return _xmlElementName;
- }
-
- set {
- _xmlElementName = value;
- _explicitlySet |= ExplicitlySet.XmlElementName;
- }
- }
-
-
- /// <internalonly/>
- public int Order {
- get { return _order; }
- set { _order = value; }
- }
-
- }
-
-
- [AttributeUsage(AttributeTargets.Parameter)]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class SoapParameterAttribute : SoapAttribute
- {
- }
-
-
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public class SoapAttribute : Attribute
- {
- /// <internalonly/>
- protected string ProtXmlNamespace = null;
- private bool _bUseAttribute = false;
- private bool _bEmbedded = false;
-
- /// <internalonly/>
- protected object ReflectInfo = null;
-
-
-
-
- internal void SetReflectInfo(object info)
- {
- ReflectInfo = info;
- }
-
- public virtual string XmlNamespace {
-
- get { return ProtXmlNamespace; }
- set { ProtXmlNamespace = value; }
- }
-
- public virtual bool UseAttribute {
- get { return _bUseAttribute; }
- set { _bUseAttribute = value; }
- }
-
- public virtual bool Embedded {
-
- get { return _bEmbedded; }
- set { _bEmbedded = value; }
- }
-
- }
-
-
-
-
-
-
-
- }