internal static TokenizerState <T> NewState <T>(TokenizerArgs args) where T : class, new() { T instance = new T(); IHasTokenDefinition htd = instance as IHasTokenDefinition; TokenizerDefinition def = null; if (htd != null) { def = htd.GetTokenizerDefinition(args); } if (def == null) { def = StaticTokenizerDefinition <T> .Definition; } return(new TokenizerState <T>(instance, def, args, true)); }
internal static TokenizerState <T> NewState <T>(TokenizerArgs args, T instance) where T : class, new() { if (instance == null) { throw new ArgumentNullException("instance"); } IHasTokenDefinition htd = instance as IHasTokenDefinition; TokenizerDefinition def = null; if (htd != null) { def = htd.GetTokenizerDefinition(args); } if (def == null) { def = StaticTokenizerDefinition <T> .Definition; } return(new TokenizerState <T>(instance, def, args, false)); }