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


C# Hashtable.ContainsKey方法代码示例

本文整理汇总了C#中System.Collections.Hashtable.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# Hashtable.ContainsKey方法的具体用法?C# Hashtable.ContainsKey怎么用?C# Hashtable.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Hashtable的用法示例。


在下文中一共展示了Hashtable.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadConfig

        /// <summary>
        /// Read a simple config file and returns its variables as a Hashtable.
        /// </summary>
        public static Hashtable ReadConfig(string configPath)
        {
            if (configPath == null) configPath = "";
            if (cache.ContainsKey(configPath)) return cache[configPath];

            Hashtable config = new Hashtable();
            if (File.Exists(configPath))
            {
                string[] lines = File.ReadAllLines(configPath);
                foreach (string line in lines)
                {
                    if (line.StartsWith("#")) continue;
                    string[] entry = line.Trim().Split(new char[] { '=' }, 2);
                    if (entry.Length < 2) continue;
                    config[entry[0].Trim()] = entry[1].Trim();
                }
            }

            // default values
            if (!config.ContainsKey("java.home")) config["java.home"] = "";

            string args = "-Xmx384m -Dsun.io.useCanonCaches=false";
            if (config.ContainsKey("java.args")) args = config["java.args"] as string;
            if (args.IndexOf("-Duser.language") < 0)
                args += " -Duser.language=en -Duser.region=US";
            config["java.args"] = args;

            cache[configPath] = config;
            return config;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:33,代码来源:JvmConfigHelper.cs

示例2: GetPromotionDs

        public DataSet GetPromotionDs(Hashtable paramHash)
        {
            string sql = @"select pm.SysNo,pm.PromotionName,pm.CreateTime,pm.status, su.username as username
                        from Promotion_Master pm
                        left join sys_user su on pm.CreateUserSysNo=su.sysno
                        where 1=1 @DateFrom @DateTo @status @KeyWords ";
              if (paramHash.ContainsKey("DateFrom"))
              {
              sql = sql.Replace("@DateFrom", "and pm.CreateTime>=" + Util.ToSqlString(paramHash["DateFrom"].ToString()));
              }
              else
              {
              sql = sql.Replace("@DateFrom", "");
              }
              if (paramHash.ContainsKey("DateTo"))
              {
              sql = sql.Replace("@DateTo", "and pm.CreateTime<=" + Util.ToSqlEndDate(paramHash["DateTo"].ToString()));
              }
              else
              {
              sql = sql.Replace("@DateTo", "");
              }
              if (paramHash.ContainsKey("Status"))
              {
              sql = sql.Replace("@status", "and pm.status=" + Util.ToSqlString(paramHash["Status"].ToString()));
              }
              else
              {
              sql = sql.Replace("@status", "");
              }
              if (paramHash.ContainsKey("KeyWords"))
              {
              string[] keys = (Util.TrimNull(paramHash["KeyWords"].ToString())).Split(' ');
              if (keys.Length == 1)
              {
                  sql = sql.Replace("@KeyWords", "and pm.PromotionName like " + Util.ToSqlLikeString(paramHash["KeyWords"].ToString()));
              }
              else
              {
                  string t = "";
                  for (int i = 0; i < keys.Length; i++)
                  {
                      t += "and pm.PromotionName like" + Util.ToSqlLikeString(keys[i]);

                  }
                  sql = sql.Replace("@KeyWords", t);

              }
              }
              else
              {
              sql = sql.Replace("@KeyWords", "");
              }

              if (paramHash == null || paramHash.Count == 0)
              sql = sql.Replace("select", "select top 50 ");
              sql = sql + "order by pm.sysno desc";

              return SqlHelper.ExecuteDataSet(sql);
        }
开发者ID:ue96,项目名称:ue96,代码行数:60,代码来源:PromotionManager.cs

示例3: ZenElementTypes

 public ZenElementTypes(Hashtable def)
 {
     if (def == null) return;
     if (def.ContainsKey("empty")) ParseSet(empty, (string)def["empty"]);
     if (def.ContainsKey("block_level")) ParseSet(block_level, (string)def["block_level"]);
     if (def.ContainsKey("inline_level")) ParseSet(inline_level, (string)def["inline_level"]);
 }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:7,代码来源:ZenCoding.cs

示例4: TestCtorDictionarySingle

        public void TestCtorDictionarySingle()
        {
            // No exception
            var hash = new Hashtable(new Hashtable(), 1f);
            // No exception
            hash = new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable(new Hashtable()), 1f), 1f), 1f), 1f);

            // []test to see if elements really get copied from old dictionary to new hashtable
            Hashtable tempHash = new Hashtable();
            // this for assumes that MinValue is a negative!
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                tempHash.Add(i, i);
            }

            hash = new Hashtable(tempHash, 1f);

            // make sure that new hashtable has the elements in it that old hashtable had
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }

            //[]make sure that there are no connections with the old and the new hashtable
            tempHash.Clear();
            for (long i = long.MinValue; i < long.MinValue + 100; i++)
            {
                Assert.True(hash.ContainsKey(i));
                Assert.True(hash.ContainsValue(i));
            }
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:32,代码来源:CtorTests.cs

