System.MarshalByRefObject.CanCastToXmlTypeHelper C# (CSharp) Method

CanCastToXmlTypeHelper() static private method

static private CanCastToXmlTypeHelper ( Type castType, MarshalByRefObject o ) : bool
castType Type
o MarshalByRefObject
return bool
        internal static bool CanCastToXmlTypeHelper(Type castType, MarshalByRefObject o)
        {
            if (castType == null)
                throw new ArgumentNullException("castType");
        
            // MarshalByRefObject's can only be casted to MarshalByRefObject's or interfaces.
            if (!castType.IsInterface && !castType.IsMarshalByRef)
                return false;

            // figure out xml type name
            String xmlTypeName = null;
            String xmlTypeNamespace = null;
            if (!SoapServices.GetXmlTypeForInteropType(castType, out xmlTypeName, out xmlTypeNamespace))
            {
                // There's no registered interop type name, so just use the default.
                xmlTypeName = castType.Name;
                xmlTypeNamespace =
                    SoapServices.CodeXmlNamespaceForClrTypeNamespace(
                        castType.Namespace, castType.Module.Assembly.nGetSimpleName());
            }

            return o.CanCastToXmlType(xmlTypeName, xmlTypeNamespace);
        } // CanCastToXmlType