当前位置: 首页>>代码示例>>C#>>正文


C# Collections.Dictionary类代码示例

本文整理汇总了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));
 }
开发者ID:Shuffle-Game,项目名称:ShufflySharp,代码行数:14,代码来源:Gateway.cs

示例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);
 }
开发者ID:ConjureETS,项目名称:OuijaMTLGJ2016,代码行数:7,代码来源:InputMapper.cs

示例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);
        }
开发者ID:h4ck3rm1k3,项目名称:FlickrNet,代码行数:13,代码来源:Flickr_ReflectionAsync.cs

示例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);
 }
开发者ID:mrkurt,项目名称:mubble-old,代码行数:7,代码来源:ModuleControl.activeobjects.cs

示例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;
        }
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:29,代码来源:BaseGame.cs

示例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] = "";
             }
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:EventLogLogProvider.cs

示例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;
			}
		}
开发者ID:OvertimeStudios,项目名称:CreepyBuster,代码行数:27,代码来源:GoogleSkuInfo.cs

示例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);
        }
开发者ID:h4ck3rm1k3,项目名称:FlickrNet,代码行数:11,代码来源:Flickr_TestAsync.cs

示例9: CreateOnEmptyDictionaryReturnsEmptyMap

        public void CreateOnEmptyDictionaryReturnsEmptyMap()
        {
            Dictionary<int, string> d = new Dictionary<int, string>();
            IPersistentMap m = PersistentHashMap.create(d);

            Expect(m.count(), EqualTo(0));
        }
开发者ID:jlomax,项目名称:clojure-clr,代码行数:7,代码来源:PersistentHashMapTests.cs

示例10: SqlFormatter

 private SqlFormatter(QueryLanguage language, bool forDebug)
 {
     this.language = language;
     this.sb = new StringBuilder();
     this.aliases = new Dictionary<TableAlias, string>();
     this.forDebug = forDebug;
 }
开发者ID:firestrand,项目名称:IQToolkit,代码行数:7,代码来源:SqlFormatter.cs

示例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
            };
        }
开发者ID:kevinyang72,项目名称:CatchTheFish01,代码行数:28,代码来源:MACD.cs

示例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);
            }
        }
开发者ID:xceza7,项目名称:EDCB,代码行数:60,代码来源:ListViewSelectedKeeper.cs

示例13: MockTable

 public MockTable(TableName name)
 {
     this.name = name;
     columns = new ColumnCollection(this);
     rows = new Dictionary<RowId, TableRow>();
     rowIndex = new List<RowId>();
 }
开发者ID:ikvm,项目名称:deveelsql,代码行数:7,代码来源:MockTable.cs

示例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;
        }
开发者ID:JackWangCUMT,项目名称:My-FyiReporting,代码行数:25,代码来源:ExcelValetTests.cs

示例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();
            }
        }
开发者ID:siganakis,项目名称:s3-tool-encrypted,代码行数:31,代码来源:Snapshots.cs


注:本文中的System.Collections.Dictionary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。