protected string BClassFileName(IBClass bClass) { StringBuilder sb = new StringBuilder(); sb.Append(HelpMeReflect.AttributeStringData(bClass.GetType(), typeof(BClass), "Description")); sb.Append(".txt"); return(sb.ToString()); }
public PropertyUpdateDetailMenu(PropertyInfo property, Object obj) : base(TITEL_TEMPLATE, new List <string>()) { this.BPropertyAttr = HelpMeReflect.AttributeOfType <BProperty>(property); this.Titel = TITEL_TEMPLATE.Replace(PLACEHOLDER, this.BPropertyAttr.Description); this.Property = property; this.Obj = obj; this.Old = HelpMeReflect.PropertyValueString(obj, property); }
protected string BClassToString(IBClass bClass) { List <PropertyInfo> properties = HelpMeReflect.PropertiesWithBPropertyAttribute(bClass.GetType()); StringBuilder sb = new StringBuilder(); foreach (PropertyInfo property in properties) { string propertyName = HelpMeReflect.AttributeOfType <BProperty>(property).Description; string propertyValue = HelpMeReflect.PropertyValueString(bClass, property); sb.Append($"{propertyName}={propertyValue}{DELIMITER}"); } return(sb.ToString()); }
private void Configure() { // Type argument Type typeArgument = this.GetType().GenericTypeArguments[0]; // Menu title (=~ class type) string typeName = HelpMeReflect.AttributeStringData(typeArgument, typeof(BClass), "Description"); this.Titel = TITEL_TEMPLATE.Replace(PLACEHOLDER, typeName); // Menu options (=~ class properties) this.bProperties = HelpMeReflect.PropertiesWithBPropertyAttribute(typeArgument); this.MenuOpties = this.bProperties.Select(HelpMeReflect.AttributeOfType <BProperty>) .Select(bProp => bProp.Description) .ToList(); // Associate the order (=~ indexes shown to user) with right properties int startIndex = 1; this.bProperties.ForEach(prop => this.indexedBProperties.Add(startIndex++, prop)); }
static void Main(string[] args) { Controller controller = new Controller(); //controller.Run(); Afbeelding afbeelding = new Afbeelding(); afbeelding.Naam = "Test"; afbeelding.Path = "TestPad"; Afbeelding afbeelding2 = new Afbeelding(); afbeelding2.Naam = "Test2"; afbeelding2.Path = "TestPad2"; List <IBClass> afbeeldings = new List <IBClass>() { afbeelding2, afbeelding }; FileBClassWriter writer = new FileBClassWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); DataContext dataContext = new DataContext(writer); dataContext.Add(afbeelding); Console.ReadLine(); dataContext.Add(afbeelding2); Console.ReadLine(); dataContext.Delete(afbeelding); Console.ReadLine(); List <PropertyInfo> properties = HelpMeReflect.PropertiesWithBPropertyAttribute(typeof(Afbeelding)); PropertyInfo naamPropertyInfo = properties.Find(prop => prop.GetCustomAttribute <BProperty>().Description.Equals("Naam")); dataContext.Update(afbeelding2, naamPropertyInfo, "Veranderde naam"); Console.ReadLine(); Console.ReadLine(); }