I don't know if this is possible, and how it would be possible. I basicly want to use this later that like:
//setting a single item as known.
label1.BackColor=Color.FromARGB(255,255,255);
/*setting multiple items in something like a container (wanted, not yet possible)*/
sContainer.BackColor=Color.FromARGB(255,255,255);
//and that's how it works recently with my class...
sContainer.SetValues("BackColor",Color.FromARGB(255,255,255));
The container will have to use Generics and Reflection I guess. The container class should "copy" all Set-able properties of the T-Class (here Control) into itself. So if I'm using SetContainer<Control>
I can set all backcolor values in my container by sContainer1.BackColor=...
.
My code until know looks that like:
public class SetContainer<T>:IList<T>
{
/*I've implemented all methods of IList by using the elements-List*/
private List<T> elements;
public void SetValues(string propname,object value)
{
FieldInfo f=typeof(T).GetField(propname);
elements.ForEach(x=>f.SetField(x,value);
}
}
I'm sorry that I don't know how to describe this well understandable.
Aucun commentaire:
Enregistrer un commentaire