本文整理汇总了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;
}
}
}
示例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;
}
}
示例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"];
}
示例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));
}
示例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;
}
示例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.");
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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"]);
}
}
示例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"]);
}
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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 );
}
}