public string SignUpPerformer(string[] args) { var name = args[0]; var age = int.Parse(args[1]); IPerformer performer = performerFactory.CreatePerformer(name, age); var instrumetTypes = args.Skip(2).ToArray(); //List<IInstrument> instrumetsAsObj = null; //foreach (string type in instrumetTypes) //{ // IInstrument instrument = instrumentFactory.CreateInstrument(type); // instrumetsAsObj.Add(instrument); //} var instrumenti2 = instrumetTypes .Select(i => this.instrumentFactory.CreateInstrument(i)) .ToArray(); foreach (var instrument in instrumenti2) { performer.AddInstrument(instrument); } this.stage.AddPerformer(performer); return(string.Format(SignUpPerformerSuccsessully, performer.Name)); }
public string SignUpPerformer(string[] args) { string name = args[0]; int age = int.Parse(args[1]); IPerformer performer = performerFactory.CreatePerformer(name, age); IList <IInstrument> performerInstumets = new List <IInstrument>(); if (args.Length > 2) { foreach (var typeInstrument in args.Skip(2).ToList()) { IInstrument instrument = instumentFactory.CreateInstrument(typeInstrument); performer.AddInstrument(instrument); } } this.stage.AddPerformer(performer); return($"Registered performer {performer.Name}"); }