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


C# Hashtable.Contains方法代码示例

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


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

示例1: SetCookie

    public void SetCookie(string[] cookieList, string host) {
        if (cookieList == null) return;
        lock (this) {
            foreach (string cookieString in cookieList) {
                if (cookieString == "")
                    continue;
                string[] cookies = cookieString.Trim().Split(SEM);
                Hashtable cookie = new Hashtable();
#if !dotNETMF
                string[] value = regex.Split(cookies[0].Trim(), 2);
#else
                string[] value = cookies[0].Trim().Split(EQU, 2);
#endif
                cookie["name"] = value[0];
                if (value.Length == 2)
                    cookie["value"] = value[1];
                else
                    cookie["value"] = "";
                for (int i = 1; i < cookies.Length; ++i) {
#if !dotNETMF
                    value = regex.Split(cookies[i].Trim(), 2);
#else
                    value = cookies[i].Trim().Split(EQU, 2);
#endif
                    if (value.Length == 2)
                        cookie[value[0].ToUpper()] = value[1];
                    else
                        cookie[value[0].ToUpper()] = "";
                }
                // Tomcat can return SetCookie2 with path wrapped in "
                if (cookie.Contains("PATH")) {
                    string path = ((string)cookie["PATH"]);
                    if (path[0] == '"')
                        path = path.Substring(1);
                    if (path[path.Length - 1] == '"')
                        path = path.Substring(0, path.Length - 1);
                    cookie["PATH"] = path;
                }
                else {
                    cookie["PATH"] = "/";
                }
#if !dotNETMF
                if (cookie.Contains("EXPIRES")) {
                    cookie["EXPIRES"] = DateTime.Parse((string)cookie["EXPIRES"]);
                }
#endif
                if (cookie.Contains("DOMAIN")) {
                    cookie["DOMAIN"] = ((string)cookie["DOMAIN"]).ToLower();
                }
                else {
                    cookie["DOMAIN"] = host;
                }
                cookie["SECURE"] = cookie.Contains("SECURE");
                if (!container.Contains(cookie["DOMAIN"])) {
                    container[cookie["DOMAIN"]] = new Hashtable();
                }
                ((Hashtable)container[cookie["DOMAIN"]])[cookie["name"]] = cookie;
            }
        }
    }
开发者ID:hprose,项目名称:hprose-dotnet,代码行数:60,代码来源:CookieManager.cs

