/// <summary> /// The run method, runs your example design pattern /// and gathers output for the Console in the /// passed in StringBuilder. /// </summary> /// <param name="builder">The StringBuilder to gather output for the Console.</param> public override void Run(StringBuilder builder) { base.Run(builder); lock (builder) { builder.AppendLine( JsonConvert.SerializeObject( _factoryMethod.Create(), Formatting.Indented)); } }
public T Create <T>(object obj) { IFactoryMethod <T> method = this as IFactoryMethod <T>; if (method != null) { return(method.Create(obj)); } throw new NotImplementedException(String.Format("Factory method for type {0} not implemented.", typeof(T).ToString())); }