本文整理汇总了C#中System.Collections.Dictionary类的典型用法代码示例。如果您正苦于以下问题:C# Dictionary类的具体用法?C# Dictionary怎么用?C# Dictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dictionary类属于System.Collections命名空间,在下文中一共展示了Dictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Gateway
public Gateway(string gatewayServer,bool server)
{
Console.WriteLine("did " + gatewayServer);
channels = new Dictionary<string, GatewayMessage>();
if (server) {
var jv = new JsDictionary<string, bool>();
jv["force new connection"] = true;
GatewaySocket = Global.Require<SocketIOClient>("socket.io-client").AConnect(gatewayServer, jv);
} else {
GatewaySocket = SocketIOClient.Connect(gatewayServer);
}
GatewaySocket.On<SocketClientMessageModel>("Client.Message", data => channels[data.Channel](data.User, data.Content));
GatewaySocket.On<string>("disconnect", data => Console.WriteLine("Disconnected "+ DateTime.Now));
}
示例2: InputMapper
public InputMapper(Dictionary<string, InputContext> contexts, int playerIndex)
{
_contexts = contexts;
_activeContexts = new Stack<InputContext>();
_callbacks = new List<Action<MappedInput>>();
_currentFrameMappedInput = new MappedInput(playerIndex);
}
示例3: ReflectionGetMethodsAsync
/// <summary>
/// Gets an array of supported method names for Flickr.
/// </summary>
/// <remarks>
/// Note: Not all methods might be supported by the FlickrNet Library.</remarks>
/// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
public void ReflectionGetMethodsAsync(Action<FlickrResult<MethodCollection>> callback)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("method", "flickr.reflection.getMethods");
GetResponseAsync<MethodCollection>(parameters, callback);
}
示例4: ModuleControl
public ModuleControl(Guid moduleID, String fileName)
{
Dictionary<string, object> parameters = new Dictionary<string,object>();
parameters.Add("moduleID", moduleID);
parameters.Add("fileName", fileName);
this.DataManager.Load(parameters);
}
示例5: BaseGame
public BaseGame(int id, int roomId, Map map, eRoomType roomType, eGameType gameType, int timeType)
: base(id, roomType, gameType, timeType)
{
m_roomId = roomId;
m_players = new Dictionary<int, Player>();
m_turnQueue = new List<TurnedLiving>();
m_livings = new List<Living>();
m_random = new Random();
m_map = map;
m_actions = new ArrayList();
PhysicalId = 0;
BossWarField = "";
m_tempBox = new List<Box>();
m_tempPoints = new List<Point>();
if (roomType == eRoomType.Dungeon)
{
Cards = new int[21];
}
else
{
Cards = new int[8];
}
m_gameState = eGameState.Inited;
}
示例6: FillEventArgs
private static void FillEventArgs(Hashtable mapArgs, Dictionary<string, string> additionalInfo)
{
if (additionalInfo == null)
{
for (int i = 0; i < 3; i++)
{
string str = (i + 1).ToString("d1", CultureInfo.CurrentCulture);
mapArgs["AdditionalInfo_Name" + str] = "";
mapArgs["AdditionalInfo_Value" + str] = "";
}
}
else
{
string[] array = new string[additionalInfo.Count];
string[] strArray2 = new string[additionalInfo.Count];
additionalInfo.Keys.CopyTo(array, 0);
additionalInfo.Values.CopyTo(strArray2, 0);
for (int j = 0; j < 3; j++)
{
string str2 = (j + 1).ToString("d1", CultureInfo.CurrentCulture);
if (j < array.Length)
{
mapArgs["AdditionalInfo_Name" + str2] = array[j];
mapArgs["AdditionalInfo_Value" + str2] = strArray2[j];
}
else
{
mapArgs["AdditionalInfo_Name" + str2] = "";
mapArgs["AdditionalInfo_Value" + str2] = "";
}
}
}
}
示例7: GoogleSkuInfo
public GoogleSkuInfo( Dictionary<string,object> dict )
{
if( dict.ContainsKey( "title" ) )
title = dict["title"] as string;
if( dict.ContainsKey( "price" ) )
price = dict["price"] as string;
if( dict.ContainsKey( "type" ) )
type = dict["type"] as string;
if( dict.ContainsKey( "description" ) )
description = dict["description"] as string;
if( dict.ContainsKey( "productId" ) )
productId = dict["productId"] as string;
if( dict.ContainsKey( "price_currency_code" ) )
priceCurrencyCode = dict["price_currency_code"] as string;
if( dict.ContainsKey( "price_amount_micros" ) )
{
var temp = dict["price_amount_micros"] as long?;
if( temp != null )
priceAmountMicros = temp.Value;
}
}
示例8: TestNullAsync
/// <summary>
/// Null test.
/// </summary>
/// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
public void TestNullAsync(Action<FlickrResult<NoResponse>> callback)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("method", "flickr.test.null");
GetResponseAsync<NoResponse>(parameters, callback);
}
示例9: CreateOnEmptyDictionaryReturnsEmptyMap
public void CreateOnEmptyDictionaryReturnsEmptyMap()
{
Dictionary<int, string> d = new Dictionary<int, string>();
IPersistentMap m = PersistentHashMap.create(d);
Expect(m.count(), EqualTo(0));
}
示例10: SqlFormatter
private SqlFormatter(QueryLanguage language, bool forDebug)
{
this.language = language;
this.sb = new StringBuilder();
this.aliases = new Dictionary<TableAlias, string>();
this.forDebug = forDebug;
}
示例11: Calculate
public override System.Collections.Generic.Dictionary<System.DateTime, double>[] Calculate(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.DateTime, double>> values)
{
int basePeriod = base.Period;
Dictionary<System.DateTime, double> macdValues = new Dictionary<System.DateTime, double>();
//Dim signalLineValues As New Dictionary(Of Date, Double)
base.Period = this.PeriodFast;
Dictionary<DateTime, double> ema12values = base.Calculate(values)[0];
base.Period = this.PeriodSlow;
Dictionary<DateTime, double> ema26values = base.Calculate(values)[0];
List<KeyValuePair<System.DateTime, double>> closeValues = new List<KeyValuePair<System.DateTime, double>>(values);
System.DateTime d = default(System.DateTime);
for (int i = 0; i <= closeValues.Count - 1; i++) {
d = closeValues[i].Key;
macdValues.Add(d, ema12values[d] - ema26values[d]);
}
base.Period = basePeriod;
Dictionary<DateTime, double> ema9values = base.Calculate(macdValues)[0];
return new Dictionary<System.DateTime, double>[] {
macdValues,
ema9values
};
}
示例12: RestoreListViewSelected
public void RestoreListViewSelected()
{
try
{
if (listBox != null && oldItem != null && oldItems != null)
{
if (this.allSelected == true)
{
listBox.SelectAll();
return;
}
//このUnselectAll()は無いと正しく復元出来ない状況があり得る
listBox.UnselectAll();
//上限越えの場合は、選択を解除して終了。
if (oldItems.Count >= this.MaxRestoreNum) return;
//選択数が少ないときは逆に遅くなる気もするが、Dictionaryにしておく
var listKeys = new Dictionary<ulong, object>();
if (getKey == null)
{
getKey = CtrlCmdDefEx.GetKeyFunc(oldItem.GetType());
}
foreach (object listItem1 in listBox.Items)
{
//重複するキーは基本的に無いという前提
try
{
listKeys.Add(getKey(listItem1), listItem1);
}
catch { }
}
object setItem;
if (listKeys.TryGetValue(getKey(oldItem), out setItem))
{
listBox.SelectedItem = setItem;
}
foreach (object oldItem1 in oldItems)
{
if (listKeys.TryGetValue(getKey(oldItem1), out setItem))
{
//数が多いとき、このAddが致命的に遅い
listBox.SelectedItems.Add(setItem);
}
}
//画面更新が入るので最後に実行する。SelectedItem==nullのときScrollIntoViewは何もしない。
listBox.ScrollIntoView(listBox.SelectedItem);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
}
}
示例13: MockTable
public MockTable(TableName name)
{
this.name = name;
columns = new ColumnCollection(this);
rows = new Dictionary<RowId, TableRow>();
rowIndex = new List<RowId>();
}
示例14: SampleTestData
public static Dictionary<string, IEnumerable> SampleTestData(int maxRows,
int minValue=1,
int maxValue=100,
int denominator=100,
string dataSetName = "Data")
{
List<ExcelTestData> values = new List<ExcelTestData>();
Dictionary<string, IEnumerable> results = new Dictionary<string, IEnumerable>();
Random random = new Random();
RandomDateTime randomdt = new RandomDateTime(1990, 1, 1);
for (int i = 0; i < maxRows; i++)
{
int r = random.Next(minValue, maxValue);
decimal result =Convert.ToDecimal( (double)r / denominator);
values.Add(new ExcelTestData() {
decimalvalue = result,
datetimevalue = randomdt.Next()
});
}
results.Add(dataSetName, values);
return results;
}
示例15: Execute
public override void Execute()
{
AmazonEC2Client client = new AmazonEC2Client(AWSAuthConnection.OUR_ACCESS_KEY_ID, AWSAuthConnection.OUR_SECRET_ACCESS_KEY);
DescribeSnapshotsRequest request = new DescribeSnapshotsRequest();
DescribeSnapshotsResponse response = client.DescribeSnapshots(request);
Dictionary<string, List<Amazon.EC2.Model.Snapshot>> snapshots = new Dictionary<string, List<Amazon.EC2.Model.Snapshot>>();
foreach (Amazon.EC2.Model.Snapshot r in response.DescribeSnapshotsResult.Snapshot)
{
if (!snapshots.ContainsKey(r.VolumeId))
snapshots[r.VolumeId] = new List<Amazon.EC2.Model.Snapshot>();
snapshots[r.VolumeId].Add(r);
}
foreach (string volumeId in snapshots.Keys)
{
Console.WriteLine("--- Volume: {0}", volumeId);
snapshots[volumeId].Sort(delegate(Amazon.EC2.Model.Snapshot x,Amazon.EC2.Model.Snapshot y)
{ return DateTime.Parse(x.StartTime).CompareTo(DateTime.Parse(y.StartTime)); });
foreach (Amazon.EC2.Model.Snapshot s in snapshots[volumeId])
{
DateTime startTime = DateTime.Parse(s.StartTime);
Console.Write("{0}\t{1}\t{2}\t{3}", s.SnapshotId, startTime, s.Progress, s.Status);
Console.WriteLine();
}
Console.WriteLine();
}
}