コード例 #1
0
        internal ContainerDefinition ConstructContainerDefinition(
            Type type,
            Assembly definedAssembly)
        {
            ContainerType containerType;

            type.IsContainer(out containerType);
            SaveId keyId   = (SaveId)null;
            SaveId valueId = (SaveId)null;

            switch (containerType)
            {
            case ContainerType.List:
                keyId = this.GetTypeDefinition(type.GenericTypeArguments[0]).SaveId;
                break;

            case ContainerType.Dictionary:
                keyId   = this.GetTypeDefinition(type.GenericTypeArguments[0]).SaveId;
                valueId = this.GetTypeDefinition(type.GenericTypeArguments[1]).SaveId;
                break;

            case ContainerType.Array:
                keyId = this.GetTypeDefinition(type.GetElementType()).SaveId;
                break;

            case ContainerType.Queue:
                keyId = this.GetTypeDefinition(type.GenericTypeArguments[0]).SaveId;
                break;
            }
            ContainerSaveId     saveId = new ContainerSaveId(containerType, keyId, valueId);
            ContainerDefinition containerDefinition = new ContainerDefinition(type, saveId, definedAssembly);

            this.AddContainerDefinition(containerDefinition);
            return(containerDefinition);
        }
コード例 #2
0
        public static ContainerSaveId ReadFrom(IReader reader)
        {
            ContainerType containerType = (ContainerType)reader.ReadByte();
            int           num           = containerType == ContainerType.Dictionary ? 2 : 1;
            List <SaveId> saveIdList    = new List <SaveId>();

            for (int index = 0; index < num; ++index)
            {
                SaveId saveId = (SaveId)null;
                switch (reader.ReadByte())
                {
                case 0:
                    saveId = (SaveId)TypeSaveId.ReadFrom(reader);
                    break;

                case 1:
                    saveId = (SaveId)GenericSaveId.ReadFrom(reader);
                    break;

                case 2:
                    saveId = (SaveId)ContainerSaveId.ReadFrom(reader);
                    break;
                }
                saveIdList.Add(saveId);
            }
            SaveId keyId   = saveIdList[0];
            SaveId valueId = saveIdList.Count > 1 ? saveIdList[1] : (SaveId)null;

            return(new ContainerSaveId(containerType, keyId, valueId));
        }
コード例 #3
0
        public static GenericSaveId ReadFrom(IReader reader)
        {
            int           num1       = (int)reader.ReadByte();
            TypeSaveId    baseId     = TypeSaveId.ReadFrom(reader);
            byte          num2       = reader.ReadByte();
            List <SaveId> saveIdList = new List <SaveId>();

            for (int index = 0; index < (int)num2; ++index)
            {
                SaveId saveId = (SaveId)null;
                switch (reader.ReadByte())
                {
                case 0:
                    saveId = (SaveId)TypeSaveId.ReadFrom(reader);
                    break;

                case 1:
                    saveId = (SaveId)GenericSaveId.ReadFrom(reader);
                    break;

                case 2:
                    saveId = (SaveId)ContainerSaveId.ReadFrom(reader);
                    break;
                }
                saveIdList.Add(saveId);
            }
            return(new GenericSaveId(baseId, saveIdList.ToArray()));
        }
コード例 #4
0
        public static SaveId ReadSaveIdFrom(IReader reader)
        {
            byte   num    = reader.ReadByte();
            SaveId saveId = (SaveId)null;

            switch (num)
            {
            case 0:
                saveId = (SaveId)TypeSaveId.ReadFrom(reader);
                break;

            case 1:
                saveId = (SaveId)GenericSaveId.ReadFrom(reader);
                break;

            case 2:
                saveId = (SaveId)ContainerSaveId.ReadFrom(reader);
                break;
            }
            return(saveId);
        }
コード例 #5
0
 public ContainerDefinition(Type type, ContainerSaveId saveId, Assembly definedAssembly)
     : base(type, (SaveId)saveId)
 {
     this.DefinedAssembly = definedAssembly;
 }