本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.Select方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.Select方法的具体用法?C# JArray.Select怎么用?C# JArray.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonDataArray
public JsonDataArray( JArray array, IDataHost host )
{
foreach ( var item in array.Select( item => JsonDataObject.ConvertValue( item, host ) ) )
Add( item );
_host = host;
}
示例2: DeserializeMessages
//дописать десериализацию, тяжко
private static List<Message> DeserializeMessages(JArray messagesArray)
{
DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
List<Message> messagesList = messagesArray.Select(x => new Message
{
Id = (int)x["id"],
Date = dtDateTime.AddSeconds((int)x["date"]).ToLocalTime(),
Out = Boolean.Parse(x["out"].ToString()),
UserId = (int)x["user_id"],
ReadState = Boolean.Parse(x["read_state"].ToString()),
Title = x["title"].ToString(),
Body = x["body"].ToString(),
}).ToList();
return messagesList;
}
示例3: ParseAccountState
private static ShaMap ParseAccountState(JArray state)
{
var stateMap = new ShaMap();
var entries = state.Select((t) =>
{
StObject so = t["json"];
Assert.AreEqual(t["binary"].ToString(), so.ToHex(), t.ToString() + " " + so.ToJson());
return new LedgerEntry(so);
});
foreach (var ledgerEntry in entries)
{
stateMap.AddItem(ledgerEntry.Index(), ledgerEntry);
}
return stateMap;
}
示例4: Create
/// <summary>
/// Create a TreeNode and its subtrees for the <paramref name="obj"/> instance beeing a <see cref="JArray"/> instance.
/// </summary>
/// <param name="obj"></param>
/// <param name="depth"></param>
/// <returns></returns>
public static TreeNode Create(JArray obj, int depth)
{
var node = new JArrayTreeNode(obj);
if (depth != 1)
{
int remainingDepth = (depth == UnlimitedDepth ? UnlimitedDepth : depth - 1);
node.Nodes.AddRange(obj
.Select(o => Create((dynamic)o, remainingDepth))
.Cast<TreeNode>()
.ToArray()
);
}
return node;
}
示例5: Signatures
public void Signatures(string name, JArray sig, bool isDER, bool isValid)
{
try
{
var derSig = sig.Select(x => (byte) x).ToArray();
var s = ECDSASignature.FromDER(derSig);
Assert.IsTrue(isValid);
}
catch (Exception e)
{
if (e is FormatException || e is EndOfStreamException)
Assert.False(isValid);
else
Assert.Fail(name);
}
}
示例6: AddMembersToParty
private void AddMembersToParty(Party party, JArray members)
{
if (members == null) return;
string[] items = members.Select(jv => (string)jv).ToArray();
if (items.Length != party.Members.Length)
{
foreach (string member in items)
{
PlayerCharacter character = Entity.GetEntity<Player>(Guid.Parse(member)).Character;
if (party.Leader == character) continue;
if (party.Members.Contains(character)) continue;
party.RemoveMember(character);
}
if (!items.Any())
{
// Remove all members
foreach (PlayerCharacter member in party.Members)
{
if (party.Leader == member) continue;
party.RemoveMember(member);
}
}
}
else
{
foreach (string entityId in items)
{
PlayerCharacter groupmember = Entity.GetEntity<Player>(Guid.Parse(entityId)).Character;
Party groupMembersParty = Game.Zone.Parties.FirstOrDefault(x => x.Leader == groupmember);
party.RemoveInvite(groupMembersParty); // remove added Group from invites
party.MergeParty(groupMembersParty);
}
}
}
示例7: extractVars
private List<Var> extractVars(JArray array) {
if (array == null) {
return new List<Var>();
} else {
return array.Select(obj => extractVar((JObject)obj)).ToList();
}
}
示例8: ParseMarketTrades
public static List<MarketTrade> ParseMarketTrades(MarketId marketId, JArray tradesJson)
{
return tradesJson.Select(
trade => ParseMarketTrade(marketId, (JObject)trade)
).ToList();
}
示例9: ParseFixtureOutcomes
private FixtureOdds ParseFixtureOutcomes(JArray outcomes)
{
FixtureOdds res = null;
foreach (var outcome in outcomes.Select(x => x.ToObjectOrDefault<JObject>()).Where(x => x != null))
{
var lbl = outcome.GetPropertyValue<string>("label");
var odds = outcome.GetPropertyValue<double>("odds") / 1000;
if (lbl == "1")
{
res = res ?? new FixtureOdds();
res.HomeWin = odds;
}
else if (lbl == "X")
{
res = res ?? new FixtureOdds();
res.Draw = odds;
}
else
if (lbl == "2")
{
res = res ?? new FixtureOdds();
res.AwayWin = odds;
}
}
return res;
}
示例10: StartCreatingSModeCodeOperators
//.........这里部分代码省略.........
Console.WriteLine("Created organizationData part for organization smode code operator with name {0}", operName);
lotId = lot.LotId;
bool orgLotIdAdded = orgLotIdToOrgNom.TryAdd(lotId, Utils.ToJObject(
new
{
nomValueId = lotId,
name = operName,
nameAlt = operNameEN ?? operName
}));
if (!orgLotIdAdded)
{
throw new Exception(string.Format("lotId {0} already present in orgLotIdToOrgNom dictionary", lotId));
}
if (!orgOperatorIdToLotId.ContainsKey(operId))
{
orgOperatorIdToLotId.TryAdd(operId, lotId);
}
}
string post = null;
string city = null;
if (!string.IsNullOrEmpty(adrCity))
{
var postCodeAndCity = new Regex(@"^(\D+)(\s)(\d+)$|^(\D+)$|^(\d+)(\s)(\D+)$");
Match match = postCodeAndCity.Match(adrCity);
if (match.Success)
{
post = !string.IsNullOrEmpty(match.Groups[3].Value) ? match.Groups[3].Value : match.Groups[5].Value;
city = !string.IsNullOrEmpty(match.Groups[1].Value) ? match.Groups[1].Value :
(!string.IsNullOrEmpty(match.Groups[7].Value) ? match.Groups[7].Value : match.Groups[4].Value);
}
}
var settlement = !string.IsNullOrEmpty(city) ? noms["cities"].Where(v => v.Value.Name == city.Trim()).Select(v => v.Value).FirstOrDefault() : null;
lotIndex = lotRepository.GetLotIndex(lotId, fullAccess: true);
var partContent = Utils.ToJObject(new
{
__oldId = operId,
__migrTable = "sModeCodeOperatorAddress",
addressType = noms["addressTypes"].ByCode("TMP"),
valid = noms["boolean"].ByCode("Y"),
settlement = settlement,
postalCode = post,
address = string.Format("{0} {1}", adrStr, adrCity),
addressAlt = string.Format("{0} {1}", adrStr, adrCity)
});
PartVersion partVersion = null;
string caseTypeNomAlias = null;
if (lotIndex.Set.Alias == "Person")
{
partVersion = lotIndex.CreatePart("personAddresses/*", partContent, context);
caseTypeNomAlias = "personCaseTypes";
}
else
{
partVersion = lotIndex.CreatePart("organizationAddresses/*", partContent, context);
caseTypeNomAlias = "organizationCaseTypes";
}
JArray files = new JArray(){
noms[caseTypeNomAlias].Values.Select(c =>
Utils.ToJObject(new
{
isAdded = true,
file = (object)null,
caseType = Utils.ToJObject(c),
bookPageNumber = (string)null,
pageCount = (int?)null,
applications = new JArray()
}))
};
fileRepository.AddFileReferences(partVersion.Part, files.Select(f => f.ToObject<CaseDO>()));
unitOfWork.Save();
try
{
lotIndex.Commit(context, lotEventDispatcher);
}
//swallow the Cannot commit without modifications exception
catch (InvalidOperationException)
{
}
unitOfWork.Save();
Console.WriteLine("Migrated sModeCode operatorId : {0}", operId);
}
}
catch (Exception e)
{
Console.WriteLine("Error in creation of organization with smode code operator name {0}", oper.Get<string>("operatorName"));
cts.Cancel();
throw;
}
}
}
示例11: ParseObjectState
static EdgeObjectState ParseObjectState(JArray items)
{
return ParseObjectState (items.Select(x=> (string)x).ToArray());
}
示例12: GetOptimized
/// <summary>
/// Return array of optimized URLs
/// </summary>
/// <param name="fileRefs"></param>
/// <param name="cdfType"></param>
/// <param name="httpContext"></param>
/// <returns></returns>
protected JArray GetOptimized(JArray fileRefs, ClientDependencyType cdfType, HttpContextBase httpContext)
{
var depenencies = fileRefs.Select(x =>
{
var asString = x.ToString();
if (asString.StartsWith("/") == false)
{
if (Uri.IsWellFormedUriString(asString, UriKind.Relative))
{
var absolute = new Uri(httpContext.Request.Url, asString);
return new BasicFile(cdfType) { FilePath = absolute.AbsolutePath };
}
return null;
}
return new JavascriptFile(asString);
}).Where(x => x != null);
var urls = ClientDependencySettings.Instance.DefaultCompositeFileProcessingProvider.ProcessCompositeList(
depenencies,
cdfType,
httpContext);
var result = new JArray();
foreach (var u in urls)
{
result.Add(u);
}
return result;
}
示例13: ParseFields
public static Field[] ParseFields(JArray a)
{
return a.Select(f =>
{
var fieldsArray = f.Value<JArray>("fields");
if (fieldsArray == null)
{
return new Field(f.Value<string>("name"), f.Value<string>("type"), f.Value<string>("mode"));
}
else
{
return new Field(f.Value<string>("name"), f.Value<string>("type"), f.Value<string>("mode"), ParseFields(fieldsArray));
}
}).ToArray();
}
示例14: SetChemicalsData
public void SetChemicalsData(JArray chemicalsData)
{
Chemicals = chemicalsData.Select(chemical => new JObject { { "ChemicalName", (string)chemical["ChemicalName"] }, { "ChemicalId", (string)chemical["ChemicalID"] } });
}
示例15: CanFollowGeneratedNavigationLinks
public void CanFollowGeneratedNavigationLinks(string acceptHeader)
{
//Arrange
OneToOneParent[] entities = MetadataTestHelpers.CreateInstances<OneToOneParent[]>();
OneToOneChild[] childEntities = entities.Select(x => x.Child).ToArray();
JArray returnedChildEntities = new JArray();
JArray returnedParentEntities;
int[] returnedChildrenIdentities;
string requestUrl = BaseAddress.ToLowerInvariant() + "/Relationships/OneToOneParent";
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
request.SetAcceptHeader(acceptHeader);
//Act
HttpResponseMessage response = Client.SendAsync(request).Result;
JObject result = response.Content.ReadAsJObject();
returnedParentEntities = (JArray)result["value"];
for (int i = 0; i < returnedParentEntities.Count; i++)
{
string childUrl = (string)returnedParentEntities[i]["[email protected]"];
HttpRequestMessage childRequest = new HttpRequestMessage(HttpMethod.Get, childUrl);
HttpResponseMessage childResponse = Client.SendAsync(childRequest).Result;
JObject childEntry = childResponse.Content.ReadAsJObject();
returnedChildEntities.Add(childEntry);
}
returnedChildrenIdentities = returnedChildEntities.Select(x => (int)x["Id"]).ToArray();
//Assert
foreach (var returnedChildEntityId in returnedChildrenIdentities)
{
Assert.True(childEntities.Any(x => x.Id == returnedChildEntityId));
}
}