BindToName() public méthode

public BindToName ( System serializedType, string &assemblyName, string &typeName ) : void
serializedType System
assemblyName string
typeName string
Résultat void
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, Type dataContractType, SerializationBinder binder, SerializationInfo serInfo)
        {
            TypeInformation typeInformation = null;
            string          typeName        = null;
            string          assemblyName    = null;

            if (binder != null)
            {
                binder.BindToName(dataContractType, out assemblyName, out typeName);
            }
            if (typeName == null)
            {
                if (serInfo.IsFullTypeNameSetExplicit)
                {
                    typeName = serInfo.FullTypeName;
                }
                else
                {
                    typeInformation = GetTypeInformation(serInfo.ObjectType);
                    typeName        = typeInformation.FullTypeName;
                }
            }
            if (assemblyName == null)
            {
                if (serInfo.IsAssemblyNameSetExplicit)
                {
                    assemblyName = serInfo.AssemblyName;
                }
                else
                {
                    assemblyName = (typeInformation == null) ? GetTypeInformation(serInfo.ObjectType).AssemblyString : typeInformation.AssemblyString;
                }
            }
            WriteClrTypeInfo(writer, typeName, assemblyName);
        }
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, Type dataContractType, SerializationBinder binder, string defaultClrTypeName, string defaultClrAssemblyName)
        {
            string typeName     = null;
            string assemblyName = null;

            if (binder != null)
            {
                binder.BindToName(dataContractType, out assemblyName, out typeName);
            }
            if (typeName == null)
            {
                typeName = defaultClrTypeName;
            }
            if (assemblyName == null)
            {
                assemblyName = defaultClrAssemblyName;
            }
            WriteClrTypeInfo(writer, typeName, assemblyName);
        }
 internal static void WriteClrTypeInfo(XmlWriterDelegator writer, DataContract dataContract, SerializationBinder binder)
 {
     if (!dataContract.IsISerializable && !(dataContract is SurrogateDataContract))
     {
         TypeInformation typeInformation = null;
         string          typeName        = null;
         string          assemblyName    = null;
         if (binder != null)
         {
             binder.BindToName(dataContract.OriginalUnderlyingType, out assemblyName, out typeName);
         }
         if (typeName == null)
         {
             typeInformation = GetTypeInformation(dataContract.OriginalUnderlyingType);
             typeName        = typeInformation.FullTypeName;
         }
         if (assemblyName == null)
         {
             assemblyName = (typeInformation == null) ? GetTypeInformation(dataContract.OriginalUnderlyingType).AssemblyString : typeInformation.AssemblyString;
         }
         WriteClrTypeInfo(writer, typeName, assemblyName);
     }
 }
        // Update the overloads whenever you are changing this method
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, DataContract dataContract, SerializationBinder binder)
        {
            if (!dataContract.IsISerializable && !(dataContract is SurrogateDataContract))
            {
                TypeInformation typeInformation = null;
                Type            clrType         = dataContract.OriginalUnderlyingType;
                string          clrTypeName     = null;
                string          clrAssemblyName = null;

                if (binder != null)
                {
                    binder.BindToName(clrType, out clrAssemblyName, out clrTypeName);
                }

                if (clrTypeName == null)
                {
                    typeInformation = NetDataContractSerializer.GetTypeInformation(clrType);
                    clrTypeName     = typeInformation.FullTypeName;
                }

                if (clrAssemblyName == null)
                {
                    clrAssemblyName = (typeInformation == null) ?
                                      NetDataContractSerializer.GetTypeInformation(clrType).AssemblyString :
                                      typeInformation.AssemblyString;

                    // Throw in the [TypeForwardedFrom] case to prevent a partially trusted assembly from forwarding itself to an assembly with higher privileges
                    if (!UnsafeTypeForwardingEnabled && !clrType.Assembly.IsFullyTrusted && !IsAssemblyNameForwardingSafe(clrType.Assembly.FullName, clrAssemblyName))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.TypeCannotBeForwardedFrom, DataContract.GetClrTypeFullName(clrType), clrType.Assembly.FullName, clrAssemblyName)));
                    }
                }

                WriteClrTypeInfo(writer, clrTypeName, clrAssemblyName);
            }
        }
