Pēcis Beisikāns' Journal
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Thursday, March 12th, 2009

Subject:.net un eventi
Time:4:56 pm.
C# viss kompilējas. Vai patterns pareizi uzrakstīts?
using System.ComponentModel;

public class Zomg : INotifyPropertyChanged
{
	public event EventHandler Gloop;
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected void OnGloop(EventArgs e)
	{
		if (Gloop != null) Gloop(this, e);
	}
	
	protected void OnPropertyChanged(PropertyChangedEventArgs e)
	{
		if (PropertyChanged != null) PropertyChanged(this, e);
	}
}

C++/CLI nez kamdēļ kliedz, ka kaut kādas add un remove funkcijas nav implementētas PropertyChangedEventHandler eventam. Vai patterns pareizi uzrakstīts?
using namespace System::ComponentModel;

publc ref class Zomg : public INotifyPropertyChanged
{
public:
	event EventHandler^ Gloop;
	virtual event PropertyChangedEventHandler^ PropertyChanged; // virtual keywordu vajadzēja!
	
protected:
	virtual void OnGloop(EventArgs^ e)
	{
		Gloop(this, e);
	}
	
	virtual void OnPropertyChanged(PropertyChangedEventArgs^ e)
	{
		PropertyChanged(this, e);
	}
};
Comments: Read 12 or Add Your Own.

Pēcis Beisikāns' Journal

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.