INotifyPropertyChanged -- Sisyphusarbeit?

07/04/2008 - 18:38 von Markus Springweiler | Report spam
Hallo,

hat die neue C#3.0 Version da keine Vereinfachung? Das ist doch totaler
Bullshit. Sorry, falsch, schlimmer als Bullshit. Wozu versucht man alles
typsicher zu machen, wenn man dann reihenweise Strings herumreichen muss?

/\/\arkus.
 

Lesen sie die antworten

#1 Markus Springweiler
07/04/2008 - 19:01 | Warnen spam
Ergànzung:

hat die neue C#3.0 Version da keine Vereinfachung?



Falls jemandem unklar sein sollte, was ich meine:

In einer benutzerfreundlichen Programmiersprache (z.B. Chrome) schreibe
ich:

TestKlasse = class
private
public
property Test1: String; notify;
property Test2: Guid; notify;
property Test3: Integer; notify;
end;

und erhalte folgendes (Dekompilation mittels Reflector):

internal class TestKlasse : INotifyPropertyChanged, INotifyPropertyChanging
{
private PropertyChangedEventHandler @e_PropertyChanged;
private PropertyChangingEventHandler @e_PropertyChanging;
private string @p_Test1;
private Guid @p_Test2;
private int @p_Test3;

public event PropertyChangedEventHandler PropertyChanged
{
add
{
= Delegate.Combine(, value) as PropertyChangedEventHandler;
}
remove
{
= Delegate.Remove(, value) as PropertyChangedEventHandler;
}
}

void raise_PropertyChanged(TestKlasse sender, PropertyChangedEventArgs e)
{
if ( != null)
{
(sender, e);
}
}

public event PropertyChangingEventHandler PropertyChanging
{
add
{
= Delegate.Combine(, value) as PropertyChangingEventHandler;
}
remove
{
= Delegate.Remove(, value) as PropertyChangingEventHandler;
}
}
void raise_PropertyChanging(TestKlasse sender, PropertyChangingEventArgs e)
{
if ( != null)
{
(sender, e);
}
}

public string Test1
{
get
{
return ;
}
set
{
if (value != )
{
this.raise_PropertyChanging(this, new PropertyChangingEventArgs("Test1"));
= value;
this.raise_PropertyChanged(this, new PropertyChangedEventArgs("Test1"));
}
}
}

public Guid Test2
{
get
{
return ;
}
set
{
if (value != )
{
this.raise_PropertyChanging(this, new PropertyChangingEventArgs("Test2"));
= value;
this.raise_PropertyChanged(this, new PropertyChangedEventArgs("Test2"));
}
}
}

public int Test3
{
get
{
return ;
}
set
{
if (value != )
{
this.raise_PropertyChanging(this, new PropertyChangingEventArgs("Test3"));
= value;
this.raise_PropertyChanged(this, new PropertyChangedEventArgs("Test3"));
}
}
}
}


/\/\arkus.

Ähnliche fragen