本文整理汇总了C#中Newtonsoft.Json.Linq.JObject.ExtractValue方法的典型用法代码示例。如果您正苦于以下问题:C# JObject.ExtractValue方法的具体用法?C# JObject.ExtractValue怎么用?C# JObject.ExtractValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JObject
的用法示例。
在下文中一共展示了JObject.ExtractValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromJson
/// <summary>
/// Build SyncTarget from json
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public new static SyncDownTarget FromJson(JObject target)
{
if (target == null) return null;
var query = target.ExtractValue<string>(Constants.Query);
SoqlSyncDownTarget ssdt = new SoqlSyncDownTarget(query);
ssdt.setSkipGroupingParenthesis(target.ExtractValue<bool>("skipGroupingParenthesis"));
return ssdt;
}
示例2: FromJson
public static SyncOptions FromJson(JObject options)
{
if (options == null)
return null;
var mergeModeStr = options.ExtractValue<string>(Constants.MergeMode);
var mergeMode = String.IsNullOrWhiteSpace(mergeModeStr)
? SyncState.MergeModeOptions.None
: (SyncState.MergeModeOptions) Enum.Parse(typeof (SyncState.MergeModeOptions), mergeModeStr);
var array = options.ExtractValue<JArray>(Constants.FieldList);
return array == null ? new SyncOptions(null, mergeMode) : new SyncOptions(array.ToObject<List<string>>(), mergeMode);
}
示例3: SalesforceObjectLayoutColumn
public SalesforceObjectLayoutColumn(JObject rawData)
{
if (rawData == null)
{
throw new SmartStoreException("rawData parameter cannot be null");
}
Name = rawData.ExtractValue<string>(Constants.LayoutNameField);
Field = rawData.ExtractValue<string>(Constants.LayoutFieldField);
Format = rawData.ExtractValue<string>(Constants.LayoutFormatField);
Label = rawData.ExtractValue<string>(Constants.LayoutLabelField);
RawData = RawData;
}
示例4: FromJson
public static SyncOptions FromJson(JObject options)
{
if (options == null)
return null;
var mergeModeStr = options.ExtractValue<string>(Constants.MergeMode);
var mergeMode = String.IsNullOrWhiteSpace(mergeModeStr)
? SyncState.MergeModeOptions.None
: (SyncState.MergeModeOptions) Enum.Parse(typeof (SyncState.MergeModeOptions), mergeModeStr);
var array = options.ExtractValue<JArray>(Constants.FieldList);
SyncOptions so = new SyncOptions(array.ToObject<List<string>>(), mergeMode);
array = options.ExtractValue<JArray>("fieldsToExcludeOnUpdate");
so.setFieldsToExcludeOnUpdate(array.ToObject<List<string>>());
return so;
}
示例5: FromJson
/// <summary>
/// Build SyncTarget from json
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
public new static SyncDownTarget FromJson(JObject target)
{
if (target == null) return null;
var query = target.ExtractValue<string>(Constants.Query);
return new SoqlSyncDownTarget(query);
}
示例6: SalesforceObject
public SalesforceObject(JObject rawData)
{
if (rawData == null)
{
throw new SmartStoreException("rawData parameter cannot be null");
}
var data = rawData.ExtractValue<string>(Constants.Id);
if (data == null || String.IsNullOrWhiteSpace(data))
{
ObjectId = rawData.ExtractValue<string>(Constants.Id.ToLower());
ObjectType = rawData.ExtractValue<string>(Constants.Type.ToLower());
Name = rawData.ExtractValue<string>(Constants.Name.ToLower());
}
else
{
ObjectId = data;
Name = rawData.ExtractValue<string>(Constants.Name);
var attributes = rawData.ExtractValue<JObject>(Constants.Attributes);
if (attributes != null)
{
ObjectType = attributes.ExtractValue<string>(Constants.Type.ToLower());
if (String.IsNullOrWhiteSpace(ObjectType) || Constants.RecentlyViewed.Equals(ObjectType) ||
Constants.NullString.Equals(ObjectType))
{
ObjectType = rawData.ExtractValue<string>(Constants.Type);
}
}
}
RawData = rawData;
if (ObjectId != null)
{
_hashcode = ObjectId.GetHashCode();
}
_hashcode ^= rawData.GetHashCode() + _hashcode * 37;
}
示例7: SalesforceObjectType
public SalesforceObjectType(JObject rawData)
{
if (rawData == null)
{
throw new SmartStoreException("rawData parameter cannot be null");
}
Name = rawData.ExtractValue<string>(Constants.NameField);
KeyPrefix = rawData.ExtractValue<string>(Constants.KeyprefixField);
Label = rawData.ExtractValue<string>(Constants.LabelField);
LabelPlural = rawData.ExtractValue<string>(Constants.LabelpluralField);
if (String.IsNullOrWhiteSpace(Label))
{
Label = Name;
}
if (String.IsNullOrWhiteSpace(LabelPlural))
{
LabelPlural = Label;
}
RawData = RawData;
IsSearchable = !rawData.ExtractValue<bool>(Constants.HiddenField) &&
rawData.ExtractValue<bool>(Constants.SearchableField);
IsLayoutable = !rawData.ExtractValue<bool>(Constants.HiddenField) &&
rawData.ExtractValue<bool>(Constants.LayoutableField);
Fields = RawData.ExtractValue<JArray>(Constants.FieldsField);
/*
* Extracts a few flagship fields and sets them to instance variables
* for easy retrieval.
*/
if (Fields == null || Fields.Count <= 0) return;
for (int i = 0, max = Fields.Count; i < max; i++)
{
var field = Fields[i].Value<JObject>();
var nameFieldPresent = field.ExtractValue<bool>(Constants.NameFieldField);
if (!nameFieldPresent) continue;
/*
* Some objects, such as 'Account', have more than one
* name field, like 'Name', 'First Name', and 'Last Name'.
* This check exists to ensure that we use the first
* name field, which is the flagship name field, and
* not the last one. If it is already set, we won't
* overwrite it.
*/
if (String.IsNullOrWhiteSpace(NameField) || Constants.NullString.Equals(NameField))
{
NameField = field.ExtractValue<string>(Constants.NameField);
}
else
{
// NameField is set, no need to continue.
break;
}
}
}
示例8: SyncDownTarget
protected SyncDownTarget(JObject target)
: base(target)
{
QueryType = (QueryTypes)Enum.Parse(typeof(QueryTypes), target.ExtractValue<string>(Constants.QueryType));
}
示例9: FromJson
/// <summary>
/// Build SyncState from json
/// </summary>
/// <param name="sync"></param>
/// <returns></returns>
public static SyncState FromJson(JObject sync)
{
if (sync == null) return null;
var jsonTarget = sync.ExtractValue<JObject>(Constants.SyncTarget);
var syncType = (SyncTypes)Enum.Parse(typeof(SyncTypes), sync.ExtractValue<string>(Constants.SyncType));
var state = new SyncState
{
Id = sync.ExtractValue<long>(SmartStore.Store.SmartStore.SoupEntryId),
Target = (syncType == SyncTypes.SyncDown ? (SyncTarget) SyncDownTarget.FromJson(jsonTarget) : SyncUpTarget.FromJSON(jsonTarget)),
Options = SyncOptions.FromJson(sync.ExtractValue<JObject>(Constants.SyncOptions)),
SoupName = sync.ExtractValue<string>(Constants.SyncSoupName),
Progress = sync.ExtractValue<int>(Constants.SyncProgress),
TotalSize = sync.ExtractValue<int>(Constants.SyncTotalSize),
SyncType = syncType,
Status =
(SyncStatusTypes)
Enum.Parse(typeof (SyncStatusTypes), sync.ExtractValue<string>(Constants.SyncStatus)),
MaxTimeStamp = sync.ExtractValue<long>(Constants.SyncMaxTimeStamp)
};
return state;
}
示例10: SoqlSyncDownTarget
public SoqlSyncDownTarget(JObject target) : base(target)
{
this.Query = target.ExtractValue<string>(QueryString);
}
示例11: MruSyncDownTarget
public MruSyncDownTarget(JObject target) : base(target)
{
FieldList = target.ExtractValue<JArray>(Constants.FieldList).ToObject<List<string>>();
ObjectType = target.ExtractValue<string>(Constants.SObjectType);
}
示例12: SyncTarget
protected SyncTarget(JObject target)
{
_idFieldName = target != null ? target.ExtractValue<string>(IdFieldName) : Constants.Id;
_modificationDateFieldName = target != null ? target.ExtractValue<string>(ModificationDateFieldName) : Constants.LastModifiedDate;
}
示例13: SoslSyncDownTarget
public SoslSyncDownTarget(JObject target) : base(target)
{
this.Query = target.ExtractValue<string>(Constants.Query);
}