fCraft.FlatfilePlayerDBProvider.UnescapeOldFormat C# (CSharp) Method

UnescapeOldFormat() public static method

public static UnescapeOldFormat ( [ str ) : string
str [
return string
        public static string UnescapeOldFormat( [NotNull] string str ) {
            if( str == null ) throw new ArgumentNullException( "str" );
            return str.Replace( '\xFF', ',' ).Replace( "\'", "'" ).Replace( @"\\", @"\" );
        }

Usage Example

Example #1
0
        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);
        }