Exemplo n.º 1
0
        public bScoreFrame(SerializationReader sr)
        {
            //checksum = sr.ReadString();
            time         = sr.ReadInt32();
            id           = sr.ReadByte();
            count300     = sr.ReadUInt16();
            count100     = sr.ReadUInt16();
            count50      = sr.ReadUInt16();
            countGeki    = sr.ReadUInt16();
            countKatu    = sr.ReadUInt16();
            countMiss    = sr.ReadUInt16();
            totalScore   = sr.ReadInt32();
            maxCombo     = sr.ReadUInt16();
            currentCombo = sr.ReadUInt16();
            perfect      = sr.ReadBoolean();
            currentHp    = sr.ReadByte();
            tagByte      = sr.ReadByte();
            usingScoreV2 = sr.ReadBoolean();
            comboPortion = usingScoreV2 ? sr.ReadDouble() : 0;
            bonusPortion = usingScoreV2 ? sr.ReadDouble() : 0;

            if (currentHp == 254)
            {
                currentHp = 0;
                pass      = false;
            }
            else
            {
                pass = true;
            }
        }
Exemplo n.º 2
0
            public Parameter(SerializationInfo serializationInfo, StreamingContext streamingContext)
            {
                if (SerializerHelper.UseFastSerialization)
                {
                    using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                    {
                        _alias = reader.ReadString();
                        _characterMaximumLength = reader.ReadInt32();
                        _dataType        = reader.ReadString();
                        _direction       = reader.ReadString();
                        _enabled         = reader.ReadBoolean();
                        _isUserDefined   = reader.ReadBoolean();
                        _name            = reader.ReadString();
                        _ordinalPosition = reader.ReadInt32();
                        _userOptions     = (List <IUserOption>)reader.ReadObject();
                        _precision       = reader.ReadInt32();
                        _scale           = reader.ReadInt32();

                        for (int i = 0; i < _userOptions.Count; i++)
                        {
                            _userOptions[i].Owner = this;
                        }
                    }
                }
                else
                {
                    int version = 0;

                    if (SerializationVersionExists)
                    {
                        try
                        {
                            version = serializationInfo.GetInt32("SerializationVersion");
                        }
                        catch (SerializationException)
                        {
                            // ignore
                            SerializationVersionExists = false;
                        }
                    }
                    _alias = serializationInfo.GetString("Alias");
                    _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength");
                    _dataType  = serializationInfo.GetString("DataType");
                    _direction = serializationInfo.GetString("Direction");
                    _enabled   = serializationInfo.GetBoolean("Enabled");
                    //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                    _isUserDefined   = serializationInfo.GetBoolean("IsUserDefined");
                    _name            = serializationInfo.GetString("Name");
                    _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition");
                    _userOptions     = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                    if (version >= 3)
                    {
                        _precision = serializationInfo.GetInt32("Precision");
                        _scale     = serializationInfo.GetInt32("Scale");
                    }
                }
            }
Exemplo n.º 3
0
        /// <exclude/>
        public Index(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                _columns = null;

                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias = reader.ReadString();
                    _columnIds = reader.ReadStringArray();
                    _enabled = reader.ReadBoolean();
                    _isUserDefined = reader.ReadBoolean();
                    _name = reader.ReadString();
                    // TODO: Parent
                    _type = reader.ReadString();
                    _userOptions = (List<IUserOption>)reader.ReadObject();
                }
            }
            else
            {
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias = serializationInfo.GetString("Alias");
                _columns = (List<Column>)serializationInfo.GetValue("Columns", ModelTypes.ColumnList);
                _enabled = serializationInfo.GetBoolean("Enabled");
                //this._exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _name = serializationInfo.GetString("Name");
                _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject);
                _type = serializationInfo.GetString("Type");
                _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                for (int i = 0; i < _userOptions.Count; i++)
                {
                    _userOptions[i].Owner = this;
                }
                if (version >= 8)
                {
                    _description = serializationInfo.GetString("Description");
                }
            }
        }
Exemplo n.º 4
0
        /// <exclude/>
        public Index(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                _columns = null;

                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias         = reader.ReadString();
                    _columnIds     = reader.ReadStringArray();
                    _enabled       = reader.ReadBoolean();
                    _isUserDefined = reader.ReadBoolean();
                    _name          = reader.ReadString();
                    // TODO: Parent
                    _type        = reader.ReadString();
                    _userOptions = (List <IUserOption>)reader.ReadObject();
                }
            }
            else
            {
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias   = serializationInfo.GetString("Alias");
                _columns = (List <Column>)serializationInfo.GetValue("Columns", ModelTypes.ColumnList);
                _enabled = serializationInfo.GetBoolean("Enabled");
                //this._exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _name          = serializationInfo.GetString("Name");
                _parent        = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject);
                _type          = serializationInfo.GetString("Type");
                _userOptions   = (List <IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                for (int i = 0; i < _userOptions.Count; i++)
                {
                    _userOptions[i].Owner = this;
                }
                if (version >= 8)
                {
                    _description = serializationInfo.GetString("Description");
                }
            }
        }
Exemplo n.º 5
0
 public override void Deserialize(SerializationReader reader)
 {
     coderack = (Coderack)reader.ReadPointer(); // coderack = CType(info.GetValue("coderack", GetType(Coderack)), Coderack)
     salience = reader.ReadDouble();            // salience = info.GetDouble("salience")
     space    = reader.ReadInt32();             // space = info.GetInt32("space")
     time     = reader.ReadInt32();             // time = info.GetInt32("time")
     reader.ReadDictionary(children);           // children = CType(info.GetValue("children", GetType(Dictionary(Of String, Codelet))), Dictionary(Of String, Codelet))
     watched = reader.ReadBoolean();            // watched = info.GetBoolean("watched")
     immune  = reader.ReadBoolean();            // immune = info.GetBoolean("immune")
 }
Exemplo n.º 6
0
        protected override void SetObjectData(SerializationReader sr)
        {
            base.SetObjectData(sr);

            f_ForegroundColor = new TextColor(sr.ReadInt32());
            f_BackgroundColor = new TextColor(sr.ReadInt32());
            f_Underline       = sr.ReadBoolean();
            f_Bold            = sr.ReadBoolean();
            f_Italic          = sr.ReadBoolean();
            f_Text            = sr.ReadString();
        }
Exemplo n.º 7
0
        protected override void SetObjectData(SerializationReader sr)
        {
            if (sr == null)
            {
                throw new ArgumentNullException("sr");
            }

            base.SetObjectData(sr);

            _IsOp    = sr.ReadBoolean();
            _IsVoice = sr.ReadBoolean();
        }
