I found the following code snippet which puzzled me.
public class Bclass : Aclass
{
public const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
public Bclass(IAclass a) : base(string.Empty)
{
var destFields = this.GetType().BaseType.GetFields( Flags );
a.GetType().GetFields( Flags ).Where(x => destFields.Contains(x)).ToList().ForEach(property =>
{
destFields.First(x => x == property).SetValue(this, property.GetValue(a));
});
var destProperties = this.GetType().BaseType.GetProperties( Flags );
a.GetType().GetProperties( Flags ).Where(x => destProperties.Contains(x)).ToList().ForEach(property =>
{
destProperties.First(x => x == property).SetValue(this, property.GetValue(a, null));
});
}
// some more methods...
}
I may have some idea what it does... (leaving it to you as a riddle and to check if I am not missing anything)
My main Q is.... why would anyone think of doing that... What benefit(s) can come out of this code.
(btw. we should change the title once we figure out what it does, and its value)
Aucun commentaire:
Enregistrer un commentaire