GetAssemblyString() private method

private GetAssemblyString ( ) : string
return string
コード例 #1
0
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            if (this.assemblyToIdTable == null)
            {
                this.assemblyToIdTable = new Hashtable(5);
            }
            long   num            = 0L;
            bool   isNew          = false;
            string assemblyString = objectInfo.GetAssemblyString();
            string str2           = assemblyString;

            if (assemblyString.Length == 0)
            {
                return(0L);
            }
            if (assemblyString.Equals(Converter.urtAssemblyString))
            {
                return(0L);
            }
            if (this.assemblyToIdTable.ContainsKey(assemblyString))
            {
                num   = (long)this.assemblyToIdTable[assemblyString];
                isNew = false;
            }
            else
            {
                num = this.InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
                this.assemblyToIdTable[assemblyString] = num;
            }
            this.serWriter.WriteAssembly(objectInfo.objectType, str2, (int)num, isNew);
            return(num);
        }
 internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
 {
     BinaryTypeEnum primitive;
     assemId = 0;
     typeInformation = null;
     if (object.ReferenceEquals(type, Converter.typeofString))
     {
         return BinaryTypeEnum.String;
     }
     if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi)) && object.ReferenceEquals(type, Converter.typeofObject))
     {
         return BinaryTypeEnum.Object;
     }
     if (object.ReferenceEquals(type, Converter.typeofStringArray))
     {
         return BinaryTypeEnum.StringArray;
     }
     if (object.ReferenceEquals(type, Converter.typeofObjectArray))
     {
         return BinaryTypeEnum.ObjectArray;
     }
     if (Converter.IsPrimitiveArray(type, out typeInformation))
     {
         return BinaryTypeEnum.PrimitiveArray;
     }
     InternalPrimitiveTypeE ee = objectWriter.ToCode(type);
     switch (ee)
     {
         case InternalPrimitiveTypeE.Invalid:
         {
             string fullName = null;
             if (objectInfo == null)
             {
                 fullName = type.Assembly.FullName;
                 typeInformation = type.FullName;
             }
             else
             {
                 fullName = objectInfo.GetAssemblyString();
                 typeInformation = objectInfo.GetTypeFullName();
             }
             if (fullName.Equals(Converter.urtAssemblyString))
             {
                 primitive = BinaryTypeEnum.ObjectUrt;
                 assemId = 0;
                 return primitive;
             }
             primitive = BinaryTypeEnum.ObjectUser;
             assemId = (int) objectInfo.assemId;
             if (assemId == 0)
             {
                 throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { typeInformation }));
             }
             return primitive;
         }
     }
     primitive = BinaryTypeEnum.Primitive;
     typeInformation = ee;
     return primitive;
 }
コード例 #3
0
 private long GetAssemblyId(WriteObjectInfo objectInfo)
 {
     if (this.assemblyToIdTable == null)
     {
         this.assemblyToIdTable = new Hashtable(5);
     }
     long num = 0L;
     bool isNew = false;
     string assemblyString = objectInfo.GetAssemblyString();
     string str2 = assemblyString;
     if (assemblyString.Length == 0)
     {
         return 0L;
     }
     if (assemblyString.Equals(Converter.urtAssemblyString))
     {
         return 0L;
     }
     if (this.assemblyToIdTable.ContainsKey(assemblyString))
     {
         num = (long) this.assemblyToIdTable[assemblyString];
         isNew = false;
     }
     else
     {
         num = this.InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
         this.assemblyToIdTable[assemblyString] = num;
     }
     this.serWriter.WriteAssembly(objectInfo.objectType, str2, (int) num, isNew);
     return num;
 }
コード例 #4
0
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            if (this.assemblyToIdTable == null)
            {
                this.assemblyToIdTable = new Hashtable(5);
            }
            bool   isNew           = false;
            string assemblyString1 = objectInfo.GetAssemblyString();
            string assemblyString2 = assemblyString1;
            long   num;

            if (assemblyString1.Length == 0)
            {
                num = 0L;
            }
            else if (assemblyString1.Equals(Converter.urtAssemblyString))
            {
                num = 0L;
            }
            else
            {
                if (this.assemblyToIdTable.ContainsKey((object)assemblyString1))
                {
                    num   = (long)this.assemblyToIdTable[(object)assemblyString1];
                    isNew = false;
                }
                else
                {
                    num = this.InternalGetId((object)("___AssemblyString___" + assemblyString1), false, (Type)null, out isNew);
                    this.assemblyToIdTable[(object)assemblyString1] = (object)num;
                }
                this.serWriter.WriteAssembly(objectInfo.objectType, assemblyString2, (int)num, isNew);
            }
            return(num);
        }