Exemplo n.º 8
0
 public Association(SerializationInfo serializationInfo, StreamingContext streamingContext)
 {
     if (SerializerHelper.UseFastSerialization)
     {
         using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
         {
             _UniqueId           = reader.ReadString();
             _AssociatedObjectId = reader.ReadString();
             _AssociationKind    = reader.ReadString();
             _Mappings           = (List <Mapping>)reader.ReadObject();
             _Name    = reader.ReadString();
             _Enabled = reader.ReadBoolean();
         }
     }
     else
     {
         if (SerializationVersionExists)
         {
             try
             {
             }
             catch (SerializationException)
             {
                 // ignore
                 SerializationVersionExists = false;
             }
         }
         _AssociatedObject = (ScriptObject)serializationInfo.GetValue("AssociatedObject", ModelTypes.ScriptObject);
         _PrimaryObject    = (ScriptObject)serializationInfo.GetValue("PrimaryObject", ModelTypes.ScriptObject);
         _AssociationKind  = serializationInfo.GetString("AssociationKind");
         _Mappings         = (List <Mapping>)serializationInfo.GetValue("Mappings", typeof(List <Mapping>));
         _Name             = serializationInfo.GetString("Name");
         _Enabled          = serializationInfo.GetBoolean("Enabled");
     }
 }
        public RedBlackNode <double, DataType> DeserializeTree(SerializationReader reader, RedBlackNode <double, DataType>[] containers, ref int ii)
        {
            double key = reader.ReadDouble();

            if (key == 0.0)
            {
                return(null);
            }
            else
            {
                RedBlackNode <double, DataType> node = new RedBlackNode <double, DataType>();
                node.Key         = key;
                node.Color       = reader.ReadBoolean() ? RED : BLACK;
                containers[ii++] = node;

                RedBlackNode <double, DataType> left  = DeserializeTree(reader, containers, ref ii);
                RedBlackNode <double, DataType> right = DeserializeTree(reader, containers, ref ii);
                if (left != null)
                {
                    left.Parent = node;
                }
                if (right != null)
                {
                    right.Parent = node;
                }
                node.Left  = left;
                node.Right = right;

                return(node);
            }
        }
Exemplo n.º 10
0
        public void ReadFromStream(SerializationReader r)
        {
            OsuVersion        = r.ReadInt32();
            FolderCount       = r.ReadInt32();
            AccountUnlocked   = r.ReadBoolean();
            AccountUnlockDate = r.ReadDateTime();
            AccountName       = r.ReadString();

            Beatmaps = new List <BeatmapEntry>();
            int length = r.ReadInt32();

            for (int i = 0; i < length; i++)
            {
                int currentIndex = (int)r.BaseStream.Position;
                int entryLength  = r.ReadInt32();

                Beatmaps.Add(BeatmapEntry.ReadFromReader(r, false, OsuVersion));

                if (r.BaseStream.Position != currentIndex + entryLength + 4)
                {
                    Debug.Fail($"Length doesn't match, {r.BaseStream.Position} instead of expected {currentIndex + entryLength + 4}");
                }
            }
            AccountRank = (PlayerRank)r.ReadByte();
        }
Exemplo n.º 11
0
        internal Score(SerializationInfo info, StreamingContext ctxt)
        {
            SerializationReader sr = SerializationReader.GetReader(info);

            pass = true;

            fileChecksum = sr.ReadString();
            playerName   = sr.ReadString();
            string scoreChecksumCheck = sr.ReadString();

            count300            = sr.ReadUInt16();
            count100            = sr.ReadUInt16();
            count50             = sr.ReadUInt16();
            countGeki           = sr.ReadUInt16();
            countKatu           = sr.ReadUInt16();
            countMiss           = sr.ReadUInt16();
            totalScore          = sr.ReadInt32();
            maxCombo            = sr.ReadUInt16();
            perfect             = sr.ReadBoolean();
            enabledMods         = (Mods)sr.ReadInt32();
            rawGraph            = sr.ReadString();
            rawReplayCompressed = sr.ReadByteArray();
            date = sr.ReadDateTime();

            if (scoreChecksumCheck != offlineScoreChecksum)
            {
                throw new Exception("f****d score");
            }
        }
Exemplo n.º 12
0
        //public string checksum;

        public bScoreFrame(Stream s)
        {
            SerializationReader sr = new SerializationReader(s);

            //checksum = sr.ReadString();
            time         = sr.ReadInt32();
            id           = sr.ReadByte();
            count300     = sr.ReadUInt16();
            count100     = sr.ReadUInt16();
            count50      = sr.ReadUInt16();
            countGeki    = sr.ReadUInt16();
            countKatu    = sr.ReadUInt16();
            countMiss    = sr.ReadUInt16();
            totalScore   = sr.ReadInt32();
            maxCombo     = sr.ReadUInt16();
            currentCombo = sr.ReadUInt16();
            perfect      = sr.ReadBoolean();
            currentHp    = sr.ReadByte();
            if (currentHp == 254)
            {
                currentHp = 0;
                pass      = false;
            }
            else
            {
                pass = true;
            }
        }
Exemplo n.º 13
0
 public Association(SerializationInfo serializationInfo, StreamingContext streamingContext)
 {
     if (SerializerHelper.UseFastSerialization)
     {
         using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
         {
             _UniqueId = reader.ReadString();
             _AssociatedObjectId = reader.ReadString();
             _AssociationKind = reader.ReadString();
             _Mappings = (List<Mapping>)reader.ReadObject();
             _Name = reader.ReadString();
             _Enabled = reader.ReadBoolean();
         }
     }
     else
     {
         if (SerializationVersionExists)
         {
             try
             {
             }
             catch (SerializationException)
             {
                 // ignore
                 SerializationVersionExists = false;
             }
         }
         _AssociatedObject = (ScriptObject)serializationInfo.GetValue("AssociatedObject", ModelTypes.ScriptObject);
         _PrimaryObject = (ScriptObject)serializationInfo.GetValue("PrimaryObject", ModelTypes.ScriptObject);
         _AssociationKind = serializationInfo.GetString("AssociationKind");
         _Mappings = (List<Mapping>)serializationInfo.GetValue("Mappings", typeof(List<Mapping>));
         _Name = serializationInfo.GetString("Name");
         _Enabled = serializationInfo.GetBoolean("Enabled");
     }
 }
Exemplo n.º 14
0
 public override void LoadData(SerializationReader Reader)
 {
     if (Reader.ReadBoolean())
     {
         Part = BodyPart.Load(Reader, null);
     }
     base.LoadData(Reader);
 }
Exemplo n.º 15
0
        public static async Task <Match> ReadMatch(this SerializationReader reader)
        {
            var match = new Match();

            reader.ReadInt16(); // match id
            reader.ReadByte();  // in progress

            match.Type       = (MatchTypes)reader.ReadByte();
            match.ActiveMods = (Mods)reader.ReadInt32();

            match.GameName     = reader.ReadString();
            match.GamePassword = reader.ReadString();

            reader.ReadString(); // beatmap name

            match.BeatmapId       = reader.ReadInt32();
            match.BeatmapChecksum = reader.ReadString();

            match.Beatmap = (await BeatmapManager.Get(match.BeatmapChecksum)).Item2;

            foreach (var slot in match.Slots)
            {
                slot.Status = (SlotStatus)reader.ReadByte();
            }

            foreach (var slot in match.Slots)
            {
                slot.Team = (SlotTeams)reader.ReadByte();
            }

            foreach (var slot in match.Slots)
            {
                if ((slot.Status & SlotStatus.HasPlayer) > 0)
                {
                    reader.ReadInt32();
                }
            }

            match.Host = PresenceManager.GetPresenceById(reader.ReadInt32());

            match.PlayMode    = (PlayMode)reader.ReadByte();
            match.ScoringType = (MatchScoringTypes)reader.ReadByte();
            match.TeamType    = (MatchTeamTypes)reader.ReadByte();
            match.FreeMods    = reader.ReadBoolean();

            if (match.FreeMods)
            {
                foreach (var slot in match.Slots)
                {
                    slot.Mods = (Mods)reader.ReadInt32();
                }
            }

            match.Seed = reader.ReadInt32();

            return(match);
        }
Exemplo n.º 16
0
        public TracePoint(SerializationInfo info, StreamingContext ctxt)
        {
            SerializationReader sr = SerializationReader.GetReader(info);

            MZ         = sr.ReadDouble();
            RT         = sr.ReadSingle();
            Intensity  = sr.ReadSingle();
            ScanNumber = sr.ReadInt32(); //jlin
            Charge     = sr.ReadInt32();
            IsFullScan = sr.ReadBoolean();
        }
