本文整理汇总了C#中EventPublisher类的典型用法代码示例。如果您正苦于以下问题:C# EventPublisher类的具体用法?C# EventPublisher怎么用?C# EventPublisher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventPublisher类属于命名空间,在下文中一共展示了EventPublisher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
m_behaviour = GetComponent<CartoonBehaviour>();
m_spinRate = m_behaviour.m_spinRate;
m_content = new GUIContent(m_text);
eventPublisher = ObjectFinder.FindOrCreateComponent<EventPublisher>();
}
示例2: GetCategoryService
private ICategoryService GetCategoryService(UnitOfWork uow) {
ICategoryRepository cateRepo = new CategoryRepository(uow);
IState request = new DummyRequest();
ILogger logger = new ConsoleLogger();
IUserRepository userRepo = new UserRepository(uow);
User user = userRepo.Create(new User {
Name = "D. Ummy",
ProviderId = "12345678",
FullName = "Mr. Doh Ummy",
EmailAddress = "[email protected]",
Culture = "th-TH",
TimeZone = "GMT Standard Time"
});
List<IEventSubscriber> subscribers = new List<IEventSubscriber>();
IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request);
IUserProvider userProvider = new DummyUserProvider(user);
IPermissionService permService = new PermissionService();
return new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService);
}
示例3: WhenSourceEventRaised_ThenCollectedSubscriberIsNotNotified
public void WhenSourceEventRaised_ThenCollectedSubscriberIsNotNotified()
{
var source = new EventSource();
var publisher = new EventPublisher(source);
var subscriber = new EventSubscriber();
var subscription = publisher.PropertyChanged.Subscribe(subscriber.OnChanged);
try
{
subscriber = null;
subscription.Dispose();
GC.Collect();
GC.WaitForFullGCApproach(-1);
GC.WaitForFullGCComplete(-1);
GC.WaitForPendingFinalizers();
source.RaisePropertyChanged("Foo");
Assert.Equal(0, EventSubscriber.ChangedProperties.Count);
}
finally
{
//subscription.Dispose();
}
}
示例4: GetPostService
private void GetPostService(UnitOfWork uow, out ICategoryService categoryService, out IForumService forumService, out ITopicService topicService, out IPostService postService) {
ICategoryRepository cateRepo = new CategoryRepository(uow);
IForumRepository forumRepo = new ForumRepository(uow);
ITopicRepository topicRepo = new TopicRepository(uow);
IPostRepository postRepo = new PostRepository(uow);
IForumConfigurationRepository configRepo = new ForumConfigurationRepository(uow);
IState request = new DummyRequest();
ILogger logger = new ConsoleLogger();
IUserRepository userRepo = new UserRepository(uow);
User user = userRepo.Create(new User {
Name = "D. Ummy",
ProviderId = "12345678",
FullName = "Mr. Doh Ummy",
EmailAddress = "[email protected]",
Culture = "th-TH",
TimeZone = "GMT Standard Time"
});
List<IEventSubscriber> subscribers = new List<IEventSubscriber>();
IEventPublisher eventPublisher = new EventPublisher(subscribers, logger, request);
IUserProvider userProvider = new DummyUserProvider(user);
IPermissionService permService = new PermissionService();
IForumConfigurationService confService = new ForumConfigurationService(configRepo);
categoryService = new CategoryService(userProvider, cateRepo, eventPublisher, logger, permService);
forumService = new ForumService(userProvider, cateRepo, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService);
topicService = new TopicService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService);
postService = new PostService(userProvider, forumRepo, topicRepo, postRepo, eventPublisher, logger, permService, confService);
}
示例5: Start
//need to have Start() so we can disable this.
void Start()
{
if (GameObject.Find ("Level") != null) {
eventPublisher = GameObject.Find ("Level").GetComponent<EventPublisher> ();
} else {
Debug.Log ("No level game object in scene: " + Application.loadedLevelName);
}
}
示例6: SubscribeToEvents
private void SubscribeToEvents()
{
_eventPublisher = new EventPublisher();
var numberCountedObserver = Observer.Create<NumberCountedEvent>(new Action<NumberCountedEvent>(OnNumberCounted));
_eventPublisher.GetEvent<NumberCountedEvent>()
.ObserveOnDispatcher()
.Subscribe(numberCountedObserver);
}
示例7: Context
protected override void Context()
{
EventPublisher publisher = new EventPublisher();
publisher.Publish(new EventData("1st"));
publisher.Publish(new EventData("2nd"));
eventData = publisher.GetMostRecentPublication<EventData>();
}
示例8: EventEnvelopeCannotBeNull
public void EventEnvelopeCannotBeNull()
{
var messageFactory = new Mock<ICreateMessages>();
var messageBus = new Mock<ISendMessages<EventEnvelope>>();
var publisher = new EventPublisher(messageFactory.Object, messageBus.Object);
var ex = Assert.Throws<ArgumentNullException>(() => publisher.Publish(HeaderCollection.Empty, null));
Assert.Equal("payload", ex.ParamName);
}
示例9: Main
private static void Main(string[] args)
{
var testEventHappened = new TestEventHappened
{
Message = "Hello Eventing World!"
};
var eventPublisher = new EventPublisher<TestEventHappened>();
eventPublisher.Publish<object>(testEventHappened);
}
示例10: HeadersCanBeNull
public void HeadersCanBeNull()
{
var messageFactory = new Mock<ICreateMessages>();
var messageBus = new Mock<ISendMessages<EventEnvelope>>();
var publisher = new EventPublisher(messageFactory.Object, messageBus.Object);
publisher.Publish(null, EventEnvelope.Empty);
messageFactory.Verify(mock => mock.Create(null, EventEnvelope.Empty), Times.Once);
messageBus.Verify(mock => mock.Send(It.IsAny<Message<EventEnvelope>>()), Times.Once);
}
示例11: EventPublisherPublish_UnitTest_RegisteredType_FindsSubjectAndInvokesOnNext
// ReSharper disable InconsistentNaming
public void EventPublisherPublish_UnitTest_RegisteredType_FindsSubjectAndInvokesOnNext()
// ReSharper restore InconsistentNaming
{
var memo = new DesignValidationMemo();
var publisher = new EventPublisher();
var subscription = publisher.GetEvent<DesignValidationMemo>().Subscribe(m => Assert.AreSame(memo, m));
publisher.Publish(memo);
subscription.Dispose();
}
示例12: EventPublisherGetEvent_UnitTest_FirstTimeForType_New
// ReSharper disable InconsistentNaming
public void EventPublisherGetEvent_UnitTest_FirstTimeForType_New()
// ReSharper restore InconsistentNaming
{
var publisher = new EventPublisher();
Assert.AreEqual(0, publisher.Count);
var actual = publisher.GetEvent<object>();
Assert.AreEqual(1, publisher.Count);
Assert.IsNotNull(actual);
Assert.IsInstanceOfType(actual, typeof(IObservable<object>));
}
示例13: Context
protected override void Context()
{
_handler = MockRepository.GenerateMock<IEventHandler<EventData>>();
IEventPublisher eventPublisher = new EventPublisher();
eventPublisher.RegisterHandler(_handler);
eventPublisher.UnregisterHandler(_handler);
eventPublisher.Publish(new EventData("My Event Data"));
}
示例14: WithEventStore
public static IApplicationServer WithEventStore(Func<ILogger, IEnumerable<IApplicationService>, ICommandRouter> routerFactory, Func<IEventStore> eventStoreFactory, IEnumerable<Func<IEventStore, IEventPublisher, IApplicationService>> appServiceFactories, Func<IEnumerable<IProjection>> projections, Func<IEnumerable<IReceptor>> receptors)
{
var logger = new ConsoleLogger();
var eventListner = new EventListener(projections());
var eventPublisher = new EventPublisher(new List<IEventListener> { eventListner }, new ReceptorSubject(receptors(), logger), logger);
var observableEventStore = new ObservableEventStore(eventStoreFactory());
var router = routerFactory(logger, appServiceFactories.Select(fac => fac(observableEventStore, eventPublisher)));
var appServer = new ApplicationServer(router, logger);
observableEventStore.Subscribe(eventPublisher);
eventPublisher.Subscribe(cmd => appServer.DispatchAsync(cmd));
return appServer;
}
示例15: Context
protected override void Context()
{
_handler = MockRepository.GenerateMock<IEventHandler<EventData>>();
_handler.Stub(h => h.Handle(null)).IgnoreArguments().Callback(delegate(EventData data)
{
_eventData = data.SomeData;
return true;
});
IEventPublisher eventPublisher = new EventPublisher();
eventPublisher.RegisterHandler(_handler);
eventPublisher.Publish(new EventData("My Event Data"));
}