コード例 #5
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE nameSpaceEnum = InternalNameSpaceE.None;

            typeName = null;

            if (code != InternalPrimitiveTypeE.Invalid)
            {
                switch (code)
                {
                case InternalPrimitiveTypeE.Boolean:
                case InternalPrimitiveTypeE.Char:
                case InternalPrimitiveTypeE.Byte:
                case InternalPrimitiveTypeE.Double:
                case InternalPrimitiveTypeE.Int16:
                case InternalPrimitiveTypeE.Int32:
                case InternalPrimitiveTypeE.Int64:
                case InternalPrimitiveTypeE.SByte:
                case InternalPrimitiveTypeE.Single:
                case InternalPrimitiveTypeE.UInt16:
                case InternalPrimitiveTypeE.UInt32:
                case InternalPrimitiveTypeE.UInt64:
                case InternalPrimitiveTypeE.DateTime:
                case InternalPrimitiveTypeE.TimeSpan:
                    nameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                    typeName      = "System." + ToComType(code);
                    break;

                case InternalPrimitiveTypeE.Decimal:
                    nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                    typeName      = "System." + ToComType(code);
                    break;
                }
            }

            if ((nameSpaceEnum == InternalNameSpaceE.None) && type != null)
            {
                if (ReferenceEquals(type, s_typeofString))
                {
                    nameSpaceEnum = InternalNameSpaceE.XdrString;
                }
                else
                {
                    if (objectInfo == null)
                    {
                        typeName      = type.FullName;
                        nameSpaceEnum = type.Assembly == s_urtAssembly ? InternalNameSpaceE.UrtSystem : InternalNameSpaceE.UrtUser;
                    }
                    else
                    {
                        typeName      = objectInfo.GetTypeFullName();
                        nameSpaceEnum = objectInfo.GetAssemblyString().Equals(s_urtAssemblyString) ? InternalNameSpaceE.UrtSystem : InternalNameSpaceE.UrtUser;
                    }
                }
            }

            return(nameSpaceEnum);
        }
コード例 #6
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE none = InternalNameSpaceE.None;

            typeName = null;
            switch (code)
            {
            case InternalPrimitiveTypeE.Boolean:
            case InternalPrimitiveTypeE.Byte:
            case InternalPrimitiveTypeE.Char:
            case InternalPrimitiveTypeE.Double:
            case InternalPrimitiveTypeE.Int16:
            case InternalPrimitiveTypeE.Int32:
            case InternalPrimitiveTypeE.Int64:
            case InternalPrimitiveTypeE.SByte:
            case InternalPrimitiveTypeE.Single:
            case InternalPrimitiveTypeE.TimeSpan:
            case InternalPrimitiveTypeE.DateTime:
            case InternalPrimitiveTypeE.UInt16:
            case InternalPrimitiveTypeE.UInt32:
            case InternalPrimitiveTypeE.UInt64:
                none     = InternalNameSpaceE.XdrPrimitive;
                typeName = "System." + ToComType(code);
                break;

            case InternalPrimitiveTypeE.Decimal:
                none     = InternalNameSpaceE.UrtSystem;
                typeName = "System." + ToComType(code);
                break;
            }
            if ((none != InternalNameSpaceE.None) || (type == null))
            {
                return(none);
            }
            if (object.ReferenceEquals(type, typeofString))
            {
                return(InternalNameSpaceE.XdrString);
            }
            if (objectInfo == null)
            {
                typeName = type.FullName;
                if (type.Assembly == urtAssembly)
                {
                    return(InternalNameSpaceE.UrtSystem);
                }
                return(InternalNameSpaceE.UrtUser);
            }
            typeName = objectInfo.GetTypeFullName();
            if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
            {
                return(InternalNameSpaceE.UrtSystem);
            }
            return(InternalNameSpaceE.UrtUser);
        }
