public override bool Equals(object obj) { if (obj is TypedToken <T> ) { TypedToken <T> other = obj as TypedToken <T>; return(type.Equals(other.type) && raw.Equals(other.raw)); } else { return(false); } }
/// <summary> /// Create a FromToken object that recognizes TypedToken of a certain type. /// </summary> /// <typeparam name="T">The token type.</typeparam> /// <typeparam name="R">The result type of the FromToken</typeparam> /// <param name="type">The token type.</param> /// <param name="f">The FromRange object used to translate the recognized range to a certain result.</param> /// <returns>The FromToken object</returns> public static FromToken <R> FromTypedToken <T, R>(T type, FromRange <string, R> f) { return(delegate(Tok tok, ref R result) { object t = tok.Token; if (t is TypedToken <T> ) { TypedToken <T> tokobj = t as TypedToken <T>; if (!tokobj.Type.Equals(type)) { return false; } result = f(tok.Index, tok.Length, tokobj.Text); return true; } else { return false; } }); }