private NameInfo TypeToNameInfo(Type type, WriteObjectInfo objectInfo, PrimitiveTypeEnum code, NameInfo nameInfo)
 {
     if (nameInfo == null)
     {
         nameInfo = this.GetNameInfo();
     }
     else
     {
         nameInfo.Init();
     }
     if ((code == PrimitiveTypeEnum.Invalid) && (objectInfo != null))
     {
         nameInfo.NIname   = objectInfo.GetTypeFullName();
         nameInfo._assemId = objectInfo._assemId;
     }
     nameInfo._primitiveTypeEnum = code;
     nameInfo._type = type;
     return(nameInfo);
 }
        public static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            BinaryTypeEnum stringArray;

            assemId         = 0;
            typeInformation = null;
            if (ReferenceEquals(type, Converter.s_typeofString))
            {
                stringArray = BinaryTypeEnum.String;
            }
            else if ((objectInfo == null || objectInfo != null && !objectInfo._isSi) && ReferenceEquals(type, Converter.s_typeofObject))
            {
                stringArray = BinaryTypeEnum.Object;
            }
            else if (ReferenceEquals(type, Converter.s_typeofStringArray))
            {
                stringArray = BinaryTypeEnum.StringArray;
            }
            else if (ReferenceEquals(type, Converter.s_typeofObjectArray))
            {
                stringArray = BinaryTypeEnum.ObjectArray;
            }
            else if (Converter.IsPrimitiveArray(type, out PrimitiveTypeEnum primitive))
            {
                typeInformation = primitive;
                stringArray     = BinaryTypeEnum.PrimitiveArray;
            }
            else
            {
                PrimitiveTypeEnum ee = objectWriter.ToCode(type);
                if (ee != PrimitiveTypeEnum.Invalid)
                {
                    stringArray     = BinaryTypeEnum.Primitive;
                    typeInformation = ee;
                }
                else
                {
                    string fullName;
                    if (objectInfo == null)
                    {
                        fullName        = type.Assembly.FullName;
                        typeInformation = type.FullName;
                    }
                    else
                    {
                        fullName        = objectInfo.GetAssemblyString();
                        typeInformation = objectInfo.GetTypeFullName();
                    }
                    if (fullName.Equals(Converter.s_urtAssemblyString) || fullName.Equals(Converter.s_urtAlternativeAssemblyString))
                    {
                        stringArray = BinaryTypeEnum.ObjectUrt;
                        assemId     = 0;
                    }
                    else
                    {
                        stringArray = BinaryTypeEnum.ObjectUser;
                        assemId     = (int)objectInfo._assemId;
                        if (assemId == 0)
                        {
                            throw new SerializationException(RemotingResources.SerializationAssemblyId.Format(typeInformation));
                        }
                    }
                }
            }
            return(stringArray);
        }