示例#1
0
        public void ParseWith(FeaturesSetting setting)
        {
            if (!string.IsNullOrWhiteSpace(Default))
            {
                Enabled = (setting.GS >= GetGS(Default));
            }

            if (!string.IsNullOrWhiteSpace(Enable))
            {
                var match = Regex.Match(Enable, @"G[^,@]*@" + setting.Locale);
                if (match.Success)
                {
                    Enabled = (setting.GS >= GetGS(match.Groups[0].Value));
                }
            }

            if (!string.IsNullOrWhiteSpace(Disable))
            {
                var match = Regex.Match(Disable, @"G[^,@]*@" + setting.Locale);
                if (match.Success)
                {
                    Enabled = (setting.GS < GetGS(match.Groups[0].Value));
                }
            }
        }
示例#2
0
        private void LoadFromCompiled(Stream stream, string settingName)
        {
            var buffer = new byte[0x100];
            var num    = 0;

            if (stream.Read(buffer, 0, 2) != 2)
            {
                throw new EndOfStreamException();
            }

            var settings = new List <FeaturesSetting>();

            var settingCount = BitConverter.ToUInt16(buffer, 0);

            for (int i = 0; i < settingCount; i++)
            {
                var fSetting = new FeaturesSetting();

                if (stream.Read(buffer, 0, 2) != 2)
                {
                    throw new EndOfStreamException();
                }

                num = BitConverter.ToUInt16(buffer, 0);
                if ((num <= 0) || (num > 0x100))
                {
                    throw new NotSupportedException();
                }

                if (stream.Read(buffer, 0, num) != num)
                {
                    throw new EndOfStreamException();
                }

                for (int k = 0; k < num; k++)
                {
                    buffer[k] = (byte)(buffer[k] ^ 0x80);
                }

                fSetting.Name = Encoding.UTF8.GetString(buffer, 0, num);

                if (stream.Read(buffer, 0, 2) != 2)
                {
                    throw new EndOfStreamException();
                }

                num = BitConverter.ToUInt16(buffer, 0);
                if (num <= 0 || num > 0x100)
                {
                    throw new NotSupportedException();
                }

                if (stream.Read(buffer, 0, num) != num)
                {
                    throw new EndOfStreamException();
                }

                for (int m = 0; m < num; m++)
                {
                    buffer[m] = (byte)(buffer[m] ^ 0x80);
                }

                fSetting.Locale = Encoding.UTF8.GetString(buffer, 0, num);

                if (stream.Read(buffer, 0, 3) != 3)
                {
                    throw new EndOfStreamException();
                }

                fSetting.Generation  = buffer[0];
                fSetting.Season      = buffer[1];
                fSetting.Subseason   = (byte)(buffer[2] >> 2);
                fSetting.Test        = (buffer[2] & 1) != 0;
                fSetting.Development = (buffer[2] & 2) != 0;

                settings.Add(fSetting);
            }

            setting = settings.FirstOrDefault(a => a.Name == settingName);
            if (setting == null)
            {
                throw new ArgumentException("Unknown setting '" + settingName + "'.");
            }

            if (stream.Read(buffer, 0, 2) != 2)
            {
                throw new EndOfStreamException();
            }

            var featureCount = BitConverter.ToUInt16(buffer, 0);

            for (int j = 0; j < featureCount; j++)
            {
                var fFeature = new FeaturesFeature();

                if (stream.Read(buffer, 0, 4) != 4)
                {
                    throw new EndOfStreamException();
                }

                fFeature.Hash = BitConverter.ToUInt32(buffer, 0);

                if (stream.Read(buffer, 0, 2) != 2)
                {
                    throw new EndOfStreamException();
                }

                num = BitConverter.ToUInt16(buffer, 0);
                if (num > 0x100)
                {
                    throw new NotSupportedException();
                }

                if (num > 0)
                {
                    if (stream.Read(buffer, 0, num) != num)
                    {
                        throw new EndOfStreamException();
                    }

                    for (int n = 0; n < num; n++)
                    {
                        buffer[n] = (byte)(buffer[n] ^ 0x80);
                    }

                    fFeature.Default = Encoding.UTF8.GetString(buffer, 0, num);
                }

                if (stream.Read(buffer, 0, 2) != 2)
                {
                    throw new EndOfStreamException();
                }

                num = BitConverter.ToUInt16(buffer, 0);
                if (num > 0x100)
                {
                    throw new NotSupportedException();
                }

                if (num > 0)
                {
                    if (stream.Read(buffer, 0, num) != num)
                    {
                        throw new EndOfStreamException();
                    }

                    for (int num9 = 0; num9 < num; num9++)
                    {
                        buffer[num9] = (byte)(buffer[num9] ^ 0x80);
                    }

                    fFeature.Enable = Encoding.UTF8.GetString(buffer, 0, num);
                }

                if (stream.Read(buffer, 0, 2) != 2)
                {
                    throw new EndOfStreamException();
                }

                num = BitConverter.ToUInt16(buffer, 0);
                if (num > 0x100)
                {
                    throw new NotSupportedException();
                }

                if (num > 0)
                {
                    if (stream.Read(buffer, 0, num) != num)
                    {
                        throw new EndOfStreamException();
                    }

                    for (int num10 = 0; num10 < num; num10++)
                    {
                        buffer[num10] = (byte)(buffer[num10] ^ 0x80);
                    }

                    fFeature.Disable = Encoding.UTF8.GetString(buffer, 0, num);
                }

                fFeature.ParseWith(setting);
                features.Add(fFeature);
            }
        }