コード例 #7
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE internalNameSpaceE = InternalNameSpaceE.None;

            typeName = (string)null;
            switch (code)
            {
            case InternalPrimitiveTypeE.Boolean:
            case InternalPrimitiveTypeE.Byte:
            case InternalPrimitiveTypeE.Char:
            case InternalPrimitiveTypeE.Double:
            case InternalPrimitiveTypeE.Int16:
            case InternalPrimitiveTypeE.Int32:
            case InternalPrimitiveTypeE.Int64:
            case InternalPrimitiveTypeE.SByte:
            case InternalPrimitiveTypeE.Single:
            case InternalPrimitiveTypeE.TimeSpan:
            case InternalPrimitiveTypeE.DateTime:
            case InternalPrimitiveTypeE.UInt16:
            case InternalPrimitiveTypeE.UInt32:
            case InternalPrimitiveTypeE.UInt64:
                internalNameSpaceE = InternalNameSpaceE.XdrPrimitive;
                typeName           = "System." + Converter.ToComType(code);
                break;

            case InternalPrimitiveTypeE.Decimal:
                internalNameSpaceE = InternalNameSpaceE.UrtSystem;
                typeName           = "System." + Converter.ToComType(code);
                break;
            }
            if (internalNameSpaceE == InternalNameSpaceE.None && type != null)
            {
                if (type == Converter.typeofString)
                {
                    internalNameSpaceE = InternalNameSpaceE.XdrString;
                }
                else if (objectInfo == null)
                {
                    typeName           = type.FullName;
                    internalNameSpaceE = !(type.Assembly == Converter.urtAssembly) ? InternalNameSpaceE.UrtUser : InternalNameSpaceE.UrtSystem;
                }
                else
                {
                    typeName           = objectInfo.GetTypeFullName();
                    internalNameSpaceE = !objectInfo.GetAssemblyString().Equals(Converter.urtAssemblyString) ? InternalNameSpaceE.UrtUser : InternalNameSpaceE.UrtSystem;
                }
            }
            return(internalNameSpaceE);
        }
コード例 #8
0
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            //use objectInfo to get assembly string with new criteria
            if (_assemblyToIdTable == null)
            {
                _assemblyToIdTable = new Dictionary <string, long>();
            }

            long   assemId        = 0;
            string assemblyString = objectInfo.GetAssemblyString();

            string serializedAssemblyString = assemblyString;

            if (assemblyString.Length == 0)
            {
                assemId = 0;
            }
            else if (assemblyString.Equals(Converter.s_urtAssemblyString))
            {
                // Urt type is an assemId of 0. No assemblyString needs
                // to be sent
                assemId = 0;
            }
            else
            {
                // Assembly needs to be sent
                // Need to prefix assembly string to separate the string names from the
                // assemblyName string names. That is a string can have the same value
                // as an assemblyNameString, but it is serialized differently
                bool isNew = false;
                if (_assemblyToIdTable.TryGetValue(assemblyString, out assemId))
                {
                    isNew = false;
                }
                else
                {
                    assemId = InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
                    _assemblyToIdTable[assemblyString] = assemId;
                }

                _serWriter.WriteAssembly(objectInfo._objectType, serializedAssemblyString, (int)assemId, isNew);
            }
            return(assemId);
        }
コード例 #9
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out String typeName)
        {
            SerTrace.Log("Converter", "GetNameSpaceEnum Entry ", ((Enum)code).ToString(), " type ", type);
            InternalNameSpaceE nameSpaceEnum = InternalNameSpaceE.None;

            typeName = null;

            if (code != InternalPrimitiveTypeE.Invalid)
            {
                switch (code)
                {
                case InternalPrimitiveTypeE.Boolean:
                case InternalPrimitiveTypeE.Char:
                case InternalPrimitiveTypeE.Byte:
                case InternalPrimitiveTypeE.Double:
                case InternalPrimitiveTypeE.Int16:
                case InternalPrimitiveTypeE.Int32:
                case InternalPrimitiveTypeE.Int64:
                case InternalPrimitiveTypeE.SByte:
                case InternalPrimitiveTypeE.Single:
                case InternalPrimitiveTypeE.UInt16:
                case InternalPrimitiveTypeE.UInt32:
                case InternalPrimitiveTypeE.UInt64:
                case InternalPrimitiveTypeE.DateTime:
                case InternalPrimitiveTypeE.TimeSpan:
                    nameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                    typeName      = "System." + ToComType(code);
                    break;

                case InternalPrimitiveTypeE.Decimal:
                    nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                    typeName      = "System." + ToComType(code);
                    break;
                }
            }

            if ((nameSpaceEnum == InternalNameSpaceE.None) && ((object)type != null))
            {
                if (Object.ReferenceEquals(type, typeofString))
                {
                    nameSpaceEnum = InternalNameSpaceE.XdrString;
                }
                else
                {
                    if (objectInfo == null)
                    {
                        typeName = type.FullName;
                        if (type.Assembly == urtAssembly)
                        {
                            nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        }
                        else
                        {
                            nameSpaceEnum = InternalNameSpaceE.UrtUser;
                        }
                    }
                    else
                    {
                        typeName = objectInfo.GetTypeFullName();
                        if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
                        {
                            nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        }
                        else
                        {
                            nameSpaceEnum = InternalNameSpaceE.UrtUser;
                        }
                    }
                }
            }

            SerTrace.Log("Converter", "GetNameSpaceEnum Exit ", ((Enum)nameSpaceEnum).ToString(), " typeName ", typeName);
            return(nameSpaceEnum);
        }