Exemplo n.º 17
0
        protected override void SetObjectData(SerializationReader sr)
        {
            if (sr == null)
            {
                throw new ArgumentNullException("sr");
            }

            base.SetObjectData(sr);

            IsOp    = sr.ReadBoolean();
            IsVoice = sr.ReadBoolean();

            // backward compatibility
            if (sr.PeekChar() != -1)
            {
                IsOwner        = sr.ReadBoolean();
                IsChannelAdmin = sr.ReadBoolean();
                IsHalfop       = sr.ReadBoolean();
            }
        }
Exemplo n.º 18
0
 public void ReadFromStream(SerializationReader r)
 {
     Time         = r.ReadInt32();
     Id           = r.ReadByte();
     Count300     = r.ReadUInt16();
     Count100     = r.ReadUInt16();
     Count50      = r.ReadUInt16();
     CountGeki    = r.ReadUInt16();
     CountKatu    = r.ReadUInt16();
     CountMiss    = r.ReadUInt16();
     TotalScore   = r.ReadInt32();
     MaxCombo     = r.ReadUInt16();
     CurrentCombo = r.ReadUInt16();
     Perfect      = r.ReadBoolean();
     CurrentHp    = r.ReadByte();
     TagByte      = r.ReadByte();
     UsingScoreV2 = r.ReadBoolean();
     ComboPortion = UsingScoreV2 ? r.ReadDouble() : 0;
     BonusPortion = UsingScoreV2 ? r.ReadDouble() : 0;
 }
Exemplo n.º 19
0
 protected virtual void SetObjectData(SerializationReader sr)
 {
     // FIXME: optimize this by re-parsing instead of deserializing
     _Data             = sr.ReadString();
     _DataArray        = _Data.Split(new char[] { ' ' });
     _Parameter        = sr.ReadString();
     _IsCommand        = sr.ReadBoolean();
     _CommandCharacter = sr.ReadString();
     _Command          = sr.ReadString();
     //_FrontendManager  = (FrontendManager) sr.ReadObject();
     //_Chat             = (ChatModel) sr.ReadObject();
 }
Exemplo n.º 20
0
        public bMatch(SerializationReader sr)
        {
            SendPassword = false;

            matchId         = sr.ReadUInt16();
            inProgress      = sr.ReadBoolean();
            matchType       = (MatchTypes)sr.ReadByte();
            activeMods      = (Mods)sr.ReadUInt32();
            gameName        = sr.ReadString();
            gamePassword    = sr.ReadString();
            beatmapName     = sr.ReadString();
            beatmapId       = sr.ReadInt32();
            beatmapChecksum = sr.ReadString();

            for (int i = 0; i < MAX_PLAYERS; i++)
            {
                slotStatus[i] = (SlotStatus)sr.ReadByte();
            }

            for (int i = 0; i < MAX_PLAYERS; i++)
            {
                slotTeam[i] = (SlotTeams)sr.ReadByte();
            }

            for (int i = 0; i < MAX_PLAYERS; i++)
            {
                slotId[i] = (slotStatus[i] & SlotStatus.HasPlayer) > 0 ? sr.ReadInt32() : -1;
            }

            hostId = sr.ReadInt32();

            playMode = (PlayModes)sr.ReadByte();

            matchScoringType = (MatchScoringTypes)sr.ReadByte();
            matchTeamType    = (MatchTeamTypes)sr.ReadByte();

            specialModes = (MultiSpecialModes)sr.ReadByte();

            if (gameName.Length > 50)
            {
                gameName = gameName.Remove(50);
            }

            if ((specialModes & MultiSpecialModes.FreeMod) > 0)
            {
                for (int i = 0; i < MAX_PLAYERS; i++)
                {
                    slotMods[i] = (Mods)sr.ReadInt32();
                }
            }
            Seed = sr.ReadInt32();
        }
