本文整理汇总了C#中ISubject.AddObserver方法的典型用法代码示例。如果您正苦于以下问题:C# ISubject.AddObserver方法的具体用法?C# ISubject.AddObserver怎么用?C# ISubject.AddObserver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISubject
的用法示例。
在下文中一共展示了ISubject.AddObserver方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BicycleObserver
public BicycleObserver(Label displayLabel, ISubject bicycleSubject)
{
this.displayLabel = displayLabel;
RPM = 0;
currentValue = 0;
bicycleSubject.AddObserver(this);
}
示例2: BicycleObserver
/// <summary>
/// Constructor - initialises the label responsible for displaying
/// computed results, and the subject which will push information
/// to the observers.
/// </summary>
/// <param name="displayLabel">The label to display computed results.</param>
/// <param name="bikeSubject">The subject to push notifications to it's observers.</param>
public BicycleObserver(Label displayLabel, ISubject bikeSubject)
{
this.displayLabel = displayLabel;
this.bikeSubject = bikeSubject;
currentRPM = 0;
currentComputedValue = 0.0;
///<summary>
///Ensuring that the observer is added to the subject
///on creation.
///</summary>
bikeSubject.AddObserver(this);
}
示例3: Observer
public Observer(ListBox display, ISubject subject)
{
this.display = display;
this.subject = subject;
// IMPORTANT
subject.AddObserver(this);
}
示例4: Observer
public Observer(ListBox display, ISubject subject)
{
this.display = display;
this.subject = subject;
temp = humidity = bPressure = 0;
// IMPORTANT
subject.AddObserver(this);
}
示例5: Observer
public Observer(ISubject subject, string name, string gap)
{
this.subject = subject;
this.name = name;
this.gap = gap;
subject.AddObserver(this);
}
示例6: Observer
public Observer(Label displayLabel, ISubject bikeSubject)
{
this.displayLabel = displayLabel;
this.bikeSubject = bikeSubject;
currentRPM = 0;
currentComputedValue = 0;
// IMPORTANT
bikeSubject.AddObserver(this);
}
示例7: FancyMP3Display
public FancyMP3Display(MP3Player player)
{
this.player = player;
player.AddObserver(this);
}
示例8: SimpleMP3Display
public SimpleMP3Display(MP3Player player)
{
this.player = player;
player.AddObserver(this);
}