private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            if (this._assemblyToIdTable == null)
            {
                this._assemblyToIdTable = new Dictionary <string, long>();
            }

            string assemblyString = objectInfo.GetAssemblyString();
            string str2           = assemblyString;
            long   num;

            if (assemblyString.Length == 0)
            {
                num = 0L;
            }
            else if (assemblyString.Equals(Converter.s_urtAssemblyString) || assemblyString.Equals(Converter.s_urtAlternativeAssemblyString))
            {
                num = 0L;
            }
            else
            {
                bool isNew;
                if (this._assemblyToIdTable.TryGetValue(assemblyString, out num))
                {
                    isNew = false;
                }
                else
                {
                    num = this.InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
                    this._assemblyToIdTable[assemblyString] = num;
                }
                this._serWriter.WriteAssembly(str2, (int)num, isNew);
            }
            return(num);
        }
        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);
        }