本文整理汇总了C#中JObject类的典型用法代码示例。如果您正苦于以下问题:C# JObject类的具体用法?C# JObject怎么用?C# JObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JObject类属于命名空间,在下文中一共展示了JObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSharpTest
public static JObject CSharpTest(RPCRequestInfo c, JObject p)
{
Thread.Sleep ((int)p ["ms"].AsNumber (0.0));
return new JObject {
{ "hello", "world" }
};
}
示例2: LoadFromJson
public void LoadFromJson(JObject source)
{
// This is where the automatic deserialization takes place. We just tell the Jobject that we want an object of the type RelfectionData and it will handle the rest
var reflectionDataObject = source.Deserialize<ReflectionData>();
// This is just a simple method a created to read the data from reflectionDataObject back into this object
reflectionDataObject.ToMonoBehavior(this);
}
示例3: TransactionInfo
public TransactionInfo(JObject data) : base(data)
{
this.From = new Guid(data["From"].ToString());
this.To = new Guid(data["To"].ToString());
this.ConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["ConstraintKind"].ToString());
if (this.ConstraintKind != ConstraintKinds.None) this.Constraint = data["Constraint"].ToString();
}
示例4: Example
public void Example()
{
#region Usage
JObject o = new JObject
{
{ "Cpu", "Intel" },
{ "Memory", 32 },
{
"Drives", new JArray
{
"DVD",
"SSD"
}
}
};
Console.WriteLine(o.ToString());
// {
// "Cpu": "Intel",
// "Memory": 32,
// "Drives": [
// "DVD",
// "SSD"
// ]
// }
#endregion
}
示例5: RPCException
public RPCException(string code, string msg, RPCException orig, JObject data = null)
{
ErrorCode = code;
ErrorMessage = msg + ": " + orig.ErrorMessage;
ErrorData = data ?? new JObject ();
ErrorData ["orig"] = orig.AsHeader ();
}
示例6: Download
public Download(Uri uri, string key, CookieContainer cc, JObject song)
{
m_uri = uri;
m_key = key;
m_cc = cc;
m_song = song;
song["Status"] = "Opening file";
string filename = (string)song["ArtistName"] + " - " + (string)song["Name"] + ".mp3";
m_logger = new Logger(this.GetType().ToString() + " " + filename);
string dst = "";
string path = "";
if (Main.PATH.Length != 0)
path = Main.PATH + Path.DirectorySeparatorChar;
dst = path + filename;
try
{
m_path = dst;
m_fs = new FileStream(dst, FileMode.Create);
}
catch (Exception ex)
{
char[] invalf = Path.GetInvalidFileNameChars();
foreach (char c in invalf)
filename = filename.Replace(c, '_');
dst = path + filename;
try
{
m_path = dst;
m_fs = new FileStream(dst, FileMode.Create);
}
catch (Exception exc)
{
for (int i = 0; i < dst.Length; i++)
{
if (!Char.IsLetterOrDigit(dst[i]))
filename = filename.Replace(dst[i], '_');
dst = path + filename;
}
try
{
m_path = dst;
m_fs = new FileStream(dst, FileMode.Create);
}
catch (Exception exc2)
{
throw new Exception("Could not save the file buddy. (" + exc2.Message + ")");
}
}
}
m_logger.Info("Starting download");
song["Status"] = "Starting download";
Segment s = new Segment(uri, cc, key, 0, SEGMENT_SIZE-1, m_path);
m_segments.Add(s);
s.Progress += new EventHandler(s_Progress);
s.HeadersReceived += new Segment.HeadersReceivedHandler(s_HeadersReceived);
s.Start();
m_start = DateTime.Now;
}
示例7: ToJson
public JObject ToJson()
{
JObject json = new JObject();
json["stack"] = StackScript.ToHexString();
json["redeem"] = RedeemScript.ToHexString();
return json;
}
示例8: ProccessDefination
public ProccessDefination(JObject data) : base(data)
{
this.StartAlias = data["StartAlias"].ToString();
this.FinishAlias = data["FinishAlias"].ToString();
var rtIdData = data["RuntimeId"];
if (rtIdData != null) this.RuntimeId = new Guid(rtIdData.ToString());
}
示例9: CreateResponse
private static JObject CreateResponse(JObject id)
{
JObject response = new JObject();
response["jsonrpc"] = "2.0";
response["id"] = id;
return response;
}
示例10: Example
public void Example()
{
#region Usage
JObject o = new JObject
{
{ "name1", "value1" },
{ "name2", "value2" }
};
JsonWriter writer = o.CreateWriter();
writer.WritePropertyName("name3");
writer.WriteStartArray();
writer.WriteValue(1);
writer.WriteValue(2);
writer.WriteEndArray();
Console.WriteLine(o.ToString());
// {
// "name1": "value1",
// "name2": "value2",
// "name3": [
// 1,
// 2
// ]
// }
#endregion
}
示例11: Example
public void Example()
{
#region Usage
JValue s1 = new JValue("A string");
JValue s2 = new JValue("A string");
JValue s3 = new JValue("A STRING");
Console.WriteLine(JToken.DeepEquals(s1, s2));
// true
Console.WriteLine(JToken.DeepEquals(s2, s3));
// false
JObject o1 = new JObject
{
{ "Integer", 12345 },
{ "String", "A string" },
{ "Items", new JArray(1, 2) }
};
JObject o2 = new JObject
{
{ "Integer", 12345 },
{ "String", "A string" },
{ "Items", new JArray(1, 2) }
};
Console.WriteLine(JToken.DeepEquals(o1, o2));
// true
Console.WriteLine(JToken.DeepEquals(s1, o1["String"]));
// true
#endregion
}
示例12: GetTypeFromJObject
private IElasticCoreType GetTypeFromJObject(JObject po, JsonSerializer serializer)
{
JToken typeToken;
serializer.TypeNameHandling = TypeNameHandling.None;
if (po.TryGetValue("type", out typeToken))
{
var type = typeToken.Value<string>().ToLowerInvariant();
switch (type)
{
case "string":
return serializer.Deserialize(po.CreateReader(), typeof(StringMapping)) as StringMapping;
case "float":
case "double":
case "byte":
case "short":
case "integer":
case "long":
return serializer.Deserialize(po.CreateReader(), typeof(NumberMapping)) as NumberMapping;
case "date":
return serializer.Deserialize(po.CreateReader(), typeof(DateMapping)) as DateMapping;
case "boolean":
return serializer.Deserialize(po.CreateReader(), typeof(BooleanMapping)) as BooleanMapping;
case "binary":
return serializer.Deserialize(po.CreateReader(), typeof(BinaryMapping)) as BinaryMapping;
}
}
return null;
}
示例13: ToJson
public JObject ToJson()
{
JObject json = new JObject();
json["usage"] = Usage;
json["data"] = Data.ToHexString();
return json;
}
示例14: FromJson
public static ProcessDefination FromJson(JObject data) {
var entity = new ProcessDefination();
entity.Id = new Guid(data["Id"].ToString());
entity.ActivityDefinationId = new Guid(data["ActivityDefinationId"].ToString());
entity.ActivityId = new Guid(data["ActivityId"].ToString());
entity.Description = data["Description"].ToString();
var arr = data["ActivedActivityIds"] as JArray;
if (arr != null) {
entity.ActivedActivityIds = new List<Guid>();
foreach (JToken item in arr) {
entity.ActivedActivityIds.Add(new Guid(item.ToString()));
}
}
var extra = data["Extra"] as JObject;
if (extra != null)
{
entity.Extras = new Dictionary<string, string>();
foreach (var pair in extra)
{
entity.Extras.Add(pair.Key, pair.Value.ToString());
}
}
return entity;
}
示例15: TransactionDefination
public TransactionDefination(JObject data) : base(data)
{
this.FromAlias = data["FromAlias"].ToString();
this.ToAlias = data["ToAlias"].ToString();
this.ConstraintKind = (ConstraintKinds)Enum.Parse(typeof(ConstraintKinds), data["ConstraintKind"].ToString());
if (this.ConstraintKind != ConstraintKinds.None) this.Constraint = data["Constraint"]?.ToString();
}