コード例 #10
0
ファイル: Converter.cs プロジェクト: Corillian/corefx
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE nameSpaceEnum = InternalNameSpaceE.None;
            typeName = null;

            if (code != InternalPrimitiveTypeE.Invalid)
            {
                switch (code)
                {
                    case InternalPrimitiveTypeE.Boolean:
                    case InternalPrimitiveTypeE.Char:
                    case InternalPrimitiveTypeE.Byte:
                    case InternalPrimitiveTypeE.Double:
                    case InternalPrimitiveTypeE.Int16:
                    case InternalPrimitiveTypeE.Int32:
                    case InternalPrimitiveTypeE.Int64:
                    case InternalPrimitiveTypeE.SByte:
                    case InternalPrimitiveTypeE.Single:
                    case InternalPrimitiveTypeE.UInt16:
                    case InternalPrimitiveTypeE.UInt32:
                    case InternalPrimitiveTypeE.UInt64:
                    case InternalPrimitiveTypeE.DateTime:
                    case InternalPrimitiveTypeE.TimeSpan:
                        nameSpaceEnum = InternalNameSpaceE.XdrPrimitive;
                        typeName = "System." + ToComType(code);
                        break;

                    case InternalPrimitiveTypeE.Decimal:
                        nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        typeName = "System." + ToComType(code);
                        break;
                }
            }

            if ((nameSpaceEnum == InternalNameSpaceE.None) && type != null)
            {
                if (ReferenceEquals(type, s_typeofString))
                {
                    nameSpaceEnum = InternalNameSpaceE.XdrString;
                }
                else
                {
                    if (objectInfo == null)
                    {
                        typeName = type.FullName;
                        nameSpaceEnum = type.GetTypeInfo().Assembly == s_urtAssembly ? InternalNameSpaceE.UrtSystem : InternalNameSpaceE.UrtUser;
                    }
                    else
                    {
                        typeName = objectInfo.GetTypeFullName();
                        nameSpaceEnum = objectInfo.GetAssemblyString().Equals(s_urtAssemblyString) ? InternalNameSpaceE.UrtSystem : InternalNameSpaceE.UrtUser;
                    }
                }
            }

            return nameSpaceEnum;
        }
コード例 #11
0
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            assemId         = 0;
            typeInformation = (object)null;
            BinaryTypeEnum binaryTypeEnum;

            if (type == Converter.typeofString)
            {
                binaryTypeEnum = BinaryTypeEnum.String;
            }
            else if ((objectInfo == null || objectInfo != null && !objectInfo.isSi) && type == Converter.typeofObject)
            {
                binaryTypeEnum = BinaryTypeEnum.Object;
            }
            else if (type == Converter.typeofStringArray)
            {
                binaryTypeEnum = BinaryTypeEnum.StringArray;
            }
            else if (type == Converter.typeofObjectArray)
            {
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            }
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
            {
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
            }
            else
            {
                InternalPrimitiveTypeE code = objectWriter.ToCode(type);
                if (code == InternalPrimitiveTypeE.Invalid)
                {
                    string str;
                    if (objectInfo == null)
                    {
                        str             = type.Assembly.FullName;
                        typeInformation = (object)type.FullName;
                    }
                    else
                    {
                        str             = objectInfo.GetAssemblyString();
                        typeInformation = (object)objectInfo.GetTypeFullName();
                    }
                    if (str.Equals(Converter.urtAssemblyString))
                    {
                        binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
                        assemId        = 0;
                    }
                    else
                    {
                        binaryTypeEnum = BinaryTypeEnum.ObjectUser;
                        assemId        = (int)objectInfo.assemId;
                        if (assemId == 0)
                        {
                            throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", typeInformation));
                        }
                    }
                }
                else
                {
                    binaryTypeEnum  = BinaryTypeEnum.Primitive;
                    typeInformation = (object)code;
                }
            }
            return(binaryTypeEnum);
        }
