本文整理汇总了C#中EventSource类的典型用法代码示例。如果您正苦于以下问题:C# EventSource类的具体用法?C# EventSource怎么用?C# EventSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventSource类属于命名空间,在下文中一共展示了EventSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestGenericEvents
public void TestGenericEvents()
{
var a = new EventSource();
var e = new IncomingEvent<EventArgs> { Channel = "a", DataObject = new EventArgs { Id = 10 }, EventName = "foo" };
(e as IncomingEvent).Data = "{id:10}";
var events = new List<IIncomingEvent>();
a.EventEmitted += (sender, evt) =>
{
Assert.AreEqual(evt.Channel, e.Channel);
Assert.AreEqual(evt.Data, e.Data);
Assert.AreEqual(evt.EventName, e.EventName);
events.Add(evt);
};
a.GetEventSubscription<EventArgs>().EventEmitted += (sender, evt) =>
{
Assert.AreEqual(evt.Channel, e.Channel);
Assert.AreEqual(evt.Data, e.Data);
Assert.AreEqual(evt.DataObject.Id, e.DataObject.Id);
Assert.AreEqual(evt.EventName, e.EventName);
events.Add(evt);
};
a.EmitEvent(e);
Assert.AreEqual(events.Count, 2, "Event should get through twice when you have two subscriptions");
}
开发者ID:luiseduardohdbackup,项目名称:Pusher.NET,代码行数:28,代码来源:EventsTest.cs
示例2: 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();
}
}
开发者ID:NuPattern,项目名称:NuPattern,代码行数:27,代码来源:Misc.cs
示例3: TestEventSource
public TestEventSource(EventSource r)
{
if (r != null)
source = r;
else
source = new EventSource();
}
开发者ID:nbIxMaN,项目名称:MQTESTS,代码行数:7,代码来源:TestEventSource.cs
示例4: BuildSourceFromDataBaseData
public static TestEventSource BuildSourceFromDataBaseData(string idReferral)
{
using (NpgsqlConnection connection = Global.GetSqlConnection())
{
string findPatient = "SELECT is_referral_review_source_mo, referral_creation_date, planned_date, referral_out_date, referral_review_date_source_mo FROM public.referral WHERE id_referral = '" + idReferral + "'ORDER BY id_referral DESC LIMIT 1";
NpgsqlCommand person = new NpgsqlCommand(findPatient, connection);
using (NpgsqlDataReader personFromDataBase = person.ExecuteReader())
{
EventSource p = new EventSource();
while (personFromDataBase.Read())
{
if (personFromDataBase["is_referral_review_source_mo"] != DBNull.Value)
p.IsReferralReviewed = Convert.ToBoolean(personFromDataBase["is_referral_review_source_mo"]);
if (personFromDataBase["referral_creation_date"] != DBNull.Value)
p.ReferralCreateDate = Convert.ToDateTime(personFromDataBase["referral_creation_date"]);
if (personFromDataBase["planned_date"] != DBNull.Value)
p.PlannedDate = Convert.ToDateTime(personFromDataBase["planned_date"]);
if (personFromDataBase["referral_out_date"] != DBNull.Value)
p.ReferralOutDate = Convert.ToDateTime(personFromDataBase["referral_out_date"]);
if (personFromDataBase["referral_review_date_source_mo"] != DBNull.Value)
p.ReferralReviewDate = Convert.ToDateTime(personFromDataBase["referral_review_date_source_mo"]);
TestEventSource pers = new TestEventSource(p);
return pers;
}
}
}
return null;
}
开发者ID:nbIxMaN,项目名称:MQTESTS,代码行数:28,代码来源:TestEventSource.cs
示例5: OnEventSourceCreated
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (!this.Disabled)
{
this.EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords) ~0);
}
}
开发者ID:TylerAngell,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:7,代码来源:BufferingEventListener.cs
示例6: OnEventSourceCreated
protected override void OnEventSourceCreated(EventSource eventSource)
{
// There is a bug in the EventListener library that causes this override to be called before the object is fully constructed.
// So if we are not constructed yet, we will just remember the event source reference. Once the construction is accomplished,
// we can decide if we want to handle a given event source or not.
// Locking on 'this' is generally a bad practice because someone from outside could put a lock on us, and this is outside of our control.
// But in the case of this class it is an unlikely scenario, and because of the bug described above,
// we cannot rely on construction to prepare a private lock object for us.
lock (this)
{
if (!this.constructed)
{
if (this.eventSourcesPresentAtConstruction == null)
{
this.eventSourcesPresentAtConstruction = new List<EventSource>();
}
this.eventSourcesPresentAtConstruction.Add(eventSource);
}
else if (!this.Disabled)
{
EnableEventSource(eventSource);
}
}
}
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:26,代码来源:BufferingEventListener.cs
示例7: OnEventSourceCreated
protected override void OnEventSourceCreated(EventSource eventSource)
{
if (eventSource.Name.StartsWith("Microsoft-ApplicationInsights-", StringComparison.Ordinal))
{
this.EnableEvents(eventSource, this.logLevel, (EventKeywords)AllKeyword);
}
base.OnEventSourceCreated(eventSource);
}
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:9,代码来源:DiagnosticsEventListener.cs
示例8: Log
public void Log(EventSource eventSource, Exception exception, EventId eventId, EventLogEntryType logEntryType)
{
if (!EventLog.SourceExists(eventSource.ToString()))
{
EventLog.CreateEventSource(eventSource.ToString(), "TrainSurfer");
}
EventLog log = new EventLog();
log.Source = eventSource.ToString();
log.WriteEntry(FormatException(exception), logEntryType, (int)eventId);
}
开发者ID:vyrcoop,项目名称:TrainSurfing,代码行数:10,代码来源:Logger.cs
示例9: CreateEvent
public static int CreateEvent (EventSource eventSource, EventType eventType, int actingPersonId,
int organizationId,
int geographyId, int affectedPersonId, int parameterInt, string parameterText)
{
//TODO: organizationId comes in hardcoded as 1 from a lot of places, should probably be changed based on affected person
// to the party for that country if not swedish.
return SwarmDb.GetDatabaseForWriting().CreateEvent(eventSource, eventType, actingPersonId, organizationId,
geographyId, affectedPersonId, parameterInt, parameterText);
}
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:10,代码来源:PWEvents.cs
示例10: WhenWeakTargetCollected_ThenWeakReferenceNotAlive
public void WhenWeakTargetCollected_ThenWeakReferenceNotAlive()
{
var source = new EventSource();
var weak = new WeakReference(source);
source = null;
GC.Collect();
Assert.False(weak.IsAlive);
}
开发者ID:NuPattern,项目名称:NuPattern,代码行数:10,代码来源:Misc.cs
示例11: OnEventSourceCreated
/// <summary>
/// Override this method to get a list of all the eventSources that exist.
/// </summary>
protected override void OnEventSourceCreated(EventSource eventSource)
{
// Because we want to turn on every EventSource, we subscribe to a callback that triggers
// when new EventSources are created. It is also fired when the EventListner is created
// for all pre-existing EventSources. Thus this callback get called once for every
// EventSource regardless of the order of EventSource and EventListener creation.
// For any EventSource we learn about, turn it on.
EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All);
}
开发者ID:zbrad,项目名称:NLogEtw,代码行数:13,代码来源:ConsoleEventListener.cs
示例12: InstallerWillWireUpSubjectToPublicMethodInInternalListenerClass
public void InstallerWillWireUpSubjectToPublicMethodInInternalListenerClass()
{
InternalListener listener = new InternalListener();
EventSource source = new EventSource();
ReflectionInstrumentationBinder binder = new ReflectionInstrumentationBinder();
binder.Bind(source, listener);
source.Fire();
Assert.IsTrue(listener.callbackHappened);
}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:11,代码来源:ReflectionInstallerForInternalClassesFixture.cs
示例13: CreateActivistWithLogging
public static void CreateActivistWithLogging (Geography geo, Person newActivist, string logMessage, EventSource evtSrc, bool isPublic, bool isConfirmed, int orgId)
{
PWEvents.CreateEvent(evtSrc,
EventType.NewActivist,
newActivist.Identity,
orgId,
geo.Identity,
newActivist.Identity,
0,
string.Empty);
newActivist.CreateActivist(isPublic, isConfirmed);
PWLog.Write(newActivist, PWLogItem.Person, newActivist.Identity, PWLogAction.ActivistJoin, "New activist joined.", logMessage);
}
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:13,代码来源:ActivistEvents.cs
示例14: BuildLogger
/// <summary>
/// Initializes a new instance of the <see cref="BuildLogger"/> class.
/// </summary>
/// <param name="logger">The logger used by this instance. Can be <c>null</c>.</param>
/// <param name="eventSource">The event source.</param>
/// <exception cref="ArgumentNullException"><paramref name="eventSource"/> is <c>null</c>.</exception>
internal BuildLogger(ILogger logger, EventSource eventSource)
{
if (eventSource == null)
{
throw new ArgumentNullException("eventSource");
}
this.eventSource = eventSource;
if (logger != null)
{
Initialize(logger);
}
}
开发者ID:Jedzia,项目名称:BackBock,代码行数:19,代码来源:BuildLogger.cs
示例15: GetSchema
/// <summary>
/// Gets the <see cref="EventSchema"/> for the specified eventId and eventSource.
/// </summary>
/// <param name="eventId">The ID of the event.</param>
/// <param name="eventSource">The event source.</param>
/// <returns>The EventSchema.</returns>
public EventSchema GetSchema(int eventId, EventSource eventSource)
{
Guard.ArgumentNotNull(eventSource, "eventSource");
IReadOnlyDictionary<int, EventSchema> events;
if (!this.schemas.TryGetValue(eventSource.Guid, out events))
{
events = new ReadOnlyDictionary<int, EventSchema>(this.schemaReader.GetSchema(eventSource));
this.schemas[eventSource.Guid] = events;
}
return events[eventId];
}
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:20,代码来源:EventSourceSchemaCache.cs
示例16: EnsureInstall
/// <summary>
/// Install the ETW manifest if needed.
/// </summary>
/// <param name="eventSource"></param>
internal static bool EnsureInstall(EventSource eventSource)
{
if (IsInstalled(eventSource))
{
return true;
}
if (DoInstall(eventSource))
{
return IsInstalled(eventSource);
}
return false;
}
开发者ID:PauloFer1,项目名称:ampm-samples,代码行数:18,代码来源:EventSourceInstaller.cs
示例17: TerminateActivistWithLogging
public static void TerminateActivistWithLogging (Person p, EventSource eventSourceSignupPage)
{
int orgId = 1;
PWEvents.CreateEvent(eventSourceSignupPage,
EventType.LostActivist,
p.Identity,
orgId,
p.Geography.Identity,
p.Identity,
0,
string.Empty);
p.TerminateActivist();
PWLog.Write(PWLogItem.Person, p.Identity, PWLogAction.ActivistLost, "Lost as activist", string.Empty);
}
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:14,代码来源:ActivistEvents.cs
示例18: channel_ItemsAddedEvent
/// <summary>
/// Intercept call to gaether locally items for filtering.
/// </summary>
protected override void channel_ItemsAddedEvent(EventSource source, EventSourceChannel channel, IEnumerable<EventBase> items)
{
foreach (RssNewsEvent item in items)
{
if ((DateTime.Now - item.DateTime) < TimeSpan.FromDays(7)
&& _latestNewsItemsTitles.ContainsKey(item.Title) == false)
{// Gather items from the last 3 days.
lock (this)
{
_latestNewsItemsTitles.Add(item.Title, item);
}
}
}
base.channel_ItemsAddedEvent(source, channel, items);
}
开发者ID:redrhino,项目名称:DotNetConnectTerminal,代码行数:19,代码来源:BloombergNewsSource.cs
示例19: InputManager
public InputManager(Game game)
: base(game)
{
CursorCentered = true;
EventsFired = new[]
{
EventConstants.MousePositionUpdated,
EventConstants.LeftMouseDown,
EventConstants.LeftMouseUp,
EventConstants.RightMouseDown,
EventConstants.RightMouseUp,
EventConstants.KeyDown,
EventConstants.KeyUp
};
m_eventSourceImpl = new EventSource(EventsFired, true);
}
开发者ID:HaKDMoDz,项目名称:4DBlockEngine,代码行数:16,代码来源:InputManager.cs
示例20: WhenSourceEventRaised_ThenSubscriberIsNotified
public void WhenSourceEventRaised_ThenSubscriberIsNotified()
{
var source = new EventSource();
var publisher = new EventPublisher(source);
var subscriber = new EventSubscriber();
publisher.PropertyChanged.Subscribe(subscriber.OnChanged);
Assert.Equal(0, EventSubscriber.ChangedProperties.Count);
source.RaisePropertyChanged("Foo");
Assert.Equal(1, EventSubscriber.ChangedProperties.Count);
Assert.Equal("Foo", EventSubscriber.ChangedProperties[0]);
}
开发者ID:NuPattern,项目名称:NuPattern,代码行数:16,代码来源:Misc.cs
注:本文中的EventSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论