Exemplo n.º 21
0
        public bStatusUpdate(Stream s)
        {
            SerializationReader sr = new SerializationReader(s);

            status        = (bStatus)sr.ReadByte();
            beatmapUpdate = sr.ReadBoolean();

            if (beatmapUpdate)
            {
                statusText      = sr.ReadString();
                beatmapChecksum = sr.ReadString();
                currentMods     = (Mods)sr.ReadUInt16();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Implementing the ISerializable to provide a faster, more optimized
        /// serialization for the class.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public SuperPoolCall(SerializationInfo info, StreamingContext context)
        {
            // Get from the info.
            SerializationReader reader = new SerializationReader((byte[])info.GetValue("data", typeof(byte[])));

            Id              = reader.ReadInt64();
            State           = (StateEnum)reader.ReadInt32();
            RequestResponse = reader.ReadBoolean();
            Parameters      = reader.ReadObjectArray();
            string methodInfoName = reader.ReadString();

            _methodInfoName = methodInfoName;
            MethodInfoLocal = SerializationHelper.DeserializeMethodBaseFromString(_methodInfoName, true);
        }
Exemplo n.º 23
0
        public void ReadFromStream(SerializationReader r)
        {
            MatchId         = r.ReadUInt16();
            InProgress      = r.ReadBoolean();
            MultiType       = (MultiTypes)r.ReadByte();
            ActiveMods      = (Mods)r.ReadUInt32();
            GameName        = r.ReadString();
            GamePassword    = r.ReadString();
            BeatmapName     = r.ReadString();
            BeatmapId       = r.ReadInt32();
            BeatmapChecksum = r.ReadString();

            for (int i = 0; i < Constants.MultiplayerMaxPlayers; i++)
            {
                MultiSlotStatus[i] = (MultiSlotStatus)r.ReadByte();
            }

            for (int i = 0; i < Constants.MultiplayerMaxPlayers; i++)
            {
                SlotTeam[i] = (SlotTeams)r.ReadByte();
            }

            for (int i = 0; i < Constants.MultiplayerMaxPlayers; i++)
            {
                SlotId[i] = (MultiSlotStatus[i] & (MultiSlotStatus)0b01111100) > 0 ? r.ReadInt32() : -1;
            }

            HostId = r.ReadInt32();

            PlayMode = (GameMode)r.ReadByte();

            MultiWinCondition = (MultiWinConditions)r.ReadByte();
            MultiTeamType     = (MultiTeamTypes)r.ReadByte();

            SpecialModes = (MultiSpecialModes)r.ReadByte();

            if (GameName.Length > 50)
            {
                GameName = GameName.Remove(50);
            }

            if ((SpecialModes & MultiSpecialModes.FreeMod) > 0)
            {
                for (int i = 0; i < Constants.MultiplayerMaxPlayers; i++)
                {
                    SlotMods[i] = (Mods)r.ReadInt32();
                }
            }
            Seed = r.ReadInt32();
        }
Exemplo n.º 24
0
        /// <summary>
        /// Implementing the ISerializable to provide a faster, more optimized
        /// serialization for the class.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public SuperPoolCall(SerializationInfo info, StreamingContext context)
        {
            // Get from the info.
            SerializationReader reader = new SerializationReader((byte[])info.GetValue("data", typeof(byte[])));

            Id = reader.ReadInt64();
            State = (StateEnum)reader.ReadInt32();
            RequestResponse = reader.ReadBoolean();
            Parameters = reader.ReadObjectArray();
            string methodInfoName = reader.ReadString();

            _methodInfoName = methodInfoName;
            MethodInfoLocal = SerializationHelper.DeserializeMethodBaseFromString(_methodInfoName, true);
        }
Exemplo n.º 25
0
        public void ReadFromStream(SerializationReader sr)
        {
            if (BeatmapDatabase.Version < 5)
            {
                sr.ReadByte();
            }

            if (sr.ReadBoolean()) //has score
            {
                HighScore = new Score();
                HighScore.ReadFromStream(sr);
            }

            Playcount = sr.ReadUInt16();
        }
Exemplo n.º 26
0
        /// <summary>
        /// Parses scores.db file.
        /// </summary>
        /// <param name="stream">Stream containing scores.db data.</param>
        /// <returns>A usable <see cref="ScoresDatabase"/>.</returns>
        public static ScoresDatabase DecodeScores(Stream stream)
        {
            ScoresDatabase db = new ScoresDatabase();

            using (var r = new SerializationReader(stream))
            {
                db.OsuVersion = r.ReadInt32();
                int beatmapCount = r.ReadInt32();

                for (int i = 0; i < beatmapCount; i++)
                {
                    string       md5Hash     = r.ReadString();
                    int          scoresCount = r.ReadInt32();
                    List <Score> scores      = new List <Score>();

                    for (int j = 0; j < scoresCount; j++)
                    {
                        Score score = new Score();
                        score.Ruleset        = (Ruleset)r.ReadByte();
                        score.OsuVersion     = r.ReadInt32();
                        score.BeatmapMD5Hash = r.ReadString();
                        score.PlayerName     = r.ReadString();
                        score.ReplayMD5Hash  = r.ReadString();
                        score.Count300       = r.ReadUInt16();
                        score.Count100       = r.ReadUInt16();
                        score.Count50        = r.ReadUInt16();
                        score.CountGeki      = r.ReadUInt16();
                        score.CountKatu      = r.ReadUInt16();
                        score.CountMiss      = r.ReadUInt16();
                        score.ReplayScore    = r.ReadInt32();
                        score.Combo          = r.ReadUInt16();
                        score.PerfectCombo   = r.ReadBoolean();
                        score.Mods           = (Mods)r.ReadInt32();
                        string lifeBarGraphData = r.ReadString();
                        score.ScoreTimestamp = r.ReadDateTime();
                        r.BaseStream.Seek(sizeof(int), SeekOrigin.Current);
                        score.ScoreId = r.ReadInt64();
                        scores.Add(score);
                    }

                    db.Scores.Add(new Tuple <string, List <Score> >(md5Hash, scores));
                }
            }

            return(db);
        }
Exemplo n.º 27
0
 public bMatchData(SerializationReader reader)
 {
     SendPassword    = false;
     matchId         = reader.ReadUInt16();
     inProgress      = reader.ReadBoolean();
     matchType       = (MatchTypes)reader.ReadByte();
     activeMods      = (Mods)reader.ReadUInt32();
     gameName        = reader.ReadString();
     gamePassword    = reader.ReadString();
     beatmapName     = reader.ReadString();
     beatmapId       = reader.ReadInt32();
     beatmapChecksum = reader.ReadString();
     for (var i = 0; i < MaxRoomPlayers; i++)
     {
         slotStatus[i] = (SlotStatus)reader.ReadByte();
     }
     for (var j = 0; j < MaxRoomPlayers; j++)
     {
         slotTeam[j] = (SlotTeams)reader.ReadByte();
     }
     for (var k = 0; k < MaxRoomPlayers; k++)
     {
         slotId[k] = (((slotStatus[k] & SlotStatus.Occupied) > (SlotStatus)0)
             ? reader.ReadInt32()
             : -1);
     }
     hostId           = reader.ReadInt32();
     playMode         = (PlayModes)reader.ReadByte();
     matchScoringType = (MatchScoringTypes)reader.ReadByte();
     matchTeamType    = (MatchTeamTypes)reader.ReadByte();
     specialModes     = (MultiSpecialModes)reader.ReadByte();
     if (gameName.Length > 50)
     {
         gameName = gameName.Remove(50);
     }
     if ((specialModes & MultiSpecialModes.FreeMod) > MultiSpecialModes.None)
     {
         for (var l = 0; l < MaxRoomPlayers; l++)
         {
             slotMods[l] = (Mods)reader.ReadInt32();
         }
     }
     Seed = reader.ReadInt32();
 }
Exemplo n.º 28
0
        public void ReadHeaderFromStream(SerializationReader sr)
        {
            Pass         = true;
            Version      = sr.ReadInt32();
            FileChecksum = sr.ReadString();
            PlayerName   = sr.ReadString();
            var localScoreChecksum = sr.ReadString();

            Count300      = sr.ReadUInt16();
            Count100      = sr.ReadUInt16();
            Count50       = sr.ReadUInt16();
            CountGeki     = sr.ReadUInt16();
            CountKatu     = sr.ReadUInt16();
            CountMiss     = sr.ReadUInt16();
            TotalScore    = sr.ReadInt32();
            MaxCombo      = sr.ReadUInt16();
            Perfect       = sr.ReadBoolean();
            EnabledMods   = (Mods)sr.ReadInt32();
            HpGraphString = sr.ReadString();
            Date          = sr.ReadDateTime();
        }
Exemplo n.º 29
0
        public bMatch(Stream s)
        {
            SerializationReader sr = new SerializationReader(s);

            matchId         = sr.ReadByte();
            inProgress      = sr.ReadBoolean();
            matchType       = (MatchType)sr.ReadByte();
            activeMods      = (Mods)sr.ReadInt16();
            gameName        = sr.ReadString();
            beatmapName     = sr.ReadString();
            beatmapId       = sr.ReadInt32();
            beatmapChecksum = sr.ReadString();
            for (int i = 0; i < slotCount; i++)
            {
                slotStatus[i] = (SlotStatus)sr.ReadByte();
            }

            for (int i = 0; i < slotCount; i++)
            {
                slotId[i] = (slotStatus[i] & SlotStatus.CompHasPlayer) > 0 ? sr.ReadInt32() : -1;
            }
        }
Exemplo n.º 30
0
        public static Replay Parse(Stream stream)
        {
            using var sr = new SerializationReader(stream);
            var replay = new Replay();

            replay.PlayMode = (PlayMode)sr.ReadByte();
            sr.ReadInt32(); // Version

            replay.BeatmapChecksum = sr.ReadString();
            replay.Username        = sr.ReadString();

            sr.ReadString(); // Replay Checksum

            replay.Count300  = sr.ReadUInt16();
            replay.Count100  = sr.ReadUInt16();
            replay.Count50   = sr.ReadUInt16();
            replay.CountGeki = sr.ReadUInt16();
            replay.CountKatu = sr.ReadUInt16();
            replay.CountMiss = sr.ReadUInt16();

            replay.TotalScore = sr.ReadInt32();
            replay.MaxCombo   = sr.ReadUInt16();

            sr.ReadBoolean(); // Perfect

            replay.Mods = (Mods)sr.ReadInt32();

            sr.ReadString();    // HpGraph
            sr.ReadInt64();     // Date
            sr.ReadByteArray(); // Replay Data

            sr.ReadInt64();     // OnlineID, i guess we don't need check 2012-2014 clients

            // TODO: replay data parsing (i do it when will make anticheat)

            return(replay);
        }
Exemplo n.º 31
0
 public bScoreData(SerializationReader reader)
 {
     int_1    = reader.ReadInt32();
     byte_0   = reader.ReadByte();
     ushort_1 = reader.ReadUInt16();
     ushort_0 = reader.ReadUInt16();
     ushort_2 = reader.ReadUInt16();
     ushort_3 = reader.ReadUInt16();
     ushort_4 = reader.ReadUInt16();
     ushort_5 = reader.ReadUInt16();
     int_2    = reader.ReadInt32();
     ushort_7 = reader.ReadUInt16();
     ushort_6 = reader.ReadUInt16();
     bool_1   = reader.ReadBoolean();
     int_0    = reader.ReadByte();
     int_3    = reader.ReadByte();
     if (int_0 == 254)
     {
         int_0  = 0;
         bool_0 = false;
         return;
     }
     bool_0 = true;
 }
Exemplo n.º 32
0
        public void ReadFromStream(SerializationReader r)
        {
            OsuVersion        = r.ReadInt32();
            FolderCount       = r.ReadInt32();
            AccountUnlocked   = r.ReadBoolean();
            AccountUnlockDate = r.ReadDateTime();
            AccountName       = r.ReadString();

            Beatmaps = new List <BeatmapEntry>();

            int length = r.ReadInt32();

            for (int i = 0; i < length; i++)
            {
                int currentIndex = (int)r.BaseStream.Position;
                int entryLength  = 0;

                // After version 20191107, the size of the beatmap entry is no longer present
                // https://github.com/ppy/osu-wiki/commit/7ce3b8988d9945fe5867029a65750b40d66a3820
                const int lengthOsuVersion = 20191107;

                if (OsuVersion < lengthOsuVersion)
                {
                    entryLength = r.ReadInt32();
                }

                Beatmaps.Add(BeatmapEntry.ReadFromReader(r, false, OsuVersion));

                if (OsuVersion < lengthOsuVersion && r.BaseStream.Position != currentIndex + entryLength + 4)
                {
                    Debug.Fail($"Length doesn't match, {r.BaseStream.Position} instead of expected {currentIndex + entryLength + 4}");
                }
            }

            AccountRank = (PlayerRank)r.ReadByte();
        }
Exemplo n.º 33
0
 protected virtual void SetObjectData(SerializationReader sr)
 {
     // FIXME: optimize this by re-parsing instead of deserializing
     _Data             = sr.ReadString();
     _DataArray        = _Data.Split(new char[] {' '});
     _Parameter        = sr.ReadString();
     _IsCommand        = sr.ReadBoolean();
     _CommandCharacter = sr.ReadString();
     _Command          = sr.ReadString();
     //_FrontendManager  = (FrontendManager) sr.ReadObject();
     //_Chat             = (ChatModel) sr.ReadObject();
 }
Exemplo n.º 34
0
        protected override void SetObjectData(SerializationReader sr)
        {
            if (sr == null) {
                throw new ArgumentNullException("sr");
            }

            base.SetObjectData(sr);

            _IsOp    = sr.ReadBoolean();
            _IsVoice = sr.ReadBoolean();
        }
Exemplo n.º 35
0
        public void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            try
            {

                if (mySerializationReader != null)
                {

                    UUID = new AttributeUUID();
                    UUID.Deserialize(ref mySerializationReader);
                    DBTypeUUID = new TypeUUID();
                    DBTypeUUID.Deserialize(ref mySerializationReader);
                    KindOfType = (KindsOfType)mySerializationReader.ReadOptimizedByte();
                    TypeCharacteristics = new TypeCharacteristics();
                    TypeCharacteristics.Deserialize(ref mySerializationReader);

                    Name = mySerializationReader.ReadString();

                    var hasEdgeType = mySerializationReader.ReadBoolean();

                    if (hasEdgeType)
                    {
                        try
                        {
                            EdgeType = (IEdgeType) mySerializationReader.ReadObject();
                        }
                        catch(Exception ex)
                        {
                            //NLOG: temporarily commented
                            //Logger.Fatal("Could not deserialize EdgeType");
                            throw new GraphDBException(new Error_UnknownDBError(ex));
                        }

                    }

                    RelatedGraphDBTypeUUID = new TypeUUID();
                    RelatedGraphDBTypeUUID.Deserialize(ref mySerializationReader);

                    if (TypeCharacteristics.IsBackwardEdge)
                        BackwardEdgeDefinition = (EdgeKey) mySerializationReader.ReadObject();

                    DefaultValue = (IObject) mySerializationReader.ReadObject();

                    #region Read Settings

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Settings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {

                        var _SettingObject = (ADBSettingsBase) mySerializationReader.ReadObject();

                        if (_SettingObject != null)
                            _Settings.Add(_SettingObject.Name, _SettingObject);

                        /*Type settingType = (Type)mySerializationReader.ReadObject();
                        ADBSettingsBase _SettingObject = null;
                        try
                        {
                            _SettingObject = (ADBSettingsBase)Activator.CreateInstance(settingType);
                        }
                        catch
                        {
                            Logger.Error("Could not create an instance of setting " + settingType.ToString());
                        }
                        Byte[] Bytes = (Byte[])mySerializationReader.ReadObject();
                        if (_SettingObject != null)
                        {
                            _SettingObject.Deserialize(new SerializationReader(Bytes));
                            _Settings.Add(_SettingObject.Name, _SettingObject);
                        }*/
                    }

                    #endregion

                }
            }

            catch (Exception e)
            {
                throw new SerializationException("The Setting could not be deserialized!\n\n" + e);
            }
        }
Exemplo n.º 36
0
 public void Deserialize(ref SerializationReader mySerializationReader)
 {
     IsBackwardEdge = mySerializationReader.ReadBoolean();
 }
Exemplo n.º 37
0
 protected virtual void SetObjectData(SerializationReader sr)
 {
     f_IsHighlight = sr.ReadBoolean();
 }
Exemplo n.º 38
0
 public override void Deserialize(SerializationReader reader)
 {
     coderack = (Coderack) reader.ReadPointer();    // coderack = CType(info.GetValue("coderack", GetType(Coderack)), Coderack)
     salience = reader.ReadDouble();  // salience = info.GetDouble("salience")
     space = reader.ReadInt32();  // space = info.GetInt32("space")
     time = reader.ReadInt32();   // time = info.GetInt32("time")
     reader.ReadDictionary(children); // children = CType(info.GetValue("children", GetType(Dictionary(Of String, Codelet))), Dictionary(Of String, Codelet))
     watched = reader.ReadBoolean();  // watched = info.GetBoolean("watched")
     immune = reader.ReadBoolean();   // immune = info.GetBoolean("immune")
 }
Exemplo n.º 39
0
        /// <exclude/>
        public OneToManyRelationship(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                _foreignColumns = null;

                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias = reader.ReadString();
                    _enabled = reader.ReadBoolean();
                    _filterId = reader.ReadString();
                    _ForeignColumnIds = reader.ReadStringArray();
                    _ForeignRelationshipId = reader.ReadString();
                    _ForeignScriptObjectId = reader.ReadString();
                    _isUserDefined = reader.ReadBoolean();
                    _name = reader.ReadString();
                    // TODO: Parent
                    string[] primaryColumnIds = reader.ReadStringArray();

                    foreach (string primaryColumnId in primaryColumnIds)
                    {
                        _primaryColumns.Add((Column)Lookups[primaryColumnId]);
                    }
                    // TODO: PrimaryScriptObject
                    _userOptions = (List<IUserOption>)reader.ReadObject();

                    for (int i = 0; i < _userOptions.Count; i++)
                    {
                        _userOptions[i].Owner = this;
                    }
                }
            }
            else
            {
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias = serializationInfo.GetString("Alias");
                _enabled = serializationInfo.GetBoolean("Enabled");
                //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                _filter = (Filter)serializationInfo.GetValue("Filter", ModelTypes.Filter);
                _foreignColumns = (List<Column>)serializationInfo.GetValue("ForeignColumns", ModelTypes.ColumnList);
                _foreignRelationship = (Relationship)serializationInfo.GetValue("ForeignRelationship", ModelTypes.Relationship);
                _foreignScriptObject = (ScriptObject)serializationInfo.GetValue("ForeignScriptObject", ModelTypes.ScriptObject);
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _name = serializationInfo.GetString("Name");
                _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject);
                _primaryColumns = (List<Column>)serializationInfo.GetValue("PrimaryColumns", ModelTypes.ColumnList);
                _primaryScriptObject = (ScriptObject)serializationInfo.GetValue("PrimaryScriptObject", ModelTypes.ScriptObject);
                _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                if (version >= 8)
                {
                    _description = serializationInfo.GetString("Description");
                }
            }
        }