示例2: runTest

 public bool runTest()
 {
     Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
     int iCountErrors = 0;
     int iCountTestcases = 0;
     String strLoc = "Loc_000oo";
     String strValue;
     Hashtable dic1;
     try 
     {
         do
         {
             strLoc = "Loc_8345vdfv";
             dic1 = new Hashtable();
             for(int i=0; i<10; i++)
             {
                 strValue = "String_" + i;
                 dic1.Add(i, strValue);
             }
             iCountTestcases++;
             for(int i=0; i<10; i++)
             {
                 if(!dic1.Contains(i)) 
                 {
                     iCountErrors++;
                     Console.WriteLine("Err_561dvs_" + i + "! Expected value not returned, " + dic1.Contains(i));
                 }
             }
             iCountTestcases++;
             if(dic1.IsReadOnly) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_65323gdfgb! Expected value not returned, " + dic1.IsReadOnly);
             }
             dic1.Remove(0);
             iCountTestcases++;
             if(dic1.Contains(0)) 
             {
                 iCountErrors++;
                 Console.WriteLine("Err_65323gdfgb! Expected value not returned, " + dic1.Contains(0));
             }
         } while (false);
     } 
     catch (Exception exc_general ) 
     {
         ++iCountErrors;
         Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
     }
     if ( iCountErrors == 0 )
     {
         Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
         return true;
     }
     else
     {
         Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
         return false;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:59,代码来源:co3914get_isreadonly.cs

示例3: GameCenterPlayer

    public GameCenterPlayer( Hashtable ht )
    {
        if( ht.Contains( "playerId" ) )
            playerId = ht["playerId"] as string;

        if( ht.Contains( "alias" ) )
            alias = ht["alias"] as string;

        if( ht.Contains( "isFriend" ) )
            isFriend = (bool)ht["isFriend"];
    }
开发者ID:britg,项目名称:Pyroclasm,代码行数:11,代码来源:GameCenterPlayer.cs

示例4: TestContainsBasic

        public void TestContainsBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            Hashtable ht1 = null;

            string s1 = null;
            string s2 = null;

            int i = 0;

            ht1 = new Hashtable(); //default constructor
            Assert.False(ht1.Contains("No_Such_Key"));

            /// []  Testcase: add few key-val pairs
            ht1 = new Hashtable();
            for (i = 0; i < 100; i++)
            {

                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg = new StringBuilder(99);
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                ht1.Add(s1, s2);
            }

            for (i = 0; i < ht1.Count; i++)
            {
                sblMsg = new StringBuilder(99);
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                Assert.True(ht1.Contains(s1));
            }

            //
            // Remove a key and then check
            //
            sblMsg = new StringBuilder(99);
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            ht1.Remove(s1); //removes "Key_50"
            Assert.False(ht1.Contains(s1));
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:52,代码来源:ContainsTests.cs

示例5: create

    public static ReceiverColorTo create(GameObject gameObject, Hashtable hashtable)
    {
        ReceiverColorTo receiver = gameObject.AddComponent<ReceiverColorTo>();
        setTween(receiver, hashtable);

        if (hashtable.Contains("color")) receiver._desiredColor = (Color)hashtable["color"];
        if (hashtable.Contains("affect alpha")) receiver._affectAlpha = (bool)hashtable["affect alpha"];
        if (hashtable.Contains("use shared material")) receiver._useSharedMaterial = (bool)hashtable["use shared material"];

        receiver.play(gameObject, "destroy");

        return receiver;
    }
开发者ID:Rirols,项目名称:Theater,代码行数:13,代码来源:ReceiverColorTo.cs

示例6: start_import

 public void start_import(Hashtable project)
 {
     if(project.Contains("Location") && project.Contains("Name")) {
         if(checkProject(project["Location"].ToString(),project["Name"].ToString())) {
             this.project = project;
         } else {
             menu.setRender(true);
             menu.console("Das Project ist beschädigt.");
         }
     } else {
         menu.setRender(true);
         menu.console("Es wurde kein Project ausgewählt.");
     }
 }
开发者ID:WH160,项目名称:mindvision,代码行数:14,代码来源:import.cs

示例7: Populate

	public void Populate (Photo [] photos) {
		Hashtable hash = new Hashtable ();
		if (photos != null) {
			foreach (Photo p in photos) {
				foreach (Tag t in p.Tags) {
					if (!hash.Contains (t.Id)) {
						hash.Add (t.Id, t);
					}
				}
			}
		}

		foreach (Widget w in this.Children) {
			w.Destroy ();
		}
		
		if (hash.Count == 0) {
			/* Fixme this should really set parent menu
			   items insensitve */
			MenuItem item = new MenuItem (Mono.Unix.Catalog.GetString ("(No Tags)"));
			this.Append (item);
			item.Sensitive = false;
			item.ShowAll ();
			return;
		}

		foreach (Tag t in hash.Values) {
			TagMenuItem item = new TagMenuItem (t);
			this.Append (item);
			item.ShowAll ();
			item.Activated += HandleActivate;
		}
				
	}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:34,代码来源:PhotoTagMenu.cs

示例8: send

		// Envia a conexao ao servidor
		public void send(GameJsonAuthConnection.ConnectionAnswerWithState callback)
		{
			if (!semaphore.WaitOne(0))
			{
				//Debug.Log("Pero no.");
				return;
			}
			
			//Debug.Log("Yaarrrrr.");
			GameJsonAuthConnection conn = new GameJsonAuthConnection(url, callback);
			
			// Cria o header
			Hashtable table = new Hashtable(headers.Count);
			foreach (DictionaryEntry entry in headers) table.Add(entry.Key, entry.Value);
			
			// Decide se e uma conexao binaria
			string delimiter;
			if (!table.Contains("Content-Type")) delimiter = "&";
			else
			{
				Match match = Regex.Match(table["Content-Type"].ToString(), @"boundary=\""(.*)""");
				if (match.Success) delimiter = match.Groups[1].Value;
				else delimiter = "&";
			}
			
			byte[] fdata = (byte[]) data.Clone();
			
			string adata = null;
			
			if (delimiter == "&")
			{
				adata = "";
				if (data.Length != 0) adata += "&";
				adata += "device=" + WWW.EscapeURL(SystemInfo.deviceUniqueIdentifier.Replace("-","")) + "&token=" + WWW.EscapeURL(Save.GetString(PlayerPrefsKeys.TOKEN.ToString()));
			}
			else
			{
				adata = @"
Content-Type: text/plain; charset=""utf-8""
Content-disposition: form-data; name=""device""

" + SystemInfo.deviceUniqueIdentifier.Replace("-","") + @"
--" + delimiter + @"
Content-Type: text/plain; charset=""utf-8""
Content-disposition: form-data; name=""token""

" + Save.GetString(PlayerPrefsKeys.TOKEN.ToString()) + @"
--" + delimiter + @"--
";
				
				System.Array.Resize<byte>(ref fdata, fdata.Length - 4);
			}
			
			byte[] bdata = System.Text.Encoding.ASCII.GetBytes(adata);
			int size = fdata.Length;
			System.Array.Resize<byte>(ref fdata, fdata.Length + bdata.Length);
			bdata.CopyTo(fdata, size);
			
			conn.connect(fdata, table, id);
		}
开发者ID:uptopgames,项目名称:Minesweeper,代码行数:61,代码来源:GamePersistentConnection.cs

示例9: ColectControlByType

 private static void ColectControlByType(Type ctrlType, Control parent, Hashtable list)
 {
     if (list == null) return;
     foreach (Control ctrl in parent.Controls)
     {
         if ((ctrl.GetType() == ctrlType) && (ctrl.ID != null) && (!list.Contains(ctrl.ID))) list.Add(ctrl.ID, ctrl);
         ColectControlByType(ctrlType, ctrl, list);
     }
 }
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:9,代码来源:EmptyGridViewEx.cs

示例10: CouplingType

	public CouplingType (Hashtable info)
	{
		if(info != null)
		{
			ID = Helpers.ToInt (info ["idTipoEnganche"]);
			Code = info ["codigo"].ToString ();
			if(info.Contains("activo"))
				IsActive = Helpers.ToBool(info["activo"]);
		}
	}
开发者ID:juliancruz87,项目名称:transpp,代码行数:10,代码来源:CouplingType.cs

示例11: ConfigCouplingRequired

	public ConfigCouplingRequired (Hashtable info)
	{
		if(info != null)
		{
			ID = Helpers.ToInt (info ["idConfigEngancheRequerido"]);
			Description = info ["descripcion"].ToString ();
			if( info.Contains("activo"))
				IsActive = Helpers.ToBool(info["activo"]);
		}
	}
开发者ID:juliancruz87,项目名称:transpp,代码行数:10,代码来源:ConfigCouplingRequired.cs

示例12: create

    public static ReceiverScaleAdd create(GameObject gameObject, Hashtable hashtable)
    {
        ReceiverScaleAdd receiver = gameObject.AddComponent<ReceiverScaleAdd>();
        setTween(receiver, hashtable);

        if (hashtable.Contains("target")) receiver._target = (Vector3)hashtable["target"];

        receiver.play(gameObject, "destroy");

        return receiver;
    }
开发者ID:Rirols,项目名称:Theater,代码行数:11,代码来源:ReceiverScaleAdd.cs

示例13: create

    public static ReceiverRectMoveTo create(GameObject gameObject, Hashtable hashtable)
    {
        ReceiverRectMoveTo receiver = gameObject.GetComponent<ReceiverRectMoveTo>();
        if (receiver == null) receiver = gameObject.AddComponent<ReceiverRectMoveTo>();
        setTween(receiver, hashtable);

        if (hashtable.Contains("target")) receiver.target = (Vector2)hashtable["target"];

        receiver.play(gameObject, "destroy");

        return receiver;
    }
开发者ID:Rirols,项目名称:Theater,代码行数:12,代码来源:ReceiverRectMoveTo.cs

示例14: GameCenterAchievement

	public GameCenterAchievement( Hashtable ht )
	{
		if( ht.Contains( "identifier" ) )
			identifier = ht["identifier"] as string;
		
		if( ht.Contains( "hidden" ) )
			isHidden = (bool)ht["hidden"];
		
		if( ht.Contains( "completed" ) )
			completed = (bool)ht["completed"];
		
		if( ht.Contains( "percentComplete" ) )
			percentComplete = float.Parse( ht["percentComplete"].ToString() );
		
		// grab and convert the date
		if( ht.Contains( "lastReportedDate" ) )
		{
			double timeSinceEpoch = double.Parse( ht["lastReportedDate"].ToString() );
			DateTime intermediate = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc );
			lastReportedDate = intermediate.AddSeconds( timeSinceEpoch );
		}
	}
开发者ID:Avatarchik,项目名称:Duel-Off,代码行数:22,代码来源:GameCenterAchievement.cs

示例15: GameCenterScore

	public GameCenterScore( Hashtable ht )
	{
		if( ht.Contains( "category" ) )
			category = ht["category"] as string;
		
		if( ht.Contains( "formattedValue" ) )
			formattedValue = ht["formattedValue"] as string;
		
		if( ht.Contains( "value" ) )
			value = Int64.Parse( ht["value"].ToString() );
		
		if( ht.Contains( "context" ) )
			context = Int64.Parse( ht["context"].ToString() );
		
		if( ht.Contains( "playerId" ) )
			playerId = ht["playerId"] as string;
		
		if( ht.Contains( "rank" ) )
			rank = int.Parse( ht["rank"].ToString() );
		
		if( ht.Contains( "isFriend" ) )
			isFriend = (bool)ht["isFriend"];
		
		if( ht.Contains( "alias" ) )
			alias = ht["alias"] as string;
		else
			alias = "Anonymous";
		
		if( ht.Contains( "maxRange" ) )
			maxRange = int.Parse( ht["maxRange"].ToString() );
		
		// grab and convert the date
		if( ht.Contains( "date" ) )
		{
			double timeSinceEpoch = double.Parse( ht["date"].ToString() );
			DateTime intermediate = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc );
			date = intermediate.AddSeconds( timeSinceEpoch );
		}
	}
开发者ID:Avatarchik,项目名称:Duel-Off,代码行数:39,代码来源:GameCenterScore.cs


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