本文整理汇总了C#中EventDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# EventDescriptor类的具体用法?C# EventDescriptor怎么用?C# EventDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventDescriptor类属于命名空间,在下文中一共展示了EventDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransitionEvent
public TransitionEvent(
EventDescriptor descriptor,
params uint[] participants)
{
this.Descriptor = descriptor;
this.Participants = participants;
}
示例2: Guid
private static Guid WINDOWS_SQM_GLOBALSESSION = new Guid("95baba28-ed26-49c9-b74f-93b170e1b849"); // new Guid("{ 0x95baba28, 0xed26, 0x49c9, { 0xb7, 0x4f, 0x93, 0xb1, 0x70, 0xe1, 0xb8, 0x49 }}");
private static void FireWinSQMEvent(EventDescriptor eventDescriptor, Dictionary<int, int> dataToWrite)
{
Guid empty = Guid.Empty;
if (WinSqmEventEnabled(ref eventDescriptor, ref empty))
{
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(WINDOWS_SQM_GLOBALSESSION));
IntPtr ptr2 = Marshal.AllocHGlobal(4);
IntPtr ptr3 = Marshal.AllocHGlobal(4);
try
{
Marshal.StructureToPtr(WINDOWS_SQM_GLOBALSESSION, ptr, true);
foreach (int num in dataToWrite.Keys)
{
int structure = dataToWrite[num];
Marshal.StructureToPtr(num, ptr2, true);
Marshal.StructureToPtr(structure, ptr3, true);
FireWinSQMEvent(eventDescriptor, ptr, ptr2, ptr3);
}
}
finally
{
Marshal.FreeHGlobal(ptr);
Marshal.FreeHGlobal(ptr2);
Marshal.FreeHGlobal(ptr3);
}
}
}
示例3: FireWinSQMEvent
private static void FireWinSQMEvent(EventDescriptor eventDescriptor, IntPtr sessionHandle, IntPtr dataPointIDHandle, IntPtr dataValueHandle)
{
EventDataDescriptor descriptor = new EventDataDescriptor(sessionHandle, Marshal.SizeOf(WINDOWS_SQM_GLOBALSESSION));
EventDataDescriptor descriptor2 = new EventDataDescriptor(dataPointIDHandle, 4);
EventDataDescriptor descriptor3 = new EventDataDescriptor(dataValueHandle, 4);
EventDataDescriptor[] userData = new EventDataDescriptor[] { descriptor, descriptor2, descriptor3 };
WinSqmEventWrite(ref eventDescriptor, userData.Length, userData);
}
示例4: WriteEvent
internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, long value1)
{
byte* numPtr = stackalloc byte[(IntPtr) sizeof(System.Runtime.Interop.UnsafeNativeMethods.EventData)];
System.Runtime.Interop.UnsafeNativeMethods.EventData* dataPtr = (System.Runtime.Interop.UnsafeNativeMethods.EventData*) numPtr;
dataPtr->DataPointer = (ulong) ((IntPtr) &value1);
dataPtr->Size = 8;
return base.WriteEvent(ref eventDescriptor, 1, (IntPtr) numPtr);
}
示例5: GetApplicable
/// <summary>
/// Returns all populations that are valid for this signature
/// </summary>
private static IEnumerable<EventPopulation> GetApplicable(
EventDescriptor evtDesc,
IEnumerable<EventPopulation> candidates,
IEnumerable<IHasState> allWorldObjs)
{
foreach (EventPopulation candidate in candidates)
if (evtDesc.CheckRequirements(candidate.AsParams(), allWorldObjs) == true)
yield return candidate;
}
示例6: GetValidPopulations
/// <summary>
/// Given an enumeration of objects, assembles them into valid
/// participant populations for this event. Requires that the event
/// takes only SmartObject participants (or equivalent).
/// </summary>
public static IEnumerable<EventPopulation> GetValidPopulations(
EventDescriptor evtDesc,
IEnumerable<IHasState> objsToConsider,
IEnumerable<IHasState> allWorldObjs)
{
BinHolder bins = BinIntoParameterSlots(evtDesc, objsToConsider);
return GetApplicable(
evtDesc,
GetPopulations(evtDesc, bins),
allWorldObjs);
}
示例7: SaveEvent
private static void SaveEvent(EventDescriptor eventDescriptor, SQLiteTransaction transaction)
{
const string commandText = "INSERT INTO Events VALUES(@aggregateId, @eventData, @version)";
using (var sqLiteCommand = new SQLiteCommand(commandText, transaction.Connection, transaction))
{
sqLiteCommand.Parameters.Add(new SQLiteParameter("@aggregateId", eventDescriptor.AggregateId));
sqLiteCommand.Parameters.Add(new SQLiteParameter("@eventData", eventDescriptor.EventData));
sqLiteCommand.Parameters.Add(new SQLiteParameter("@version", eventDescriptor.Version));
sqLiteCommand.ExecuteNonQuery();
}
}
示例8: Save
public void Save(Guid aggregateId, Event @event)
{
List<EventDescriptor> list;
db.TryGetValue(aggregateId, out list);
if(list == null)
{
list = new List<EventDescriptor>();
db.Add(aggregateId, list);
}
var eventDescriptor = new EventDescriptor(@event.Id, @event, @event.Version);
list.Add(eventDescriptor);
}
示例9: SaveEvent
private async void SaveEvent(Event @event, string streamName)
{
var eventDescriptor = new EventDescriptor(Guid.NewGuid(), @event.GetType().Name, @event);
var serializedEvent = JsonConvert.SerializeObject(new EventDescriptor[] { eventDescriptor });
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:2113/streams/");
var response = await client.PostAsync(streamName, new StringContent(serializedEvent, Encoding.UTF8, "application/vnd.eventstore.events+json"));
_logger.LogInformation(string.Format("Saving event {0} to stream resulted with {1}", eventDescriptor.EventType, response.StatusCode));
}
}
示例10: ConstructorReadOnlyTests
public void ConstructorReadOnlyTests()
{
var descriptors = new EventDescriptor[]
{
new MockEventDescriptor("descriptor1")
};
var collection = new EventDescriptorCollection(descriptors, true);
Assert.Equal(descriptors, collection.Cast<EventDescriptor>());
// These methods are implemented as explicit properties so we need to ensure they are what we expect
Assert.True(((IList)collection).IsReadOnly);
Assert.True(((IList)collection).IsFixedSize);
}
示例11: BinIntoParameterSlots
/// <summary>
/// Takes a list of world SmartObjects and an EventDescriptor and creates
/// one bin for each of the event's participant slot containing the
/// objects that satisfy that slot's State (not Relation) requirements.
/// Makes sure that any index in fixedSlots only considers the accompanied
/// SmartObject. Does however not check state for those.
/// </summary>
private static BinHolder BinIntoParameterSlots(
EventDescriptor evtDesc,
IEnumerable<IHasState> objs,
IDictionary<int, IHasState> fixedSlots = null)
{
StateName[][] stateReqs = evtDesc.StateRequirements;
BinHolder bins = new BinHolder(stateReqs.Length);
for (int i = 0; i < stateReqs.Length; i++)
{
if (fixedSlots != null && fixedSlots.ContainsKey(i) == true)
bins.AddBin(new IHasState[] { fixedSlots[i] });
else
bins.AddBin(Filter.ByState(objs, stateReqs[i]));
}
return bins;
}
示例12: Explore
public IEnumerable Explore(WorldState initial, EventDescriptor[] evtDescs)
{
List<ExplorationNode> stateSpace = new List<ExplorationNode>();
this.status = ExplorationStatus.Exploring;
foreach (var step in Step_Exploring(initial, evtDescs, stateSpace))
{
exploredNodes = stateSpace.Count;
if (exploredNodes > MAX_NODES)
break;
yield return null;
}
// TODO: Temporarily disabling expanding..
//this.status = Status.Expanding;
//foreach (var step in Step_Expanding(stateSpace))
// yield return null;
this.status = ExplorationStatus.PageRank;
foreach (var step in Step_PageRanking(stateSpace, 0.85, 200, 5, 0.01))
yield return null;
this.status = ExplorationStatus.InversePageRank;
foreach (var step in Step_InversePageRanking(stateSpace, 0.85, 200, 5, 0.01))
yield return null;
this.status = ExplorationStatus.Path;
#if !GPU
foreach (var step in Step_Pathing(stateSpace))
yield return null;
#else
Console.WriteLine("\nProcessing paths on GPU...");
Crunch.GPUGraphUtil.GPUPath(stateSpace);
#endif
//this.status = ExplorationStatus.MinCut;
//foreach (var step in Step_MinCut(stateSpace))
// yield return null;
this.status = ExplorationStatus.Done;
this.space = new ExplorationSpace(stateSpace);
yield break;
}
示例13: SaveEventsInternal
private void SaveEventsInternal(IEnumerable<DomainEvent> events, ITapeStream stream, int version)
{
var array = events.ToArray();
foreach (var @event in array)
{
@event.Version = ++version;
byte[] bytes;
using (var buffer = new MemoryStream())
{
var descriptor = new EventDescriptor(@event);
serializer.Serialize(descriptor, buffer);
bytes = buffer.ToArray();
}
stream.TryAppend(bytes, TapeAppendCondition.None);
}
sender.SendBatch(array);
}
示例14: WriteTransferEvent
protected bool WriteTransferEvent(ref EventDescriptor eventDescriptor, Guid relatedActivityId, int dataCount, IntPtr data)
{
uint status = 0;
Guid activityId = GetActivityId();
unsafe
{
status = UnsafeNativeMethods.EventWriteTransfer(
m_regHandle,
ref eventDescriptor,
(activityId == Guid.Empty) ? null : &activityId,
&relatedActivityId,
(uint)dataCount,
(void*)data);
}
if (status != 0)
{
SetLastError((int)status);
return false;
}
return true;
}
示例15: WriteEvent
public bool WriteEvent(ref EventDescriptor eventDescriptor, string data)
{
uint status = 0;
if (data == null)
{
throw new ArgumentNullException("dataString");
}
if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
{
if (data.Length > s_traceEventMaximumStringSize)
{
t_returnCode = WriteEventErrorCode.EventTooBig;
return false;
}
EventData userData;
userData.Size = (uint)((data.Length +1)* 2);
userData.Reserved = 0;
unsafe
{
fixed (char* pdata = data)
{
Guid activityId = GetActivityId();
userData.DataPointer = (ulong)pdata;
if (s_preWin7)
{
status = UnsafeNativeMethods.EventWrite(m_regHandle,
ref eventDescriptor,
1,
&userData);
}
else
{
status = UnsafeNativeMethods.EventWriteTransfer(m_regHandle,
ref eventDescriptor,
(activityId == Guid.Empty) ? null : &activityId,
null,
1,
&userData);
}
}
}
}
if (status != 0)
{
SetLastError((int)status);
return false;
}
return true;
}