Exemplo n.º 40
0
        protected override void SetObjectData(SerializationReader sr)
        {
            base.SetObjectData(sr);

            f_ForegroundColor = new TextColor(sr.ReadInt32());
            f_BackgroundColor = new TextColor(sr.ReadInt32());
            f_Underline       = sr.ReadBoolean();
            f_Bold            = sr.ReadBoolean();
            f_Italic          = sr.ReadBoolean();
            f_Text            = sr.ReadString();
        }
Exemplo n.º 41
0
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            if (mySerializationReader != null)
            {
                try
                {
                    _UUID = new TypeUUID(this.ObjectUUID.GetByteArray());
                    ParentTypeUUID = new TypeUUID();
                    ParentTypeUUID.Deserialize(ref mySerializationReader);
                    _IsUserDefined = mySerializationReader.ReadBoolean();
                    _IsAbstract = mySerializationReader.ReadBoolean();
                    _Comment = mySerializationReader.ReadString();

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Attributes = new Dictionary<AttributeUUID, TypeAttribute>();

                    _TypeAttributeLookupTable = new Dictionary<AttributeUUID, TypeAttribute>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        var _AttrAtrib = new AttributeUUID();
                        _AttrAtrib.Deserialize(ref mySerializationReader);
                        var _TypeObj = new TypeAttribute();
                        _TypeObj.Deserialize(ref mySerializationReader);
                        _Attributes.Add(_AttrAtrib, _TypeObj);
                        _TypeAttributeLookupTable.Add(_AttrAtrib, _TypeObj);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _TypeSettings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {
                        ADBSettingsBase _ADBSettingsBase = (ADBSettingsBase) mySerializationReader.ReadObject();
                        if(_ADBSettingsBase != null)
                            _TypeSettings.Add(_ADBSettingsBase.Name, _ADBSettingsBase);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _UniqueAttributes = new List<AttributeUUID>();
                    AttributeUUID AttribID = null;

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _UniqueAttributes.Add(AttribID);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _MandatoryAttributes = new HashSet<AttributeUUID>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _MandatoryAttributes.Add(AttribID);
                    }

                    ObjectDirectoryShards = mySerializationReader.ReadUInt16();

                    #region Indices

                    _AttributeIndices = new Dictionary<IndexKeyDefinition, Dictionary<String, AAttributeIndex>>();
                    _AttributeIndicesNameLookup = new Dictionary<String, IndexKeyDefinition>();

                    var idxCount = mySerializationReader.ReadUInt32();
                    for (var i = 0; i < idxCount; i++)
                    {

                        var idxKey = new IndexKeyDefinition();
                        idxKey.Deserialize(ref mySerializationReader);

                        //_AttributeIndices.Add(idxKey, new Dictionary<String, AttributeIndex>());

                        var idxVersionCount = mySerializationReader.ReadUInt32();

                        for (var j = 0; j < idxVersionCount; j++)
                        {

                            var key                 = mySerializationReader.ReadString();
                            var fileSystemLocation  = new ObjectLocation(mySerializationReader.ReadString());
                            var indexEdition        = mySerializationReader.ReadString();
                            var indexName           = mySerializationReader.ReadString();
                            var indexType           = mySerializationReader.ReadString();
                            var isUUIDIdx           = mySerializationReader.ReadBoolean();
                            var keyCount            = mySerializationReader.ReadUInt64();
                            var valueCount          = mySerializationReader.ReadUInt64();
                            var attributeIdxShards = mySerializationReader.ReadUInt16();

                            //var CreateIdxExcept = CreateAttributeIndex(indexName, idxKey.IndexKeyAttributeUUIDs, indexEdition, indexObjectType, fileSystemLocation);

                            if (isUUIDIdx)
                            {
                                AddAttributeIndex(new UUIDIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount));
                            }
                            else
                            {
                                AddAttributeIndex(new AttributeIndex(indexName, idxKey, this, attributeIdxShards, indexType, indexEdition, keyCount, valueCount));
                            }

                            //if (CreateIdxExcept.Failed())
                            //    throw new GraphDBException(CreateIdxExcept.Errors);
                        }

                    }

                    #endregion

                }

                catch (Exception e)
                {
                    throw new SerializationException("The GraphDBType could not be deserialized!\n\n" + e);
                }

            }
        }