コード例 #12
0
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            //use objectInfo to get assembly string with new criteria
            SerTrace.Log( this, "GetAssemblyId Entry ",objectInfo.objectType," isSi ",objectInfo.isSi);
            if (assemblyToIdTable == null)
                assemblyToIdTable = new Hashtable(5);

            long assemId = 0;
            bool isNew = false;
            String assemblyString = objectInfo.GetAssemblyString();

            String serializedAssemblyString = assemblyString;
            if (assemblyString.Length == 0)
            {
                assemId = 0;
            }
            else if (assemblyString.Equals(Converter.urtAssemblyString))
            {
                // Urt type is an assemId of 0. No assemblyString needs
                // to be sent 
                SerTrace.Log( this, "GetAssemblyId urt Assembly String ");
                assemId = 0;
            }
            else
            {
                // Assembly needs to be sent
                // Need to prefix assembly string to separate the string names from the
                // assemblyName string names. That is a string can have the same value
                // as an assemblyNameString, but it is serialized differently

                if (assemblyToIdTable.ContainsKey(assemblyString))
                {
                    assemId = (long)assemblyToIdTable[assemblyString];
                    isNew = false;
                }
                else
                {
                    assemId = InternalGetId("___AssemblyString___"+assemblyString, false, null, out isNew);
                    assemblyToIdTable[assemblyString] = assemId;
                }

                serWriter.WriteAssembly(objectInfo.objectType, serializedAssemblyString, (int)assemId, isNew);
            }
            SerTrace.Log( this, "GetAssemblyId Exit id ",assemId," isNew ",isNew," assemblyString ",serializedAssemblyString);
            return assemId;
        }
コード例 #13
0
        // Token: 0x06005295 RID: 21141 RVA: 0x00121EF4 File Offset: 0x001200F4
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            assemId         = 0;
            typeInformation = null;
            BinaryTypeEnum result;

            if (type == Converter.typeofString)
            {
                result = BinaryTypeEnum.String;
            }
            else if ((objectInfo == null || (objectInfo != null && !objectInfo.isSi)) && type == Converter.typeofObject)
            {
                result = BinaryTypeEnum.Object;
            }
            else if (type == Converter.typeofStringArray)
            {
                result = BinaryTypeEnum.StringArray;
            }
            else if (type == Converter.typeofObjectArray)
            {
                result = BinaryTypeEnum.ObjectArray;
            }
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
            {
                result = BinaryTypeEnum.PrimitiveArray;
            }
            else
            {
                InternalPrimitiveTypeE internalPrimitiveTypeE = objectWriter.ToCode(type);
                if (internalPrimitiveTypeE == InternalPrimitiveTypeE.Invalid)
                {
                    string text;
                    if (objectInfo == null)
                    {
                        text            = type.Assembly.FullName;
                        typeInformation = type.FullName;
                    }
                    else
                    {
                        text            = objectInfo.GetAssemblyString();
                        typeInformation = objectInfo.GetTypeFullName();
                    }
                    if (text.Equals(Converter.urtAssemblyString))
                    {
                        result  = BinaryTypeEnum.ObjectUrt;
                        assemId = 0;
                    }
                    else
                    {
                        result  = BinaryTypeEnum.ObjectUser;
                        assemId = (int)objectInfo.assemId;
                        if (assemId == 0)
                        {
                            throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[]
                            {
                                typeInformation
                            }));
                        }
                    }
                }
                else
                {
                    result          = BinaryTypeEnum.Primitive;
                    typeInformation = internalPrimitiveTypeE;
                }
            }
            return(result);
        }
コード例 #14
0
ファイル: BinaryConverter.cs プロジェクト: sjyanxin/WPFSource
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out String typeName)
        {
            SerTrace.Log("Converter", "GetNameSpaceEnum Entry ",((Enum)code).ToString()," type ",type);
            InternalNameSpaceE nameSpaceEnum = InternalNameSpaceE.None; 
            typeName = null;
 
            if (code != InternalPrimitiveTypeE.Invalid) 
            {
                switch (code) 
                {
                    case InternalPrimitiveTypeE.Boolean:
                    case InternalPrimitiveTypeE.Char:
                    case InternalPrimitiveTypeE.Byte: 
                    case InternalPrimitiveTypeE.Double:
                    case InternalPrimitiveTypeE.Int16: 
                    case InternalPrimitiveTypeE.Int32: 
                    case InternalPrimitiveTypeE.Int64:
                    case InternalPrimitiveTypeE.SByte: 
                    case InternalPrimitiveTypeE.Single:
                    case InternalPrimitiveTypeE.UInt16:
                    case InternalPrimitiveTypeE.UInt32:
                    case InternalPrimitiveTypeE.UInt64: 
                    case InternalPrimitiveTypeE.DateTime:
                    case InternalPrimitiveTypeE.TimeSpan: 
                        nameSpaceEnum = InternalNameSpaceE.XdrPrimitive; 
                        typeName = "System."+ToComType(code);
                        break; 

                    case InternalPrimitiveTypeE.Decimal:
                        nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        typeName = "System."+ToComType(code); 
                        break;
                } 
            } 

            if ((nameSpaceEnum == InternalNameSpaceE.None) && ((object)type != null)) 
            {
                if (Object.ReferenceEquals(type, typeofString))
                    nameSpaceEnum = InternalNameSpaceE.XdrString;
                else 
                {
                    if (objectInfo == null) 
                    { 
                        typeName = type.FullName;
                        if (type.Assembly == urtAssembly) 
                            nameSpaceEnum = InternalNameSpaceE.UrtSystem;
                        else
                            nameSpaceEnum = InternalNameSpaceE.UrtUser;
                    } 
                    else
                    { 
                        typeName = objectInfo.GetTypeFullName(); 
                        if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
                            nameSpaceEnum = InternalNameSpaceE.UrtSystem; 
                        else
                            nameSpaceEnum = InternalNameSpaceE.UrtUser;
                    }
                } 
            }
 
            SerTrace.Log("Converter", "GetNameSpaceEnum Exit ", ((Enum)nameSpaceEnum).ToString()," typeName ",typeName); 
            return nameSpaceEnum;
        } 
