本文整理汇总了C#中ITimeProvider.GetUtcNow方法的典型用法代码示例。如果您正苦于以下问题:C# ITimeProvider.GetUtcNow方法的具体用法?C# ITimeProvider.GetUtcNow怎么用?C# ITimeProvider.GetUtcNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITimeProvider
的用法示例。
在下文中一共展示了ITimeProvider.GetUtcNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPlannedWorkgroup
public void AddPlannedWorkgroup(DrillingDepartmentId id, RequestId requestId, WorkgroupEntity we, ITimeProvider provider)
{
// Create the Planned Workgroup
DoWork("Create a Planned Workgroup and add to the Drilling Department Structure");
RecordAndRealizeThat(new PlannedWorkgroupAddedToDepartment(id, requestId, we, provider.GetUtcNow()));
}
示例2: DefineProject
public void DefineProject(Guid requestId, string name, ITimeProvider provider)
{
// filter request IDs
var time = provider.GetUtcNow();
var id = new ProjectId(NewGuidIfEmpty(requestId));
Apply(new ProjectDefined(_state.Id, id, name, time));
}
示例3: DefineAction
public void DefineAction(Guid requestId, string actionName, ITimeProvider provider)
{
// filter request IDs
var time = provider.GetUtcNow();
var id = new ActionId(NewGuidIfEmpty(requestId));
Apply(new ActionDefined(_state.Id, id, actionName, time));
}
示例4: ArchiveAction
public void ArchiveAction(ActionId actionId, ITimeProvider time)
{
var action = GetActionOrThrow(actionId);
if (!action.Archived)
{
Apply(new ActionArchived(_aggState.Id, actionId, action.Project, time.GetUtcNow()));
}
}
示例5: AssignPlannedMetricsToDrillWorkunits
public void AssignPlannedMetricsToDrillWorkunits(DrillingDepartmentId id, ITimeProvider provider, string testtext)
{
// Check if Drilling Department has already been opened
// Check if Planned Structure has already been imported
// TODO - Check if Planned Resources have already been imported into Drilling Department
// Check if Planned Metrics have already been imported
// Add the Metrics to the Drilling Department
// Issue PlannedMetricsAssignedToDrillWorkunits event
RecordAndRealizeThat(new PlannedMetricsAssignedToDrillWorkunits(id, new RequestId(), provider.GetUtcNow()));
}
示例6: CaptureInboxEntry
public void CaptureInboxEntry(Guid requestId, string name, ITimeProvider provider)
{
// filter request IDs
var time = provider.GetUtcNow();
var id = new ActionId(NewGuidIfEmpty(requestId));
Apply(new InboxEntryCaptured(_state.Id, requestId, name));
//Apply(new ActionCaptured(_state.Id, id, name, time));
}
示例7: ChangeDescriptionOfStuff
public void ChangeDescriptionOfStuff(StuffId stuffId, string newDescriptionOfStuff, ITimeProvider time)
{
StuffInfo stuffInfo;
if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo))
{
throw DomainError.Named("unknown stuff", "Unknown stuff {0}", stuffId);
}
if (stuffInfo.Description != newDescriptionOfStuff)
{
Apply(new StuffDescriptionChanged(_aggState.Id, stuffId, newDescriptionOfStuff, time.GetUtcNow()));
}
}
示例8: ChangeActionOutcome
public void ChangeActionOutcome(ActionId actionId, string outcome, ITimeProvider time)
{
ActionInfo actionInfo;
if (!_aggState.Actions.TryGetValue(actionId, out actionInfo))
{
throw DomainError.Named("unknown action", "Unknown action {0}", actionId);
}
if (actionInfo.Outcome != outcome)
{
Apply(new ActionOutcomeChanged(_aggState.Id, actionId, actionInfo.Project, outcome, time.GetUtcNow()));
}
}
示例9: Initialize
/// <summary>
/// Initializes the data feed for the specified job and algorithm
/// </summary>
public void Initialize(IAlgorithm algorithm, AlgorithmNodePacket job, IResultHandler resultHandler)
{
if (!(job is LiveNodePacket))
{
throw new ArgumentException("The LiveTradingDataFeed requires a LiveNodePacket.");
}
_cancellationTokenSource = new CancellationTokenSource();
_algorithm = algorithm;
_job = (LiveNodePacket) job;
_resultHandler = resultHandler;
_timeProvider = GetTimeProvider();
_dataQueueHandler = GetDataQueueHandler();
_frontierTimeProvider = new ManualTimeProvider(_timeProvider.GetUtcNow());
_customExchange = new BaseDataExchange("CustomDataExchange") {SleepInterval = 10};
// sleep is controlled on this exchange via the GetNextTicksEnumerator
_exchange = new BaseDataExchange("DataQueueExchange", GetNextTicksEnumerator()){SleepInterval = 0};
_subscriptions = new ConcurrentDictionary<SymbolSecurityType, Subscription>();
Bridge = new BusyBlockingCollection<TimeSlice>();
// run the exchanges
_exchange.Start();
_customExchange.Start();
// find the minimum resolution, ignoring ticks
_fillForwardResolution = algorithm.SubscriptionManager.Subscriptions
.Where(x => x.Resolution != Resolution.Tick)
.Select(x => x.Resolution)
.Union(algorithm.Universes.Select(x => x.SubscriptionSettings.Resolution))
.DefaultIfEmpty(algorithm.UniverseSettings.Resolution)
.Min();
// add user defined subscriptions
var start = _timeProvider.GetUtcNow();
foreach (var kvp in _algorithm.Securities.OrderBy(x => x.Key.ToString()))
{
var security = kvp.Value;
AddSubscription(security, start, Time.EndOfTime, true);
}
// add universe subscriptions
foreach (var universe in _algorithm.Universes)
{
var subscription = CreateUniverseSubscription(universe, start, Time.EndOfTime);
_subscriptions[new SymbolSecurityType(subscription)] = subscription;
}
}
示例10: TrashStuff
// Trash vs. Archives
// Archiving is an internal housekeeping process.
// It is an event that happens within the system as a result of another user command.
// A user doesn't "Archive" something, the system does.
// A user Trashes stuff, puts stuff in their ReferenceSystem, Puts stuff In SomedayMaybe, MovesToProject, etc.
// If a user Moves Stuff from the Inbox to a Project, then StuffArchived from Inbox, not StuffTrashed.
// If a user wants to "View Archives" then things that were Archived by the system appear in that View.
// However, if a user expressed their intent to TRASH an item, it is NOT in the "Archived Views".
// The trashed stuff is still in the Event Stream, but from the user's perspective, it is GONE/TRASHED/Not visible!
// This Event happens when Stuff is intentionally "trashed" by the user because they want it "out" of the system
public void TrashStuff(StuffId stuffId, ITimeProvider provider)
{
if (!_aggState.Inbox.Contains(stuffId))
throw DomainError.Named("no stuff", "Stuff with Id {0} not found", stuffId.Id);
Apply(new StuffTrashed(_aggState.Id, stuffId, provider.GetUtcNow()));
}
示例11: PutStuffInInbox
public void PutStuffInInbox(RequestId requestId, string stuffDescription, ITimeProvider provider)
{
var stuffId = new StuffId(NewGuidIfEmpty(requestId));
Apply(new StuffPutInInbox(_aggState.Id, stuffId, stuffDescription, provider.GetUtcNow()));
}
示例12: MoveStuffToProject
public void MoveStuffToProject(IEnumerable<StuffId> stuffToMove, ProjectId projectId, ITimeProvider provider)
{
GetProjectOrThrow(projectId);
var dateTime = provider.GetUtcNow();
foreach (var stuffId in stuffToMove)
{
StuffInfo stuffInfo;
if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo))
{
throw DomainError.Named("unknown-stuff", "Unknown stuff {0}", stuffId);
}
Apply(new StuffArchived(_aggState.Id, stuffId, dateTime));
Apply(new ActionDefined(_aggState.Id,new ActionId(Guid.NewGuid()), projectId, stuffInfo.Description, dateTime));
}
}
示例13: DefineSingleActionProject
public void DefineSingleActionProject(RequestId requestId, StuffId stuffId, ITimeProvider provider)
{
// filter request IDs
var time = provider.GetUtcNow();
var projectId = new ProjectId(NewGuidIfEmpty(requestId));
// generate actionId
var actionId = new ActionId(Guid.NewGuid());
// make sure Stuff exists in the Inbox
StuffInfo stuffInfo;
if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo))
{
throw DomainError.Named("unknown stuff", "Unknown stuff {0}", stuffId);
}
// TODO: May be able to use this to change the stuff description and then let that cascade down
// as both the Project AND Action Outcome in case you wanted to use a different name than from original desc
// With current design it may be better to kick off a "RENAME" command or Apply Renamed event for that purpose though.
//if (stuffInfo.Description != stuffDescription)
//{
// Apply(new StuffDescriptionChanged(_aggState.Id, stuffId, newDescriptionOfStuff, time.GetUtcNow()));
//}
// TODO: Not sure if it best to just reuse existing Events and projections (probably)
// or if I should create a new composite event for this new command msg.
// Thinking the former, not latter is way to go.
Apply(new ProjectDefined(_aggState.Id, projectId, stuffInfo.Description, ProjectType.List, time));
Apply(new ActionDefined(_aggState.Id, actionId, projectId, stuffInfo.Description, time));
//Apply(new SingleActionProjectDefined(_aggState.Id, etc.)
// Archive the Stuff from the Inbox now that is has transitioned from "Stuff" to a defined "Action"
Apply(new StuffArchived(_aggState.Id, stuffId, time));
}
示例14: DefineProject
// This Event happens when Stuff is moved from the Inbox to another part of the system
// TODO: Not sure if I need a method for a Command to call because StuffArchived Event is system generated.
//public void ArchiveStuff(StuffId stuffId, ITimeProvider provider)
//{
// if (!_aggState.Inbox.Contains(stuffId))
// throw DomainError.Named("no stuff", "Stuff with Id {0} not found", stuffId);
// Apply(new StuffArchived(_aggState.Id, stuffId, provider.GetUtcNow()));
//}
public void DefineProject(RequestId requestId, string name, ITimeProvider provider)
{
// filter request IDs
var time = provider.GetUtcNow();
var projectId = new ProjectId(NewGuidIfEmpty(requestId));
const ProjectType defaultProjectType = ProjectType.List;
Apply(new ProjectDefined(_aggState.Id, projectId, name, defaultProjectType, time));
}
示例15: ChangeWorkgroupName
public void ChangeWorkgroupName(DrillingDepartmentId id, RequestId requestId, string newName, ITimeProvider provider)
{
RecordAndRealizeThat(new WorkgroupNameChanged(id, requestId, newName, provider.GetUtcNow()));
}