Exemplo n.º 42
0
 private object Deserialize(ref SerializationReader mySerializationReader, DBBoolean myValue)
 {
     myValue._Value = mySerializationReader.ReadBoolean();
     return myValue;
 }
Exemplo n.º 43
0
        /// <exclude/>
        public MapColumn(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                _relationshipPath = null;

                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias = reader.ReadString();
                    _aliasDisplay = reader.ReadString();
                    _characterMaximumLength = reader.ReadInt32();
                    // TODO: CurrentParent
                    _dataType = reader.ReadString();
                    _default = reader.ReadString();
                    _enabled = reader.ReadBoolean();
                    _foreignColumnId = reader.ReadString();
                    _inPrimaryKey = reader.ReadBoolean();
                    _isIdentity = reader.ReadBoolean();
                    _isNullable = reader.ReadBoolean();
                    _isUserDefined = reader.ReadBoolean();
                    _name = reader.ReadString();
                    _ordinalPosition = reader.ReadInt32();
                    // TODO: Parent
                    _readOnly = reader.ReadBoolean();
                    _RelationshipPathIds = reader.ReadStringArray();
                    _userOptions = (List<IUserOption>)reader.ReadObject();

                    for (int i = 0; i < _userOptions.Count; i++)
                    {
                        _userOptions[i].Owner = this;
                    }
                }
            }
            else
            {
                _IsMapColumn = true;
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias = serializationInfo.GetString("Alias");
                _aliasDisplay = serializationInfo.GetString("AliasDisplay");
                _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength");
                _currentParent = (ScriptObject)serializationInfo.GetValue("CurrentParent", ModelTypes.ScriptObject);
                _dataType = serializationInfo.GetString("DataType");
                _default = serializationInfo.GetString("Default");
                _enabled = serializationInfo.GetBoolean("Enabled");
                //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                _foreignColumn = (Column)serializationInfo.GetValue("ForeignColumn", ModelTypes.Column);
                _inPrimaryKey = serializationInfo.GetBoolean("InPrimaryKey");
                _isIdentity = serializationInfo.GetBoolean("IsIdentity");
                _isNullable = serializationInfo.GetBoolean("IsNullable");
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _name = serializationInfo.GetString("Name");
                _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition");
                _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject);
                _readOnly = serializationInfo.GetBoolean("ReadOnly");
                _relationshipPath = (Relationship[])serializationInfo.GetValue("RelationshipPath", ModelTypes.RelationshipArray);
                _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                if (version >= 8)
                {
                    _description = serializationInfo.GetString("Description");
                }
            }
        }