コード例 #15
0
        internal static InternalNameSpaceE GetNameSpaceEnum(InternalPrimitiveTypeE code, Type type, WriteObjectInfo objectInfo, out string typeName)
        {
            InternalNameSpaceE none = InternalNameSpaceE.None;
            typeName = null;
            switch (code)
            {
                case InternalPrimitiveTypeE.Boolean:
                case InternalPrimitiveTypeE.Byte:
                case InternalPrimitiveTypeE.Char:
                case InternalPrimitiveTypeE.Double:
                case InternalPrimitiveTypeE.Int16:
                case InternalPrimitiveTypeE.Int32:
                case InternalPrimitiveTypeE.Int64:
                case InternalPrimitiveTypeE.SByte:
                case InternalPrimitiveTypeE.Single:
                case InternalPrimitiveTypeE.TimeSpan:
                case InternalPrimitiveTypeE.DateTime:
                case InternalPrimitiveTypeE.UInt16:
                case InternalPrimitiveTypeE.UInt32:
                case InternalPrimitiveTypeE.UInt64:
                    none = InternalNameSpaceE.XdrPrimitive;
                    typeName = "System." + ToComType(code);
                    break;

                case InternalPrimitiveTypeE.Decimal:
                    none = InternalNameSpaceE.UrtSystem;
                    typeName = "System." + ToComType(code);
                    break;
            }
            if ((none != InternalNameSpaceE.None) || (type == null))
            {
                return none;
            }
            if (object.ReferenceEquals(type, typeofString))
            {
                return InternalNameSpaceE.XdrString;
            }
            if (objectInfo == null)
            {
                typeName = type.FullName;
                if (type.Assembly == urtAssembly)
                {
                    return InternalNameSpaceE.UrtSystem;
                }
                return InternalNameSpaceE.UrtUser;
            }
            typeName = objectInfo.GetTypeFullName();
            if (objectInfo.GetAssemblyString().Equals(urtAssemblyString))
            {
                return InternalNameSpaceE.UrtSystem;
            }
            return InternalNameSpaceE.UrtUser;
        }
コード例 #16
0
        // From the type create the BinaryTypeEnum and typeInformation which describes the type on the wire
 
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, String typeName, ObjectWriter objectWriter, out Object typeInformation, out int assemId)
        {
            SerTrace.Log("BinaryConverter", "GetBinaryTypeInfo Entry type ",type,", typeName ",typeName," objectInfo "+objectInfo);
            BinaryTypeEnum binaryTypeEnum; 

            assemId = 0; 
            typeInformation = null; 

            if (Object.ReferenceEquals(type, Converter.typeofString)) 
                binaryTypeEnum = BinaryTypeEnum.String;
            else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi))
                     && (Object.ReferenceEquals(type, Converter.typeofObject)))
            { 
                // If objectInfo.Si then can be a surrogate which will change the type
                binaryTypeEnum = BinaryTypeEnum.Object; 
            } 
            else if (Object.ReferenceEquals(type, Converter.typeofStringArray))
                binaryTypeEnum = BinaryTypeEnum.StringArray; 
            else if (Object.ReferenceEquals(type, Converter.typeofObjectArray))
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray; 
            else
            { 
                InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type); 
                switch (primitiveTypeEnum)
                { 
                    case InternalPrimitiveTypeE.Invalid:
                        String assembly = null;
                        if (objectInfo == null)
                        { 
                            assembly = type.Assembly.FullName;
                            typeInformation = type.FullName; 
                        } 
                        else
                        { 
                            assembly = objectInfo.GetAssemblyString();
                            typeInformation = objectInfo.GetTypeFullName();
                        }
 
                        if (assembly.Equals(Converter.urtAssemblyString))
                        { 
                            binaryTypeEnum = BinaryTypeEnum.ObjectUrt; 
                            assemId = 0;
                        } 
                        else
                        {
                            binaryTypeEnum = BinaryTypeEnum.ObjectUser;
                            Contract.Assert(objectInfo!=null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object"); 
                            assemId = (int)objectInfo.assemId;
                            if (assemId == 0) 
                                throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId",typeInformation)); 
                        }
                        break; 
                    default:
                        binaryTypeEnum = BinaryTypeEnum.Primitive;
                        typeInformation = primitiveTypeEnum;
                        break; 
                }
            } 
 
            SerTrace.Log( "BinaryConverter", "GetBinaryTypeInfo Exit ",((Enum)binaryTypeEnum).ToString(),", typeInformation ",typeInformation," assemId ",assemId);
            return binaryTypeEnum; 
        }
