本文整理汇总了C#中SubscriptionToken类的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionToken类的具体用法?C# SubscriptionToken怎么用?C# SubscriptionToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubscriptionToken类属于命名空间,在下文中一共展示了SubscriptionToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contains
/// <summary>
/// Returns <see langword="true"/> if there is a subscriber matching <see cref="SubscriptionToken"/>.
/// </summary>
/// <param name="token">The <see cref="SubscriptionToken"/> returned by <see cref="EventBase"/> while subscribing to the event.</param>
/// <returns><see langword="true"/> if there is a <see cref="SubscriptionToken"/> that matches; otherwise <see langword="false"/>.</returns>
public virtual bool Contains(SubscriptionToken token)
{
lock (Subscriptions) {
IEventSubscription subscription = Subscriptions.FirstOrDefault(evt => evt.SubscriptionToken == token);
return subscription != null;
}
}
示例2: WhenDisposeIsCalledMoreThanOnce_ThenExceptionIsNotThrown
public void WhenDisposeIsCalledMoreThanOnce_ThenExceptionIsNotThrown()
{
SubscriptionToken token = new SubscriptionToken(t => { });
token.Dispose();
token.Dispose();
}
示例3: Equals_Should_Return_False_When_Comparing_Different_Instances
public void Equals_Should_Return_False_When_Comparing_Different_Instances()
{
SubscriptionToken token = new SubscriptionToken();
object tokenObject = new SubscriptionToken();
Assert.False(token.Equals(tokenObject));
}
示例4: EqualsShouldReturnFalseWhenComparingDifferentInstances
public void EqualsShouldReturnFalseWhenComparingDifferentInstances()
{
var aToken = new SubscriptionToken();
object anotherToken = new SubscriptionToken();
Assert.That(aToken.Equals(anotherToken), Is.False);
}
示例5: HashCodeIsTheSameForSameToken
public void HashCodeIsTheSameForSameToken()
{
SubscriptionToken token = new SubscriptionToken();
int hashCode = token.GetHashCode();
Assert.AreNotEqual(0, hashCode);
Assert.AreEqual(hashCode, token.GetHashCode());
}
示例6: Stop
public Task<bool> Stop()
{
bool returnValue = false;
try
{
// ***
// *** Unsubscribe from the event
// ***
if (_exceptionEventToken != null)
{
this.EventAggregator.GetEvent<Events.TemperatureChangedEvent>().Unsubscribe(_exceptionEventToken);
_exceptionEventToken.Dispose();
_exceptionEventToken = null;
}
// ***
// *** Release the collection items
// ***
this.Items.Clear();
returnValue = true;
}
catch (Exception ex)
{
this.EventAggregator.GetEvent<Events.DebugEvent>().Publish(new DebugEventArgs(ex));
returnValue = false;
}
return Task<bool>.FromResult(returnValue);
}
示例7: HeadPageViewModel
public HeadPageViewModel(
IEventAggregator events,
MouthViewModel mouth,
RightEyeViewModel rightEye,
LeftEyeViewModel leftEye,
NoseViewModel nose,
INavigationService navService,
MotionActivatedSimpleAnimation animation)
{
_events = events;
_actionFacialCodingEventToken = _events.GetEvent<Events.ActionFacialCodingEvent>().Subscribe((args) =>
{
this.OnActionFacialCodingCommand(args);
}, ThreadOption.UIThread);
_sensorChangedEventToken = _events.GetEvent<Events.RangeSensorEvent>().Subscribe((args) =>
{
this.OnRangeSensorChanged(args);
}, ThreadOption.UIThread);
_navService = navService;
GoBackCommand = new DelegateCommand(_navService.GoBack);
NavigateControlCommand = new DelegateCommand(() => navService.Navigate("Control", null));
HideCommand = new DelegateCommand(this.Hide);
_mouth = mouth;
_rightEye = rightEye;
_leftEye = leftEye;
_nose = nose;
_animationService = animation;
Image = new BitmapImage(new Uri(@"ms-appx:///Assets/pumpkinbackground.png", UriKind.RelativeOrAbsolute));
}
示例8: ItemListFilter
public ItemListFilter()
{
InitializeComponent();
Init();
ItemListFilterViewModel = new ItemListFilterViewModel(iEventAggregator, controls.Length);
this.DataContext = ItemListFilterViewModel;
propertyChangedMap = new Dictionary<string, Action>()
{
{ "SelectedControlIndex", () => {
SetControlSelected(controls[selectedControlIndex], false);
selectedControlIndex = ItemListFilterViewModel.SelectedControlIndex;
SetControlSelected(controls[selectedControlIndex], true);
}},
};
ItemListFilterViewModel.PropertyChanged += PropertyChangedHandler;
eventMap = new Dictionary<string, Action>()
{
{"FILTER_SELECT_CONTROL", SelectControl }
};
filterActionToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe(
(viewEventArgs) =>
{
EventHandler(viewEventArgs);
}
);
}
示例9: App
App()
{
iEventAggregator = Event.EventInstance.EventAggregator;
viewActionToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe(
(viewEventArgs) => { EventHandler(viewEventArgs); }
);
}
示例10: ModuleBWorkspace
public ModuleBWorkspace(IStringCopyService stringCopyService)/*IEventAggregator eventAggregator*/
{
// código exclusivo para la recepción de un string a traves de un agregador de eventos.
var eventAggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
// eventAggregator.GetEvent<MyCopyDataAddedEvent>().Subscribe(OnCopyDataReceived, ThreadOption.UIThread);
var evento = eventAggregator.GetEvent<MyCopyDataAddedEvent>();
if (subscriptionToken != null)
{
evento.Unsubscribe(subscriptionToken);
}
subscriptionToken = evento.Subscribe(OnCopyDataReceived, ThreadOption.UIThread, true);
InitializeComponent();
//código exclusivo para recepción de un string a traves de un servicio compartido
stringCopyService.CopyStringEvent += TheStringCopyService_CopyStringEvent;
//código exclusivo para la recepción de datos atraves del regioncontext.
// get the region context from the current view
// (which is plugged into the region)
Microsoft.Practices.Prism.ObservableObject<object> regionContexto =
RegionContext.GetObservableContext(this);
// set an event handler to run when PropertyChanged event is fired
regionContexto.PropertyChanged += regionContext_PropertyChanged;
}
示例11: SoundQuestionWindowViewModel
public SoundQuestionWindowViewModel(IEventAggregator eventAggregator, StandingsService standingsService, InputService inputService)
: base(eventAggregator, standingsService, inputService)
{
_soundToken = ShowEvent.Subscribe(PauseStart);
_closeEvent = eventAggregator.GetEvent<CloseEvent>();
_stopToken = _closeEvent.Subscribe((o) => Dispose());
}
示例12: SearchGameDataViewModel
public SearchGameDataViewModel(string _gameQuery)
{
iEventAggregator = Event.EventInstance.EventAggregator;
SelectedCol = 0;
SelectedRow = 0;
TitleBarText = "Searching for " + _gameQuery + "...";
GameData = GameRetriever.GetGameDataSetLists(_gameQuery);
GameQuery = _gameQuery;
eventMap = new Dictionary<string, Action>()
{
{ "SEARCHGAMEDATA_MOVE_LEFT", () => { SelectedCol = SelectedCol - 1; } },
{ "SEARCHGAMEDATA_MOVE_RIGHT", () => { SelectedCol = SelectedCol + 1; } },
{ "SEARCHGAMEDATA_MOVE_UP", () => { SelectedRow = SelectedRow - 1; } },
{ "SEARCHGAMEDATA_MOVE_DOWN", () => { SelectedRow = SelectedRow + 1; } },
{ "SEARCHGAMEDATA_SELECT", SelectItem }
};
searchGameDataActionToken = iEventAggregator.GetEvent<PubSubEvent<SearchGameDataEventArgs>>().Subscribe(
(viewEventArgs) =>
{
EventHandler(this, viewEventArgs);
}
);
}
示例13: OnNavigatedTo
public void OnNavigatedTo(NavigationContext navigationContext)
{
_trackMenuBarToken = _eventAggregator.GetEvent<TrackCommandBarEvent>().Subscribe(OnTrackMenuBarEvent, true);
_tracksMenuBarToken = _eventAggregator.GetEvent<TracksCommandBarEvent>().Subscribe(OnTracksMenuBarEvent, true);
Album = navigationContext.Tag as IAlbum;
}
示例14: OnImportsSatisfied
public void OnImportsSatisfied()
{
if (_obj == null)
{
_obj = _eventAggregator.GetEvent<CompositePresentationEvent<ObservableCollection<IDataItem>>>().Subscribe(dataItemsReceived => DataService.DataItems = dataItemsReceived, true);
}
}
示例15: ItemListFilterViewModel
public ItemListFilterViewModel(IEventAggregator iEventAggregator, int _numControls)
{
this.iEventAggregator = iEventAggregator;
buttonActions = new string[] { "FILTER_RESET", "FILTER_TYPE", "FILTER_FILES" };
Filter = "";
FilterType = "Contains";
numControls = _numControls;
MoveRightCommand = new DelegateCommand(MoveRight, CanMoveRight);
MoveLeftCommand = new DelegateCommand(MoveLeft, CanMoveLeft);
RemoveLastCharFromFilterCommand = new DelegateCommand(RemoveLastCharFromFilter, CanRemoveLastCharFromFilter);
ResetFiltersCommand = new DelegateCommand(ResetFilters, CanResetFilters);
EventMap = new Dictionary<string, Action>()
{
{"FILTER_MOVE_LEFT", () =>
{
if (MoveLeftCommand.CanExecute())
{
MoveLeftCommand.Execute();
}
}
},
{"FILTER_MOVE_RIGHT", () =>
{
if (MoveRightCommand.CanExecute())
{
MoveRightCommand.Execute();
}
}
},
{"CHAR_BACK", () =>
{
if (RemoveLastCharFromFilterCommand.CanExecute())
{
RemoveLastCharFromFilterCommand.Execute();
}
}
}
};
EventMapParam = new Dictionary<string, Action<string>>()
{
{"CHAR_SELECT", AppendToFilter},
{"VOS_OPTION", (_filterType) =>
{
FilterType = _filterType;
}
}
};
filterViewToken = this.iEventAggregator.GetEvent<PubSubEvent<ViewEventArgs>>().Subscribe(
(viewEventArgs) =>
{
EventHandler(viewEventArgs);
}
);
}