本文整理汇总了C#中Tuple.ToDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.ToDictionary方法的具体用法?C# Tuple.ToDictionary怎么用?C# Tuple.ToDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.ToDictionary方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestToDictionaryKeyError
public void TestToDictionaryKeyError()
{
Tuple<int, string>[] records = new Tuple<int, string>[]
{
Tuple.Create(1,"cheka"),
Tuple.Create(1,"duplicated")
};
// !!!!!!!!! will throw exception due to same key existed
IDictionary<int, string> dict = records.ToDictionary(t => t.Item1, t => t.Item2);
}
示例2: RandomEnvironment
public static SortedList<string, double[]> RandomEnvironment(Random rnd)
{
var environmentArray = new Tuple<string, double[]>[]
{
Tuple.Create("ce1", Common.RandomDoubleArray(rnd,3)),
Tuple.Create("ce2", Common.RandomDoubleArray(rnd, 7))
};
var environmentDictionary = environmentArray.ToDictionary(l => l.Item1, l => l.Item2);
return new SortedList<string, double[]>(environmentDictionary);
}
示例3: RandomGlobalDiagnosticVariables
public static SortedList<string, double> RandomGlobalDiagnosticVariables(Random rnd)
{
var globalDiagnosticVariablesArray = new Tuple<string, double>[]
{
Tuple.Create(Common.RandomString(rnd, 4), rnd.NextDouble()),
Tuple.Create(Common.RandomString(rnd, 5), rnd.NextDouble())
};
var globalDiagnosticVariablesDictionary = globalDiagnosticVariablesArray.ToDictionary(l => l.Item1, l => l.Item2);
return new SortedList<string, double>(globalDiagnosticVariablesDictionary);
}
示例4: RecordDispersalForACell
/// <summary>
/// Record dispersal events in the dispersal tracker
/// </summary>
/// <param name="inboundCohorts">The cohorts arriving in a cell in the current time step</param>
/// <param name="outboundCohorts">The cohorts leaving a cell in the current time step</param>
/// <param name="outboundCohortWeights">The body masses of cohorts leaving the cell in the current time step</param>
/// <param name="timestep">The current model time step</param>
/// <param name="madingleyModelGrid">The model grid</param>
public void RecordDispersalForACell(uint[, ,] inboundCohorts, uint[, ,] outboundCohorts, List<double>[,] outboundCohortWeights, uint timestep, ModelGrid madingleyModelGrid)
{
var count = inboundCohorts.GetLength(0) * inboundCohorts.GetLength(1);
var copy = new Madingley.Common.GridCellDispersal[count];
for (var kk = 0; kk < count; kk++)
{
var ii = (int)kk / inboundCohorts.GetLength(1);
var jj = kk % inboundCohorts.GetLength(1);
var denter =
new Tuple<Madingley.Common.CohortsEnterDirection, int>[]
{
Tuple.Create(Madingley.Common.CohortsEnterDirection.North, (int)inboundCohorts[ii, jj, 0]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.NorthEast, (int)inboundCohorts[ii, jj, 1]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.East, (int)inboundCohorts[ii, jj, 2]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.SouthEast, (int)inboundCohorts[ii, jj, 3]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.South, (int)inboundCohorts[ii, jj, 4]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.SouthWest, (int)inboundCohorts[ii, jj, 5]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.West, (int)inboundCohorts[ii, jj, 6]),
Tuple.Create(Madingley.Common.CohortsEnterDirection.NorthWest, (int)inboundCohorts[ii, jj, 7]),
};
var enter = denter.ToDictionary(l => l.Item1, l => l.Item2);
var dexit =
new Tuple<Madingley.Common.CohortsExitDirection, int>[]
{
Tuple.Create(Madingley.Common.CohortsExitDirection.North, (int)outboundCohorts[ii, jj, 0]),
Tuple.Create(Madingley.Common.CohortsExitDirection.NorthEast, (int)outboundCohorts[ii, jj, 1]),
Tuple.Create(Madingley.Common.CohortsExitDirection.East, (int)outboundCohorts[ii, jj, 2]),
Tuple.Create(Madingley.Common.CohortsExitDirection.SouthEast, (int)outboundCohorts[ii, jj, 3]),
Tuple.Create(Madingley.Common.CohortsExitDirection.South, (int)outboundCohorts[ii, jj, 4]),
Tuple.Create(Madingley.Common.CohortsExitDirection.SouthWest, (int)outboundCohorts[ii, jj, 5]),
Tuple.Create(Madingley.Common.CohortsExitDirection.West, (int)outboundCohorts[ii, jj, 6]),
Tuple.Create(Madingley.Common.CohortsExitDirection.NorthWest, (int)outboundCohorts[ii, jj, 7]),
};
var exit = dexit.ToDictionary(l => l.Item1, l => l.Item2);
var weights = outboundCohortWeights[ii, jj].ToArray();
var cell = madingleyModelGrid.GetGridCell((uint)ii, (uint)jj);
var ccell = Converters.ConvertCellData(cell);
copy[kk] = new Madingley.Common.GridCellDispersal(enter, exit, weights, ccell);
}
this.GridCellDispersals = copy;
}
示例5: Setup
public void Setup()
{
//TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
_bus.Subscribe(_consumer);
_processingQueues = GivenProcessingQueues();
var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);
_managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
_manager = new ProjectionManager(
GetInputQueue(),
GetInputQueue(),
queues,
_timeProvider,
ProjectionType.All,
_ioDispatcher,
_initializeSystemProjections);
_coordinator = new ProjectionCoreCoordinator(
ProjectionType.All,
ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
queues.Values.ToArray(),
_bus,
Envelope);
_bus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.Started>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.Stopped>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.Prepared>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.Faulted>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.StateReport>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.ResultReport>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.StatisticsReport>(_manager);
_bus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
_bus.Subscribe<CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Post>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.UpdateQuery>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.GetQuery>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Delete>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.GetStatistics>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.GetState>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.GetResult>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Disable>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Enable>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Abort>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.SetRunAs>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.Reset>(_manager);
_bus.Subscribe<ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
_bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
_bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
_bus.Subscribe<ClientMessage.DeleteStreamCompleted>(_manager);
_bus.Subscribe<SystemMessage.StateChangeMessage>(_manager);
_bus.Subscribe<SystemMessage.SystemCoreReady>(_manager);
_bus.Subscribe<ProjectionManagementMessage.ReaderReady>(_manager);
_bus.Subscribe(
CallbackSubscriber.Create<ProjectionManagementMessage.Starting>(
starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));
_bus.Subscribe<SystemMessage.StateChangeMessage>(_coordinator);
_bus.Subscribe<SystemMessage.SystemCoreReady>(_coordinator);
if (GetInputQueue() != _processingQueues.First().Item2)
{
_bus.Subscribe<PartitionProcessingResultBase>(_managerMessageDispatcher);
_bus.Subscribe<CoreProjectionManagementControlMessage>(
_managerMessageDispatcher);
_bus.Subscribe<PartitionProcessingResultOutputBase>(_managerMessageDispatcher);
_bus.Subscribe<ReaderSubscriptionManagement.SpoolStreamReading>(_managerMessageDispatcher);
}
foreach(var q in _processingQueues)
SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);
//Given();
WhenLoop();
}
开发者ID:SzymonPobiega,项目名称:EventStore,代码行数:76,代码来源:TestFixtureWithProjectionCoreAndManagementServices.cs
示例6: MoneyResolver
static MoneyResolver()
{
var items = new Tuple<Money, MoneyStatus, int>[] {
Tuple.Create(Money.Coin10 , MoneyStatus.Available, 10),
Tuple.Create(Money.Coin50 , MoneyStatus.Available, 50),
Tuple.Create(Money.Coin100 , MoneyStatus.Available, 100),
Tuple.Create(Money.Coin500 , MoneyStatus.Available, 500),
Tuple.Create(Money.Bill1000 , MoneyStatus.Available, 1000),
Tuple.Create(Money.Coin1 , MoneyStatus.Unavailable, 1),
Tuple.Create(Money.Coin5 , MoneyStatus.Unavailable, 5),
Tuple.Create(Money.Bill2000 , MoneyStatus.Unavailable, 2000),
Tuple.Create(Money.Bill5000 , MoneyStatus.Unavailable, 5000),
Tuple.Create(Money.Bill10000 , MoneyStatus.Unavailable, 10000),
};
sLookup = items
.ToDictionary(item => item.Item1, item => {
return new InternalMoney {
Type = item.Item1,
Status = item.Item2,
Value = item.Item3
};
})
;
sUnknownMoney = new InternalMoney {
Type = Money.Unknown,
Status = MoneyStatus.Unavailable,
Value = 0
};
}