// ReSharper disable once UnusedMember.Local internal static ClassCommand <TInstanceCmd> Create <TInstanceCmd>(Func <ICommandContext, TInstanceCmd> factory) where TInstanceCmd : ICommandInstance { var descriptor = ClassCommandDescriptor <TInstanceCmd> .Build(); var parameters = ReadParameters <TInstanceCmd>(); var cmd = new ClassCommand <TInstanceCmd>(descriptor, factory ?? DefaultInstanceFactory <TInstanceCmd>, parameters) { Group = descriptor.GroupName }; return(cmd); }
public void ExecuteClassCommandWithEmptyMethod() { BindingEnvironment environment = new BindingEnvironment(); ClassCommand command = new ClassCommand("Spam", new DefCommand("foo", null, new PassCommand())); command.Execute(environment); var result = (DefinedClass)environment.GetValue("Spam"); Assert.AreEqual("Spam", result.Name); Assert.IsNotNull(result.GetMethod("foo")); }
public void CreateSimpleClassWithEmptyDocString() { BindingEnvironment environment = new BindingEnvironment(); ClassCommand command = new ClassCommand("Spam", new PassCommand()); command.Execute(environment); var result = environment.GetValue("Spam"); var dclass = (DefinedClass)result; Assert.IsNull(dclass.GetValue("__doc__")); Assert.IsTrue(dclass.HasValue("__doc__")); }
public void ExecuteSimpleClassCommand() { BindingEnvironment environment = new BindingEnvironment(); ClassCommand command = new ClassCommand("Spam", new PassCommand()); command.Execute(environment); var result = environment.GetValue("Spam"); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(DefinedClass)); var dclass = (DefinedClass)result; Assert.AreEqual("Spam", dclass.Name); Assert.IsNull(dclass.GetValue("__doc__")); Assert.IsTrue(dclass.HasValue("__doc__")); }
public void ExecuteClassCommandWithInheritance() { DefinedClass fooclass = new DefinedClass("Foo"); DefinedClass barclass = new DefinedClass("Bar"); BindingEnvironment environment = new BindingEnvironment(); ClassCommand command = new ClassCommand("Spam", new IExpression[] { new ConstantExpression(fooclass), new ConstantExpression(barclass) }, new PassCommand()); command.Execute(environment); var result = environment.GetValue("Spam"); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(DefinedClass)); var dclass = (DefinedClass)result; Assert.AreEqual("Spam", dclass.Name); Assert.IsNotNull(dclass.Bases); Assert.AreEqual(2, dclass.Bases.Count); Assert.AreEqual(fooclass, dclass.Bases[0]); Assert.AreEqual(barclass, dclass.Bases[1]); Assert.IsNull(dclass.GetValue("__doc__")); Assert.IsTrue(dclass.HasValue("__doc__")); }
public PersonViewModel() { this.People = new ObservableCollection <PersonModel>(); this.UpdateCommand = new ClassCommand <string>(Update); using (StreamReader reader = new StreamReader("../../Storage/Data.txt")) { string line; while ((line = reader.ReadLine()) != null) { string[] data = line.Split(','); PersonModel person = new PersonModel { FirstName = data[0], LastName = data[1], PhoneNumber = data[2], EmailAddress = data[3] }; this.People.Add(person); } } }