Exemplo n.º 44
0
        /// <exclude/>
        public StoredProcedure(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias = reader.ReadString();
                    _aliasPlural = reader.ReadString();
                    _columns = (List<Column>)reader.ReadObject();
                    // TODO: Database
                    _enabled = reader.ReadBoolean();
                    _filters = (List<Filter>)reader.ReadObject();
                    _isUserDefined = reader.ReadBoolean();
                    _manyToManyRelationships = (List<ManyToManyRelationship>)reader.ReadObject();
                    _manyToOneRelationships = (List<ManyToOneRelationship>)reader.ReadObject();
                    _name = reader.ReadString();
                    _oneToManyRelationships = (List<OneToManyRelationship>)reader.ReadObject();
                    _oneToOneRelationships = (List<OneToOneRelationship>)reader.ReadObject();
                    _parameters = (List<Parameter>)reader.ReadObject();
                    _userOptions = (List<IUserOption>)reader.ReadObject();
                    _Schema = reader.ReadString();
                    _Associations = (List<Association>)reader.ReadObject();

                    foreach (Column column in _columns)
                    {
                        column.Parent = this;
                    }
                    foreach (Filter filter in _filters)
                    {
                        filter.Parent = this;
                    }
                    foreach (Association association in _Associations)
                    {
                        association.PrimaryObject = this;
                    }
                    foreach (ManyToManyRelationship relationship in _manyToManyRelationships)
                    {
                        relationship.Parent = this;
                    }
                    foreach (ManyToOneRelationship relationship in _manyToOneRelationships)
                    {
                        relationship.Parent = this;
                    }
                    foreach (OneToManyRelationship relationship in _oneToManyRelationships)
                    {
                        relationship.Parent = this;
                    }
                    foreach (OneToOneRelationship relationship in _oneToOneRelationships)
                    {
                        relationship.Parent = this;
                    }
                    for (int i = 0; i < _userOptions.Count; i++)
                    {
                        _userOptions[i].Owner = this;
                    }
                }
            }
            else
            {
                _IsStoredProcedure = true;
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias = serializationInfo.GetString("Alias");
                _aliasPlural = serializationInfo.GetString("AliasPlural");
                _columns = (List<Column>)serializationInfo.GetValue("Columns", ModelTypes.ColumnList);
                _database = (Database)serializationInfo.GetValue("Database", ModelTypes.Database);
                _enabled = serializationInfo.GetBoolean("Enabled");
                //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                _filters = (List<Filter>)serializationInfo.GetValue("Filters", ModelTypes.FilterList);
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _manyToManyRelationships = (List<ManyToManyRelationship>)serializationInfo.GetValue("ManyToManyRelationships", ModelTypes.ManyToManyRelationshipList);
                _manyToOneRelationships = (List<ManyToOneRelationship>)serializationInfo.GetValue("ManyToOneRelationships", ModelTypes.ManyToOneRelationshipList);
                _name = serializationInfo.GetString("Name");
                _oneToManyRelationships = (List<OneToManyRelationship>)serializationInfo.GetValue("OneToManyRelationships", ModelTypes.OneToManyRelationshipList);
                _oneToOneRelationships = (List<OneToOneRelationship>)serializationInfo.GetValue("OneToOneRelationships", ModelTypes.OneToOneRelationshipList);
                _parameters = (List<Parameter>)serializationInfo.GetValue("Parameters", ModelTypes.ParameterList);
                _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                if (version > 0)
                {
                    _Schema = serializationInfo.GetString("Schema");

                    if (version > 4)
                    {
                        _Errors = (List<string>)serializationInfo.GetValue("Errors", typeof(List<string>));

                        if (version >= 6)
                        {
                            _Associations = (List<Association>)serializationInfo.GetValue("Associations", typeof(List<Association>));

                            if (version >= 8)
                            {
                                _description = serializationInfo.GetString("Description");
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 45
0
            public Parameter(SerializationInfo serializationInfo, StreamingContext streamingContext)
            {
                if (SerializerHelper.UseFastSerialization)
                {
                    using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                    {
                        _alias = reader.ReadString();
                        _characterMaximumLength = reader.ReadInt32();
                        _dataType = reader.ReadString();
                        _direction = reader.ReadString();
                        _enabled = reader.ReadBoolean();
                        _isUserDefined = reader.ReadBoolean();
                        _name = reader.ReadString();
                        _ordinalPosition = reader.ReadInt32();
                        _userOptions = (List<IUserOption>)reader.ReadObject();
                        _precision = reader.ReadInt32();
                        _scale = reader.ReadInt32();

                        for (int i = 0; i < _userOptions.Count; i++)
                        {
                            _userOptions[i].Owner = this;
                        }
                    }
                }
                else
                {
                    int version = 0;

                    if (SerializationVersionExists)
                    {
                        try
                        {
                            version = serializationInfo.GetInt32("SerializationVersion");
                        }
                        catch (SerializationException)
                        {
                            // ignore
                            SerializationVersionExists = false;
                        }
                    }
                    _alias = serializationInfo.GetString("Alias");
                    _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength");
                    _dataType = serializationInfo.GetString("DataType");
                    _direction = serializationInfo.GetString("Direction");
                    _enabled = serializationInfo.GetBoolean("Enabled");
                    //_exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ModelTypes.Object);
                    _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                    _name = serializationInfo.GetString("Name");
                    _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition");
                    _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                    if (version >= 3)
                    {
                        _precision = serializationInfo.GetInt32("Precision");
                        _scale = serializationInfo.GetInt32("Scale");
                    }
                }
            }
Exemplo n.º 46
0
        /// <summary>
        /// TODO: I don't think this should be exposed to the user???
        /// </summary>
        /// <param name="serializationInfo"></param>
        /// <param name="streamingContext"></param>
        public Column(SerializationInfo serializationInfo, StreamingContext streamingContext)
        {
            if (SerializerHelper.UseFastSerialization)
            {
                using (SerializationReader reader = new SerializationReader((byte[])serializationInfo.GetValue("d", typeof(byte[]))))
                {
                    UniqueId = reader.ReadString();
                    Lookups.Add(UniqueId, this);
                    _alias = reader.ReadString();
                    _aliasDisplay = reader.ReadString();
                    _characterMaximumLength = reader.ReadInt32();
                    _dataType = reader.ReadString();
                    _default = reader.ReadString();
                    _enabled = reader.ReadBoolean();
                    _inPrimaryKey = reader.ReadBoolean();
                    _isIdentity = reader.ReadBoolean();
                    _isNullable = reader.ReadBoolean();
                    _isUserDefined = reader.ReadBoolean();
                    _name = reader.ReadString();
                    _ordinalPosition = reader.ReadInt32();
                    // Parent
                    _readOnly = reader.ReadBoolean();
                    _userOptions = (List<IUserOption>)reader.ReadObject();
                    _IsCalculated = reader.ReadBoolean();
                    _precision = reader.ReadInt32();
                    _scale = reader.ReadInt32();

                    for (int i = 0; i < _userOptions.Count; i++)
                    {
                        _userOptions[i].Owner = this;
                    }
                }
            }
            else
            {
                int version = 0;

                if (SerializationVersionExists)
                {
                    try
                    {
                        version = serializationInfo.GetInt32("SerializationVersion");
                    }
                    catch (SerializationException)
                    {
                        // ignore
                        SerializationVersionExists = false;
                    }
                }
                _alias = serializationInfo.GetString("Alias");
                _aliasDisplay = serializationInfo.GetString("AliasDisplay");
                _characterMaximumLength = serializationInfo.GetInt32("CharacterMaximumLength");
                _dataType = serializationInfo.GetString("DataType");
                _default = serializationInfo.GetString("Default");
                _enabled = serializationInfo.GetBoolean("Enabled");
                //this._exposedUserOptions = serializationInfo.GetValue("ExposedUserOptions", ObjectType);
                _inPrimaryKey = serializationInfo.GetBoolean("InPrimaryKey");
                _isIdentity = serializationInfo.GetBoolean("IsIdentity");
                _isNullable = serializationInfo.GetBoolean("IsNullable");
                _isUserDefined = serializationInfo.GetBoolean("IsUserDefined");
                _name = serializationInfo.GetString("Name");
                _ordinalPosition = serializationInfo.GetInt32("OrdinalPosition");
                _parent = (ScriptObject)serializationInfo.GetValue("Parent", ModelTypes.ScriptObject);
                _readOnly = serializationInfo.GetBoolean("ReadOnly");
                _userOptions = (List<IUserOption>)serializationInfo.GetValue("UserOptions", ModelTypes.UserOptionList);

                if (version >= 2)
                {
                    _IsCalculated = serializationInfo.GetBoolean("IsCalculated");

                    if (version >= 3)
                    {
                        _precision = serializationInfo.GetInt32("Precision");
                        _scale = serializationInfo.GetInt32("Scale");

                        if (version >= 8)
                        {
                            _description = serializationInfo.GetString("Description");

                            if (version >= 9)
                            {
                                _Lookup = (Lookup)serializationInfo.GetValue("Lookup", ModelTypes.Lookup);
                                //_Lookup.SubscribingObjects.Add(this);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 47
0
        public Score ReadReplayFile(string replayFilename)
        {
            Score score;

            using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
                using (SerializationReader sr = new SerializationReader(s))
                {
                    var ruleset   = Ruleset.GetRuleset((PlayMode)sr.ReadByte());
                    var processor = ruleset.CreateScoreProcessor();

                    score = processor.GetScore();

                    /* score.Pass = true;*/
                    var version = sr.ReadInt32();
                    /* score.FileChecksum = */
                    var beatmapHash = sr.ReadString();
                    score.Beatmap = beatmaps.Query <BeatmapInfo>().Where(b => b.Hash == beatmapHash).FirstOrDefault();
                    /* score.PlayerName = */
                    sr.ReadString();
                    /* var localScoreChecksum = */
                    sr.ReadString();
                    /* score.Count300 = */
                    sr.ReadUInt16();
                    /* score.Count100 = */
                    sr.ReadUInt16();
                    /* score.Count50 = */
                    sr.ReadUInt16();
                    /* score.CountGeki = */
                    sr.ReadUInt16();
                    /* score.CountKatu = */
                    sr.ReadUInt16();
                    /* score.CountMiss = */
                    sr.ReadUInt16();
                    score.TotalScore = sr.ReadInt32();
                    score.MaxCombo   = sr.ReadUInt16();
                    /* score.Perfect = */
                    sr.ReadBoolean();
                    /* score.EnabledMods = (Mods)*/
                    sr.ReadInt32();
                    /* score.HpGraphString = */
                    sr.ReadString();
                    /* score.Date = */
                    sr.ReadDateTime();

                    var compressedReplay = sr.ReadByteArray();

                    if (version >= 20140721)
                    {
                        /*OnlineId =*/
                        sr.ReadInt64();
                    }
                    else if (version >= 20121008)
                    {
                        /*OnlineId =*/
                        sr.ReadInt32();
                    }

                    using (var replayInStream = new MemoryStream(compressedReplay))
                    {
                        byte[] properties = new byte[5];
                        if (replayInStream.Read(properties, 0, 5) != 5)
                        {
                            throw (new Exception("input .lzma is too short"));
                        }
                        long outSize = 0;
                        for (int i = 0; i < 8; i++)
                        {
                            int v = replayInStream.ReadByte();
                            if (v < 0)
                            {
                                throw (new Exception("Can't Read 1"));
                            }
                            outSize |= ((long)(byte)v) << (8 * i);
                        }

                        long compressedSize = replayInStream.Length - replayInStream.Position;

                        using (var lzma = new LzmaStream(properties, replayInStream, compressedSize, outSize))
                            using (var reader = new StreamReader(lzma))
                                score.Replay = new LegacyReplay(reader);
                    }
                }

            return(score);
        }
Exemplo n.º 48
0
        public override void Deserialize(ref SerializationReader mySerializationReader)
        {
            UInt32 _Capacity;

            if (mySerializationReader != null)
            {
                try
                {
                    _UUID = new TypeUUID(this.ObjectUUID.GetByteArray());
                    ParentTypeUUID = new TypeUUID();
                    ParentTypeUUID.Deserialize(ref mySerializationReader);
                    _IsUserDefined = mySerializationReader.ReadBoolean();
                    _IsAbstract = mySerializationReader.ReadBoolean();
                    _Comment = mySerializationReader.ReadString();

                    _Capacity = mySerializationReader.ReadUInt32();

                    _Attributes = new Dictionary<AttributeUUID, TypeAttribute>();

                    _TypeAttributeLookupTable = new Dictionary<AttributeUUID, TypeAttribute>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        var _AttrAtrib = new AttributeUUID();
                        _AttrAtrib.Deserialize(ref mySerializationReader);
                        var _TypeObj = new TypeAttribute();
                        _TypeObj.Deserialize(ref mySerializationReader);
                        _Attributes.Add(_AttrAtrib, _TypeObj);
                        _TypeAttributeLookupTable.Add(_AttrAtrib, _TypeObj);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _TypeSettings = new Dictionary<String, ADBSettingsBase>();

                    for (var i = 0; i < _Capacity; i++)
                    {
                        ADBSettingsBase _ADBSettingsBase = (ADBSettingsBase) mySerializationReader.ReadObject();
                        if(_ADBSettingsBase != null)
                            _TypeSettings.Add(_ADBSettingsBase.Name, _ADBSettingsBase);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _UniqueAttributes = new List<AttributeUUID>();
                    AttributeUUID AttribID = null;

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _UniqueAttributes.Add(AttribID);
                    }

                    _Capacity = mySerializationReader.ReadUInt32();
                    _MandatoryAttributes = new HashSet<AttributeUUID>();

                    for (UInt32 i = 0; i < _Capacity; i++)
                    {
                        AttribID = new AttributeUUID(ref mySerializationReader);
                        _MandatoryAttributes.Add(AttribID);
                    }

                    #region Indices

                    _AttributeIndices = new Dictionary<IndexKeyDefinition, Dictionary<String, AAttributeIndex>>();
                    _AttributeIndicesNameLookup = new Dictionary<String, IndexKeyDefinition>();
                    _AttributeIndexLocations = new Dictionary<IndexKeyDefinition, Dictionary<string, Tuple<string, ObjectLocation>>>();

                    var idxCount = mySerializationReader.ReadUInt32();
                    for (var i = 0; i < idxCount; i++)
                    {

                        var idxKey = new IndexKeyDefinition();
                        idxKey.Deserialize(ref mySerializationReader);

                        //_AttributeIndices.Add(idxKey, new Dictionary<String, AttributeIndex>());

                        var idxVersionCount = mySerializationReader.ReadUInt32();

                        _AttributeIndexLocations.Add(idxKey, new Dictionary<string, Tuple<string, ObjectLocation>>());
                        for (var j = 0; j < idxVersionCount; j++)
                        {

                            var key                 = mySerializationReader.ReadString();
                            var idxLocation         = mySerializationReader.ReadString();
                            var indexType           = mySerializationReader.ReadString();

                            _AttributeIndexLocations[idxKey][key] = new Tuple<string,ObjectLocation>(indexType, new ObjectLocation(idxLocation));

                            //idx.IndexKeyDefinition  = idxKey;
                            //AddAttributeIndex(idx as AAttributeIndex);

                        }

                    }

                    #endregion

                }

                catch (Exception e)
                {
                    throw new SerializationException("The GraphDBType could not be deserialized!\n\n" + e);
                }

            }
        }