コード例 #17
0
        private long GetAssemblyId(WriteObjectInfo objectInfo)
        {
            //use objectInfo to get assembly string with new criteria
            if (_assemblyToIdTable == null)
            {
                _assemblyToIdTable = new Dictionary<string, long>();
            }

            long assemId = 0;
            string assemblyString = objectInfo.GetAssemblyString();

            string serializedAssemblyString = assemblyString;
            if (assemblyString.Length == 0)
            {
                assemId = 0;
            }
            else if (assemblyString.Equals(Converter.s_urtAssemblyString))
            {
                // Urt type is an assemId of 0. No assemblyString needs
                // to be sent 
                assemId = 0;
            }
            else
            {
                // Assembly needs to be sent
                // Need to prefix assembly string to separate the string names from the
                // assemblyName string names. That is a string can have the same value
                // as an assemblyNameString, but it is serialized differently
                bool isNew = false;
                if (_assemblyToIdTable.TryGetValue(assemblyString, out assemId))
                {
                    isNew = false;
                }
                else
                {
                    assemId = InternalGetId("___AssemblyString___" + assemblyString, false, null, out isNew);
                    _assemblyToIdTable[assemblyString] = assemId;
                }

                _serWriter.WriteAssembly(objectInfo._objectType, serializedAssemblyString, (int)assemId, isNew);
            }
            return assemId;
        }
コード例 #18
0
        // From the type create the BinaryTypeEnum and typeInformation which describes the type on the wire
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            BinaryTypeEnum binaryTypeEnum;

            assemId         = 0;
            typeInformation = null;

            if (ReferenceEquals(type, Converter.s_typeofString))
            {
                binaryTypeEnum = BinaryTypeEnum.String;
            }
            else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo._isSi)) && (ReferenceEquals(type, Converter.s_typeofObject)))
            {
                // If objectInfo.Si then can be a surrogate which will change the type
                binaryTypeEnum = BinaryTypeEnum.Object;
            }
            else if (ReferenceEquals(type, Converter.s_typeofStringArray))
            {
                binaryTypeEnum = BinaryTypeEnum.StringArray;
            }
            else if (ReferenceEquals(type, Converter.s_typeofObjectArray))
            {
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            }
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
            {
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
            }
            else
            {
                InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type);
                switch (primitiveTypeEnum)
                {
                case InternalPrimitiveTypeE.Invalid:
                    string assembly = null;
                    if (objectInfo == null)
                    {
                        assembly        = type.GetTypeInfo().Assembly.FullName;
                        typeInformation = type.FullName;
                    }
                    else
                    {
                        assembly        = objectInfo.GetAssemblyString();
                        typeInformation = objectInfo.GetTypeFullName();
                    }

                    if (assembly.Equals(Converter.s_urtAssemblyString))
                    {
                        binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
                        assemId        = 0;
                    }
                    else
                    {
                        binaryTypeEnum = BinaryTypeEnum.ObjectUser;
                        Debug.Assert(objectInfo != null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object");
                        assemId = (int)objectInfo._assemId;
                        if (assemId == 0)
                        {
                            throw new SerializationException(SR.Format(SR.Serialization_AssemblyId, typeInformation));
                        }
                    }
                    break;

                default:
                    binaryTypeEnum  = BinaryTypeEnum.Primitive;
                    typeInformation = primitiveTypeEnum;
                    break;
                }
            }

            return(binaryTypeEnum);
        }
