fCraft.Color.Parse C# (CSharp) Method

Parse() private method

private Parse ( char code ) : string
code char
return string
        public static string Parse( char code ) {
            code = Char.ToLower( code );
            if ( IsValidColorCode( code ) ) {
                return "&" + code;
            } else {
                switch ( code ) {
                    case 's':
                        return Sys;
                    case 'y':
                        return Say;
                    case 'p':
                        return PM;
                    case 'r':
                        return Announcement;
                    case 'h':
                        return Help;
                    case 'w':
                        return Warning;
                    case 'm':
                        return Me;
                    case 'i':
                        return IRC;
                    default:
                        return null;
                }
            }
        }

Same methods

Color::Parse ( int index ) : string
Color::Parse ( string color ) : string

Usage Example

 public override void Validate(string value)
 {
     base.Validate(value);
     if (Color.Parse(value) == null)
     {
         throw new FormatException("Value cannot be parsed as a color.");
     }
     else if (Color.Parse(value).Length == 0 && NotBlank)
     {
         throw new FormatException("Value may not represent absence of color.");
     }
 }
All Usage Examples Of fCraft.Color::Parse