本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcStruct.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcStruct.ContainsKey方法的具体用法?C# XmlRpcStruct.ContainsKey怎么用?C# XmlRpcStruct.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CookComputing.XmlRpc.XmlRpcStruct
的用法示例。
在下文中一共展示了XmlRpcStruct.ContainsKey方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: toBool
/// <summary>
/// robust convert a data bit to a bool
/// </summary>
/// <param name="data"></param>
/// <param name="name"></param>
/// <returns></returns>
internal bool? toBool(XmlRpcStruct data, string name)
{
if (data.ContainsKey(name))
{
object val = data[name];
if (val is string)
{
bool result;
bool good = bool.TryParse(val as string, out result);
return result;
}
return data[name] as bool?;
}
return null;
}
示例2: toInt
/// <summary>
/// robust convert to int. can take int strings as well as ints
/// </summary>
/// <param name="data"></param>
/// <param name="name"></param>
/// <returns></returns>
internal int toInt(XmlRpcStruct data, string name)
{
if (data.ContainsKey(name))
{
int n;
object val = data[name];
if (val is string)
{
bool good = int.TryParse((string)val, out n);
if (good)
return n;
}
else if (val is int)
return (int)(val);
}
return 0;
}
示例3: decodeSingleError
private TLErrorMessage decodeSingleError(XmlRpcStruct message)
{
if (message.ContainsKey("code") && message.ContainsKey("message"))
return new TLErrorMessage(message);
else
return null;
}
示例4: Metadata
public Metadata(XmlRpcStruct md)
{
if (md.ContainsKey("Artist"))
Artist = (string)md["Artist"];
if (md.ContainsKey("Album"))
Album = (string)md["Album"];
if (md.ContainsKey("Title"))
Track = (string)md["Title"];
if (md.ContainsKey("Uri"))
Uri = (string)md["Uri"];
if (md.ContainsKey("AlbumArtUri"))
AlbumArtUri = (string)md["AlbumArtUri"];
if (md.ContainsKey("PlayTime"))
PlayTime = (int)md["PlayTime"];
}
示例5: Event
public Event(XmlRpcStruct x)
{
if (x.ContainsKey("Name"))
Name = (string)x["Name"];
Args = new List<object>();
if (x.ContainsKey("Args"))
{
object o = x["Args"];
object[] array = (object[])o;
Args.AddRange(array);
}
}
示例6: toExecStatus
/// <summary>
/// parse an execution status
/// </summary>
/// <param name="data"></param>
/// <param name="name"></param>
/// <returns></returns>
internal TestCaseResultStatus toExecStatus(XmlRpcStruct data, string name)
{
TestCaseResultStatus result = TestCaseResultStatus.undefined;
if (data.ContainsKey(name))
{
char c = toChar(data, name);
switch (c)
{
case 'f':
case 'F': result = TestCaseResultStatus.Fail;
break;
case 'b':
case 'B': result = TestCaseResultStatus.Blocked;
break;
case 'p':
case 'P': result = TestCaseResultStatus.Pass;
break;
}
}
return result;
}
示例7: GeneralResult
internal GeneralResult(XmlRpcStruct data)
{
operation = (string)data["operation"];
status = (bool)(data["status"]);
id = toInt(data, "id");
message = (string)data["message"];
if ((data.ContainsKey("additionalInfo") &&
(data["additionalInfo"] is XmlRpcStruct)))
additionalInfo = new AdditionalInfo(data["additionalInfo"] as XmlRpcStruct);
else
additionalInfo = null;
}
示例8: TestCaseFromTestSuite
internal TestCaseFromTestSuite(XmlRpcStruct data)
{
active = int.Parse((string)data["active"]) == 1;
id = toInt(data, "id");
name = (string)data["name"];
version = toInt(data, "version");
tcversion_id = toInt(data, "tcversion_id");
//steps = (string)data["steps"];
//expected_results = (string)data["expected_results"];
external_id = (string)data["tc_external_id"];
testSuite_id = toInt(data, "parent_id");
is_open = int.Parse((string)data["is_open"]) == 1;
modification_ts = base.toDate(data, "modification_ts");
updater_id = toInt(data, "updater_id");
execution_type = toInt(data, "execution_type");
summary = (string)data["summary"];
if (data.ContainsKey("details"))
details = (string)data["details"];
else
details = "";
author_id = toInt(data, "author_id");
creation_ts = base.toDate(data, "creation_ts");
importance = toInt(data, "importance");
parent_id = toInt(data, "parent_id");
node_type_id = toInt(data, "node_type_id");
node_order = toInt(data, "node_order");
node_table = (string)data["node_table"];
layout = (string)data["layout"];
status = toInt(data, "status");
preconditions = (string)data["preconditions"];
}
示例9: toChar
/// <summary>
/// convert a data value to a single char
/// </summary>
/// <param name="data"></param>
/// <param name="name"></param>
/// <returns></returns>
internal char toChar(XmlRpcStruct data, string name)
{
if (data.ContainsKey(name) && (data[name] is string))
{
string s = (string)(data[name]);
return s[0];
}
return '\x00';
}
示例10: toDate
/// <summary>
/// robust convert a date string
/// </summary>
/// <param name="data">key value dictionary</param>
/// <param name="name">name of field to use</param>
/// <returns></returns>
internal DateTime toDate(XmlRpcStruct data, string name)
{
if (data.ContainsKey(name))
{
DateTime n;
bool good = DateTime.TryParse((string)data[name], out n);
if (good)
return n;
}
return DateTime.MinValue;
}
示例11: TestPlanTotal
internal TestPlanTotal(XmlRpcStruct data)
{
Total_tc = toInt(data, "total_tc");
if (data.ContainsKey("type"))
Type = (string)data["type"];
if (data.ContainsKey("name"))
Name = (string)data["name"];
XmlRpcStruct xdetails = data["details"] as XmlRpcStruct;
foreach (string key in xdetails.Keys)
{
XmlRpcStruct val = xdetails[key] as XmlRpcStruct;
int qty = toInt(val,"qty");
Details.Add(key, qty);
}
}
示例12: Output
/// <summary>
/// Constructor.
/// </summary>
/// <param name="output">The output from the server request.</param>
protected Output( XmlRpcStruct output )
{
if ( output.ContainsKey( "status" ) )
this.StatusString = ( string ) output[ "status" ];
else
this.StatusString = "200 OK";
this.Status = ConvertStatusToStatusCode( StatusString );
this.Seconds = ( double ) output[ "seconds" ];
}
示例13: AttemptStructDeserialization
public static object AttemptStructDeserialization(XmlRpcStruct response, Type output)
{
MemberInfo[] outputMembers = output.GetMembers();
object result = Activator.CreateInstance(output);
PropertyInfo[] properties = output.GetProperties();
foreach(PropertyInfo property in properties)
{
Console.WriteLine (property.Name);
if(response.ContainsKey (property.Name))
{
Console.WriteLine("Declaring type:{0}, output type:{1}", property.PropertyType, response[property.Name].GetType());
if(Type.Equals(property.PropertyType, response[property.Name].GetType()))
{
Console.WriteLine ("Identical Type! Woot! Value is " + response[property.Name]);
property.SetValue(result, response[property.Name], null);
}
}
}
return result;
}
示例14: StructToPost
private static Post StructToPost(Post p, XmlRpcStruct x, bool publish)
{
/*
* 1. struct {
2. string postid;
3. DateTime dateCreated;
4. string title;
5. string description;
6. string[] categories;
7. bool publish;
8. }
*/
if (p == null)
{
p = new Post();
p.Id = x.ContainsKey("postid") ? Convert.ToInt32(x["postid"]) : 0;
}
p.Approved = publish;
p.Body = x["description"].ToString();
p.Title = x["title"].ToString();
if (x.ContainsKey("categories"))
{
IEnumerable categories = x["categories"] as IEnumerable;
if (categories != null)
{
foreach(object category in categories)
{
if (category != null)
{
Tag tag = new Tag { TagName = category.ToString() };
p.AddTag(tag);
}
}
}
}
return p;
}