コード例 #19
0
ファイル: BinaryTypeConverter.cs プロジェクト: dotnet/corefx
        // From the type create the BinaryTypeEnum and typeInformation which describes the type on the wire
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            BinaryTypeEnum binaryTypeEnum;

            assemId = 0;
            typeInformation = null;

            if (ReferenceEquals(type, Converter.s_typeofString))
            {
                binaryTypeEnum = BinaryTypeEnum.String;
            }
            else if (((objectInfo == null) || ((objectInfo != null) && !objectInfo._isSi)) && (ReferenceEquals(type, Converter.s_typeofObject)))
            {
                // If objectInfo.Si then can be a surrogate which will change the type
                binaryTypeEnum = BinaryTypeEnum.Object;
            }
            else if (ReferenceEquals(type, Converter.s_typeofStringArray))
            {
                binaryTypeEnum = BinaryTypeEnum.StringArray;
            }
            else if (ReferenceEquals(type, Converter.s_typeofObjectArray))
            {
                binaryTypeEnum = BinaryTypeEnum.ObjectArray;
            }
            else if (Converter.IsPrimitiveArray(type, out typeInformation))
            {
                binaryTypeEnum = BinaryTypeEnum.PrimitiveArray;
            }
            else
            {
                InternalPrimitiveTypeE primitiveTypeEnum = objectWriter.ToCode(type);
                switch (primitiveTypeEnum)
                {
                    case InternalPrimitiveTypeE.Invalid:
                        string assembly = null;
                        if (objectInfo == null)
                        {
                            assembly = type.Assembly.FullName;
                            typeInformation = type.FullName;
                        }
                        else
                        {
                            assembly = objectInfo.GetAssemblyString();
                            typeInformation = objectInfo.GetTypeFullName();
                        }

                        if (assembly.Equals(Converter.s_urtAssemblyString))
                        {
                            binaryTypeEnum = BinaryTypeEnum.ObjectUrt;
                            assemId = 0;
                        }
                        else
                        {
                            binaryTypeEnum = BinaryTypeEnum.ObjectUser;
                            Debug.Assert(objectInfo != null, "[BinaryConverter.GetBinaryTypeInfo]objectInfo null for user object");
                            assemId = (int)objectInfo._assemId;
                            if (assemId == 0)
                            {
                                throw new SerializationException(SR.Format(SR.Serialization_AssemblyId, typeInformation));
                            }
                        }
                        break;
                    default:
                        binaryTypeEnum = BinaryTypeEnum.Primitive;
                        typeInformation = primitiveTypeEnum;
                        break;
                }
            }

            return binaryTypeEnum;
        }
コード例 #20
0
        internal static BinaryTypeEnum GetBinaryTypeInfo(Type type, WriteObjectInfo objectInfo, string typeName, ObjectWriter objectWriter, out object typeInformation, out int assemId)
        {
            BinaryTypeEnum primitive;

            assemId         = 0;
            typeInformation = null;
            if (object.ReferenceEquals(type, Converter.typeofString))
            {
                return(BinaryTypeEnum.String);
            }
            if (((objectInfo == null) || ((objectInfo != null) && !objectInfo.isSi)) && object.ReferenceEquals(type, Converter.typeofObject))
            {
                return(BinaryTypeEnum.Object);
            }
            if (object.ReferenceEquals(type, Converter.typeofStringArray))
            {
                return(BinaryTypeEnum.StringArray);
            }
            if (object.ReferenceEquals(type, Converter.typeofObjectArray))
            {
                return(BinaryTypeEnum.ObjectArray);
            }
            if (Converter.IsPrimitiveArray(type, out typeInformation))
            {
                return(BinaryTypeEnum.PrimitiveArray);
            }
            InternalPrimitiveTypeE ee = objectWriter.ToCode(type);

            switch (ee)
            {
            case InternalPrimitiveTypeE.Invalid:
            {
                string fullName = null;
                if (objectInfo == null)
                {
                    fullName        = type.Assembly.FullName;
                    typeInformation = type.FullName;
                }
                else
                {
                    fullName        = objectInfo.GetAssemblyString();
                    typeInformation = objectInfo.GetTypeFullName();
                }
                if (fullName.Equals(Converter.urtAssemblyString))
                {
                    primitive = BinaryTypeEnum.ObjectUrt;
                    assemId   = 0;
                    return(primitive);
                }
                primitive = BinaryTypeEnum.ObjectUser;
                assemId   = (int)objectInfo.assemId;
                if (assemId == 0)
                {
                    throw new SerializationException(Environment.GetResourceString("Serialization_AssemblyId", new object[] { typeInformation }));
                }
                return(primitive);
            }
            }
            primitive       = BinaryTypeEnum.Primitive;
            typeInformation = ee;
            return(primitive);
        }