示例5: Dequeue

        /// <summary>
        /// Get the next item from the queue which is not in the provided exclusion list.  
        /// Return null if the queue is empty or if there are no qualifying items.
        /// </summary>
        /// <returns></returns>
        public SendParameters Dequeue(Hashtable exclusionList, Guid currentSlide)
        {
            lock (this) {
                ClientQueue bestClient = null;
                SendParameters bestMessage = null;
                foreach (ClientQueue cq in m_QueueList.Values) {
                    //Block student messages when sending public messages.
                    if ((exclusionList.ContainsKey(cq.Id)) && (cq.IsPublicNode) && !((ReferenceCounter)exclusionList[cq.Id]).IsZero)
                        return cq.Dequeue(currentSlide);

                    if (m_DisabledClients.ContainsKey(cq.Id))
                        continue;
                    if (((exclusionList.ContainsKey(cq.Id)) && (((ReferenceCounter)exclusionList[cq.Id]).IsZero)) ||
                        (!exclusionList.ContainsKey(cq.Id))) {
                        SendParameters thisSp = cq.Peek(currentSlide);
                        if (thisSp != null) {
                            if (thisSp.CompareTo(bestMessage, currentSlide) < 0) {
                                bestMessage = thisSp;
                                bestClient = cq;
                            }
                        }
                    }
                }
                if (bestClient != null) {
                    //Trace.WriteLine("Dequeue: best message tag: " + bestMessage.Tags.SlideID.ToString() +
                    //    "; current slide=" + currentSlide.ToString() +
                    //    "; seq number=" + bestMessage.SequenceNumber.ToString(), this.GetType().ToString());
                    return bestClient.Dequeue(currentSlide);
                }
            }
            return null;
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:37,代码来源:TCPServerSendQueue.cs

示例6: DoExtraProcess

        protected override Hashtable DoExtraProcess(Hashtable h)
        {
            if (!h.Contains("T_SU"))
            {
                h.Add("T_SU",0);
            }
            if (!h.ContainsKey("01_SU"))
            {
                h.Add("01_SU",0);
            }
            if (!h.ContainsKey("02_SU"))
            {
                h.Add("02_SU", 0);
            }
            if (!h.ContainsKey("03_SU"))
            {
                h.Add("03_SU", 0);
            }
            if (!h.ContainsKey("04_SU"))
            {
                h.Add("04_SU", 0);
            }

            return h;
        }
开发者ID:TscCai,项目名称:sis,代码行数:25,代码来源:GeneralListener.cs

示例7: ImportParticipant

        protected void ImportParticipant(EventPageBase ep, string[] participantFields, string[] keys)
        {
            string email = "";
            Hashtable fieldsHashtable = new Hashtable();
            if(participantFields.Count() == keys.Count())
            for (int i = 0; i < keys.Count(); i++)
            {
                if(!fieldsHashtable.ContainsKey(keys[i]))
                    fieldsHashtable.Add(keys[i].ToLower(), participantFields[i]);
            }

            if (fieldsHashtable.ContainsKey("email"))
                email = fieldsHashtable["email"].ToString();
            else
                return;
            if(string.IsNullOrEmpty(email))
                return;

            XForm xform = ep.RegistrationForm;

            XFormData xFormData = xform.CreateFormData();

            PopulateChildNodeRecursive(fieldsHashtable, xFormData.Data.ChildNodes);
           

            string xformstring = xFormData.Data.InnerXml;
            StatusLiteral.Text += "Adding participant: " + email+"<br/>";
            AttendRegistrationEngine.GenerateParticipation(ep.ContentLink, email, false, xformstring,
                "Imported participant from text");
        }
开发者ID:BVNetwork,项目名称:Attend,代码行数:30,代码来源:ImportText.aspx.cs

示例8: Main

        static void Main(string[] args)
        {
            Hashtable hashtable = new Hashtable();

            for (int i = 0; i < 1000000; i++)
            {
                hashtable[i.ToString("0000000")] = i;

            }
            Stopwatch s1 = Stopwatch.StartNew();
            var r1 = hashtable.ContainsKey("09999");
            var r2 = hashtable.ContainsKey("30000");
            s1.Stop();
            Console.WriteLine("{0}", s1.Elapsed);

            Dictionary<string, int> dictionary = new Dictionary<string, int>();
            for (int i = 0; i < 1000000; i++)
            {
                dictionary.Add(i.ToString("000000"), i);
            }

            Stopwatch s2 = Stopwatch.StartNew();
            var r3 = dictionary.ContainsKey("09999");
            var r4 = dictionary.ContainsKey("30000");
            s2.Stop();
            Console.WriteLine("{0}", s2.Elapsed);
        }
开发者ID:vuongtran,项目名称:dojo-code,代码行数:27,代码来源:Program.cs

示例9: FileTag

        public FileTag(Hashtable options)
        {
            StatusEvent.FireStatusError(this, statusEvent, Globalisation.GetString(""));
            if (options.ContainsKey("Db"))
            {
                this.Db = (MyDatabase)options["Db"];
            }

            if (options.ContainsKey("Form"))
            {
                this.Form = (Form1)options["Form"];
            }

            if (options.ContainsKey("listview"))
            {
                this.ListView = (ListView)options["listview"];
                this.ListView.MouseDown += new MouseEventHandler(mouseDown_ListView);

                this.ListView.OwnerDraw = true;
                this.ListView.DrawItem += new DrawListViewItemEventHandler(ListView_DrawItem);
            }

            if (options.ContainsKey("infopanel"))
            {
                this.Infopanel = (RichTextBox)options["infopanel"];
            }

            if (options.ContainsKey("GridFile"))
            {
                this.GridFile = (GridFile)options["GridFile"];
                this.GridFileListView = this.GridFile.GetListView();
                //this.GridFileListView.MouseDown += new MouseEventHandler(mouseDown_LoadTag);
                this.GridFileListView.SelectedIndexChanged += new System.EventHandler(this.center_listview_SelectedIndexChanged);
            }
        }
开发者ID:solofo-ralitera,项目名称:tagmyfiles,代码行数:35,代码来源:FileTag.cs

示例10: Dequeue

 /// <summary>
 /// Get the next item from the queue which is not in the provided exclusion list.  
 /// Return null if the queue is empty or if there are no qualifying items.
 /// </summary>
 /// <returns></returns>
 public SocketSendParameters Dequeue(Hashtable exclusionList, Guid currentSlide)
 {
     lock (this) {
         SocketQueue bestSocketQueue = null;
         SocketSendParameters bestMessage = null;
         foreach (SocketQueue sq in m_QueueList.Values) {
             if (((exclusionList.ContainsKey(sq.Socket)) && (((ReferenceCounter)exclusionList[sq.Socket]).IsZero)) ||
                 (!exclusionList.ContainsKey(sq.Socket))) {
                 SocketSendParameters thisSp = sq.Peek(currentSlide);
                 if (thisSp != null) {
                     if (thisSp.CompareTo(bestMessage, currentSlide) < 0) {
                         bestMessage = thisSp;
                         bestSocketQueue = sq;
                     }
                 }
             }
         }
         if (bestSocketQueue != null) {
             //Trace.WriteLine("Dequeue: best message tag: " + bestMessage.Tags.SlideID.ToString() +
             //    "; current slide=" + currentSlide.ToString() +
             //    "; seq number=" + bestMessage.SequenceNumber.ToString(), this.GetType().ToString());
             return bestSocketQueue.Dequeue(currentSlide);
         }
     }
     return null;
 }
开发者ID:kevinbrink,项目名称:CP3_Enhancement,代码行数:31,代码来源:TCPSocketSendQueue.cs

示例11: TestGetKeyValueList

        public void TestGetKeyValueList()
        {
            var dic1 = new SortedList();

            for (int i = 0; i < 100; i++)
                dic1.Add("Key_" + i, "Value_" + i);

            var ilst1 = dic1.GetKeyList();
            var hsh1 = new Hashtable();

            DoIListTests(dic1, ilst1, hsh1, DicType.Key);

            Assert.False(hsh1.Count != 2
                || !hsh1.ContainsKey("IsReadOnly")
                || !hsh1.ContainsKey("IsFixedSize"), "Error, KeyList");


            dic1 = new SortedList();
            for (int i = 0; i < 100; i++)
                dic1.Add("Key_" + i, "Value_" + i);

            ilst1 = dic1.GetValueList();
            hsh1 = new Hashtable();
            DoIListTests(dic1, ilst1, hsh1, DicType.Value);

            Assert.False(hsh1.Count != 2
                || !hsh1.ContainsKey("IsReadOnly")
                || !hsh1.ContainsKey("IsFixedSize"), "Error, ValueList");
        }
开发者ID:hitomi333,项目名称:corefx,代码行数:29,代码来源:WrapperTests.cs

示例12: ExecuteRule

		/// <summary> Returns a value cast to a specific type
		/// *
		/// </summary>
		/// <param name="aBrc">- The BRERuleContext object
		/// </param>
		/// <param name="aMap">- The Map of parameters from the XML
		/// </param>
		/// <param name="aStep">- The step that it is on
		/// </param>
		/// <returns> The value cast to the specified type
		/// 
		/// </returns>
		public object ExecuteRule(IBRERuleContext aBrc, Hashtable aMap, object aStep)
		{
			bool staticCall = false;
			if (!aMap.ContainsKey(OBJECTID))
			{
				if (!aMap.ContainsKey(TYPE))
					throw new BRERuleException("Parameter 'Type' or 'ObjectId' not found");
				else staticCall = true;
			}
			if (!aMap.ContainsKey(MEMBER))
			{
				throw new BRERuleException("Parameter 'Member' not found");
			}
			else
			{
				if (staticCall)
					return Reflection.ClassCall((string)aMap[TYPE],
						                           (string)aMap[MEMBER],
						                           GetArguments(aMap));
				else
					return Reflection.ObjectCall(aBrc.GetResult(aMap[OBJECTID]).Result,
						                           (string)aMap[MEMBER],
						                           GetArguments(aMap));
			}
		}
开发者ID:killbug2004,项目名称:WSProf,代码行数:37,代码来源:ObjectLookup.cs

示例13: FirstNonRepeatedChar

 private static char FirstNonRepeatedChar(string str)
 {
     char[] cArr = str.ToCharArray();
     Hashtable h = new Hashtable();
     // Build hashtable - Key = Char ; Value = Count (#of times Char occures in string)
     for (int i = 0; i < cArr.Length; ++i)
     {
         if (!h.ContainsKey(cArr[i]))
         {
             h.Add(cArr[i], 1);
         }
         else
         {
             int count = (int)h[cArr[i]];
             h[cArr[i]] = count + 1;
         }
     }
     for (int i = 0; i < cArr.Length; ++i)
     {
         if(h.ContainsKey(cArr[i]))
         {
             if((int)h[cArr[i]] == 1)
                 return cArr[i];
         }
     }
     return '0';
 }
开发者ID:msgsmg,项目名称:msggittest,代码行数:27,代码来源:Program.cs

示例14: Login

        public LoginResponse Login (Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            data = null;

            string ip = "";
            string version = "";
            string platform = "";
            string mac = "";
            string id0 = "";

            if (request != null) {
                ip = request.ContainsKey ("ip") ? (string)request ["ip"] : "";
                version = request.ContainsKey ("version") ? (string)request ["version"] : "";
                platform = request.ContainsKey ("platform") ? (string)request ["platform"] : "";
                mac = request.ContainsKey ("mac") ? (string)request ["mac"] : "";
                id0 = request.ContainsKey ("id0") ? (string)request ["id0"] : "";
            }

            string message;
            if (!m_module.CheckUser (account.PrincipalID, ip,
                    version,
                    platform,
                    mac,
                    id0, out message)) {
                return new LLFailedLoginResponse (LoginResponseEnum.Indeterminant, message, false);
            }
            return null;
        }
开发者ID:WhiteCoreSim,项目名称:WhiteCore-Dev,代码行数:29,代码来源:BanCheck.cs

示例15: ArgumentParse

        /// <summary>
        /// Parse arguments.
        /// </summary>
        /// <param name="args">Argument array from Main() method.</param>
        /// <returns>Hashtable of parsed arguments.</returns>
        private static Hashtable ArgumentParse(string[] args)
        {
            Hashtable Return = new Hashtable();

            string Key;
            bool ReadPort = false;
            bool ResetMessage = false;
            foreach (String arg in args)
            {
                if (arg.StartsWith("-") || arg.StartsWith("/"))
                {
                    Key = arg.Substring(1, arg.Length - 1).ToLower();

                    if (Key.Equals("on"))
                    {
                        if (!Return.ContainsKey(PARAMETER_BACKLIGHT))
                            Return.Add(PARAMETER_BACKLIGHT, true);
                    }
                    else if (Key.Equals("off"))
                    {
                        if (!Return.ContainsKey(PARAMETER_BACKLIGHT))
                            Return.Add(PARAMETER_BACKLIGHT, false);
                    }
                    else if (Key.StartsWith("p"))
                    {
                        if (!Return.ContainsKey(PARAMETER_PORT))
                            ReadPort = true;
                    }

                    ResetMessage = true;
                }
                else if (ReadPort)
                {
                    Return.Add(PARAMETER_PORT, arg);
                    ReadPort = false;
                }
                else
                {
                    if (ResetMessage)
                    {
                        if (Return.ContainsKey(PARAMETER_TEXT))
                            Return.Remove(PARAMETER_TEXT);

                        ResetMessage = false;
                    }

                    if (!Return.ContainsKey(PARAMETER_TEXT))
                    {
                        Return.Add(PARAMETER_TEXT, new StringBuilder(arg));
                    }
                    else
                    {
                        ((StringBuilder)Return[PARAMETER_TEXT]).Append(" ").Append(arg);
                    }
                }
            }

            return Return;
        }
开发者ID:Gerst20051,项目名称:ArduinoExamples,代码行数:64,代码来源:LCDWrite.cs


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