Exemple #5
0
        // Update the overloads whenever you are changing this method
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, Type dataContractType, SerializationBinder binder, SerializationInfo serInfo)
        {
            TypeInformation typeInformation = null;
            string clrTypeName = null;
            string clrAssemblyName = null;

            if (binder != null)
            {
                binder.BindToName(dataContractType, out clrAssemblyName, out clrTypeName);
            }

            if (clrTypeName == null)
            {
                if (serInfo.IsFullTypeNameSetExplicit)
                {
                    clrTypeName = serInfo.FullTypeName;
                }
                else
                {
                    typeInformation = NetDataContractSerializer.GetTypeInformation(serInfo.ObjectType);
                    clrTypeName = typeInformation.FullTypeName;
                }
            }

            if (clrAssemblyName == null)
            {
                if (serInfo.IsAssemblyNameSetExplicit)
                {
                    clrAssemblyName = serInfo.AssemblyName;
                }
                else
                {
                    clrAssemblyName = (typeInformation == null) ?
                    NetDataContractSerializer.GetTypeInformation(serInfo.ObjectType).AssemblyString :
                    typeInformation.AssemblyString;
                }
            }

            WriteClrTypeInfo(writer, clrTypeName, clrAssemblyName);
        }
Exemple #6
0
        // Update the overloads whenever you are changing this method
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, Type dataContractType, SerializationBinder binder, string defaultClrTypeName, string defaultClrAssemblyName)
        {
            string clrTypeName = null;
            string clrAssemblyName = null;

            if (binder != null)
            {
                binder.BindToName(dataContractType, out clrAssemblyName, out clrTypeName);
            }

            if (clrTypeName == null)
            {
                clrTypeName = defaultClrTypeName;
            }

            if (clrAssemblyName == null)
            {
                clrAssemblyName = defaultClrAssemblyName;
            }

            WriteClrTypeInfo(writer, clrTypeName, clrAssemblyName);
        }
Exemple #7
0
        // Update the overloads whenever you are changing this method
        internal static void WriteClrTypeInfo(XmlWriterDelegator writer, DataContract dataContract, SerializationBinder binder)
        {
            if (!dataContract.IsISerializable && !(dataContract is SurrogateDataContract))
            {
                TypeInformation typeInformation = null;
                Type clrType = dataContract.OriginalUnderlyingType;
                string clrTypeName = null;
                string clrAssemblyName = null;

                if (binder != null)
                {
                    binder.BindToName(clrType, out clrAssemblyName, out clrTypeName);
                }

                if (clrTypeName == null)
                {
                    typeInformation = NetDataContractSerializer.GetTypeInformation(clrType);
                    clrTypeName = typeInformation.FullTypeName;
                }

                if (clrAssemblyName == null)
                {
                    clrAssemblyName = (typeInformation == null) ?
                        NetDataContractSerializer.GetTypeInformation(clrType).AssemblyString :
                        typeInformation.AssemblyString;

                    // Throw in the [TypeForwardedFrom] case to prevent a partially trusted assembly from forwarding itself to an assembly with higher privileges
                    if (!UnsafeTypeForwardingEnabled && !clrType.Assembly.IsFullyTrusted && !IsAssemblyNameForwardingSafe(clrType.Assembly.FullName, clrAssemblyName))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.TypeCannotBeForwardedFrom, DataContract.GetClrTypeFullName(clrType), clrType.Assembly.FullName, clrAssemblyName)));
                    }
                }

                WriteClrTypeInfo(writer, clrTypeName, clrAssemblyName);
            }
        }
 private void InvokeSerializationBinder(SerializationBinder binder)
 {
     if (binder != null)
     {
         binder.BindToName(objectType, out binderAssemblyString, out binderTypeName);
     }
 }
Exemple #9
0
        /// <summary>
        /// Write a type value to the binary writer.
        /// </summary>
        /// <param name="binaryWriter">
        /// The binary writer.
        /// </param> 
        /// <param name="type">
        /// The type.
        /// </param>
        /// <param name="binder">
        /// The serialization binder.
        /// </param>
        private static void WriteType(BinaryWriter binaryWriter, Type type, SerializationBinder binder)
        {
            var tuple = TypeNameCache.GetOrAdd(
                type,
                _ =>
                {
                    string assemblyName;
                    string typeName;
                    binder.BindToName(type, out assemblyName, out typeName);
                    return new Tuple<string, string>(assemblyName, typeName);
                });

            binaryWriter.Write(tuple.Item1);
            binaryWriter.Write(tuple.Item2);
        }
 internal static void WriteClrTypeInfo(XmlWriterDelegator writer, DataContract dataContract, SerializationBinder binder)
 {
     if (!dataContract.IsISerializable && !(dataContract is SurrogateDataContract))
     {
         TypeInformation typeInformation = null;
         string typeName = null;
         string assemblyName = null;
         if (binder != null)
         {
             binder.BindToName(dataContract.OriginalUnderlyingType, out assemblyName, out typeName);
         }
         if (typeName == null)
         {
             typeInformation = GetTypeInformation(dataContract.OriginalUnderlyingType);
             typeName = typeInformation.FullTypeName;
         }
         if (assemblyName == null)
         {
             assemblyName = (typeInformation == null) ? GetTypeInformation(dataContract.OriginalUnderlyingType).AssemblyString : typeInformation.AssemblyString;
         }
         WriteClrTypeInfo(writer, typeName, assemblyName);
     }
 }