コード例 #1
0
ファイル: IPBanInfo.cs プロジェクト: TheDireMaster/fCraft
        internal static IPBanInfo LoadFormat2([NotNull] string[] fields)
        {
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }
            if (fields.Length != 8)
            {
                throw new ArgumentException("Unexpected field count", "fields");
            }
            IPBanInfo info = new IPBanInfo {
                Address  = IPAddress.Parse(fields[0]),
                BannedBy = FlatfilePlayerDBProvider.Unescape(fields[1])
            };

            fields[2].ToDateTime(out info.BanDate);
            if (fields[3].Length > 0)
            {
                info.BanReason = FlatfilePlayerDBProvider.Unescape(fields[3]);
            }
            if (fields[4].Length > 0)
            {
                info.PlayerName = FlatfilePlayerDBProvider.Unescape(fields[4]);
            }

            Int32.TryParse(fields[5], out info.Attempts);
            info.LastAttemptName = FlatfilePlayerDBProvider.Unescape(fields[6]);
            fields[7].ToDateTime(out info.LastAttemptDate);

            return(info);
        }
コード例 #2
0
ファイル: IPBanInfo.cs プロジェクト: TheDireMaster/fCraft
        internal static IPBanInfo LoadFormat0([NotNull] string[] fields, bool convertDatesToUtc)
        {
            if (fields == null)
            {
                throw new ArgumentNullException("fields");
            }
            if (fields.Length != 8)
            {
                throw new ArgumentException("Unexpected field count", "fields");
            }
            IPBanInfo info = new IPBanInfo {
                Address  = IPAddress.Parse(fields[0]),
                BannedBy = FlatfilePlayerDBProvider.UnescapeOldFormat(fields[1])
            };

            FlatfilePlayerDBProvider.TryParseLocalDate(fields[2], out info.BanDate);
            info.BanReason = FlatfilePlayerDBProvider.UnescapeOldFormat(fields[3]);
            if (fields[4].Length > 1)
            {
                info.PlayerName = FlatfilePlayerDBProvider.UnescapeOldFormat(fields[4]);
            }

            info.Attempts        = Int32.Parse(fields[5]);
            info.LastAttemptName = FlatfilePlayerDBProvider.UnescapeOldFormat(fields[6]);
            FlatfilePlayerDBProvider.TryParseLocalDate(fields[7], out info.LastAttemptDate);

            if (convertDatesToUtc)
            {
                if (info.BanDate != DateTime.MinValue)
                {
                    info.BanDate = info.BanDate.ToUniversalTime();
                }
                if (info.LastAttemptDate != DateTime.MinValue)
                {
                    info.LastAttemptDate = info.LastAttemptDate.ToUniversalTime();
                }
            }

            return(info);
        }