本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.GetBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.GetBoolean方法的具体用法?C# JObject.GetBoolean怎么用?C# JObject.GetBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.GetBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridEditorLinkPickerTitleConfig
private GridEditorLinkPickerTitleConfig(JObject obj) : base(obj) {
Show = obj.GetBoolean("show");
}
示例2: Parse
/// <summary>
/// Parses the specified <code>obj</code> into an instance of <see cref="LinkPickerItem"/>.
/// </summary>
/// <param name="obj">The instance of <see cref="JObject"/> to be parsed.</param>
public static LinkPickerItem Parse(JObject obj) {
if (obj == null) return null;
// Get the ID
int id = obj.GetInt32("id");
// Parse the link mode
LinkPickerMode mode;
if (obj.GetValue("mode") == null) {
if (obj.GetBoolean("isMedia")) {
mode = LinkPickerMode.Media;
} else if (id > 0) {
mode = LinkPickerMode.Content;
} else {
mode = LinkPickerMode.Url;
}
} else {
mode = (LinkPickerMode) Enum.Parse(typeof(LinkPickerMode), obj.GetString("mode"), true);
}
// Parse remaining properties
return new LinkPickerItem {
JObject = obj,
Id = id,
Name = obj.GetString("name"),
RawUrl = obj.GetString("url"),
Target = obj.GetString("target"),
Mode = mode
};
}
示例3: GetBoolean
public void GetBoolean() {
JObject root = new JObject();
root.Add("property1", null);
root.Add("property2", true);
root.Add("property3", false);
root.Add("property4", 1);
root.Add("property5", 0);
root.Add("property6", "true");
root.Add("property7", "false");
JObject obj = new JObject();
obj.Add("root", root);
Assert.AreEqual(false, obj.GetBoolean("root.property0"), "Check #1 failed");
Assert.AreEqual(false, obj.GetBoolean("root.property1"), "Check #2 failed");
Assert.AreEqual(true, obj.GetBoolean("root.property2"), "Check #3 failed");
Assert.AreEqual(false, obj.GetBoolean("root.property3"), "Check #4 failed");
Assert.AreEqual(true, obj.GetBoolean("root.property4"), "Check #5 failed");
Assert.AreEqual(false, obj.GetBoolean("root.property5"), "Check #6 failed");
Assert.AreEqual(true, obj.GetBoolean("root.property6"), "Check #7 failed");
Assert.AreEqual(false, obj.GetBoolean("root.property7"), "Check #8 failed");
}
示例4: Parse
/// <summary>
/// Parses an area from the specified <code>obj</code>.
/// </summary>
/// <param name="row">The parent row of the area.</param>
/// <param name="obj">The instance of <code>JObject</code> to be parsed.</param>
public static GridArea Parse(GridRow row, JObject obj) {
// Some input validation
if (obj == null) throw new ArgumentNullException("obj");
// Parse the array of allow blocks
JArray allowed = obj.GetArray("allowed");
// Parse basic properties
GridArea area = new GridArea(obj) {
Row = row,
Grid = obj.GetInt32("grid"),
AllowAll = obj.GetBoolean("allowAll"),
Allowed = allowed == null ? new string[0] : allowed.Select(x => (string)x).ToArray(),
Styles = obj.GetObject("styles", GridDictionary.Parse),
Config = obj.GetObject("config", GridDictionary.Parse)
};
// Parse the controls
area.Controls = obj.GetArray("controls", x => GridControl.Parse(area, x)) ?? new GridControl[0];
// Update "PreviousArea" and "NextArea" properties
for (int i = 1; i < area.Controls.Length; i++) {
area.Controls[i - 1].NextControl = area.Controls[i];
area.Controls[i].PreviousControl = area.Controls[i - 1];
}
// Return the row
return area;
}