本文整理汇总了C#中Parser.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.Select方法的具体用法?C# Parser.Select怎么用?C# Parser.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScimExpressionParser
static ScimExpressionParser()
{
CaseInsensitiveString = from content in QuotedString
select ScimExpression.String(content);
IdentifierName = Parse.Identifier(Parse.Letter, Parse.LetterOrDigit);
//compValue = false / null / true / number / string
//; rules from JSON(RFC 7159)
Literal = Parse.String("true").Return(ScimExpression.Constant(true))
.XOr(Parse.String("false").Return(ScimExpression.Constant(false)))
.XOr(Parse.String("null").Return(ScimExpression.Constant(null)));
//ATTRNAME = ALPHA * (nameChar)
//nameChar = "-" / "_" / DIGIT / ALPHA
// TODO : check - and _
AttrName = IdentifierName.Select(ScimExpression.Attribute);
//valuePath = attrPath "[" valFilter "]"
// ; FILTER uses sub - attributes of a parent attrPath
ValuePath = from open in Parse.Char('[')
from expr in Parse.Ref(() => Filter)
from close in Parse.Char(']')
select new Func<ScimExpression, ScimExpression>(r => ScimExpression.Binary("Where", r, expr));
//subAttr = "." ATTRNAME
//; a sub-attribute of a complex attribute
SubAttr = Parse.Char('.')
.Then(_ => IdentifierName)
.Then(n => Parse.Return(new Func<ScimExpression, ScimExpression>(r => ScimExpression.SubAttribute(n, r))));
//attrPath = [URI ":"] ATTRNAME * 1subAttr
// ; SCIM attribute name
// ; URI is SCIM "schema" URI
AttrPath = AttrName
.SelectMany(root => SubAttr.XOr(ValuePath).XMany(), (name, path) => path.Aggregate(name, (o, f) => f(o)));
Operand = (ExpressionInParentheses
.XOr(Literal.Or(AttrPath.Token()))
.XOr(CaseInsensitiveString)).Token();
// compareOp = "eq" / "ne" / "co" /
// "sw" / "ew" /
// "gt" / "lt" /
// "ge" / "le"
Comparison = Parse.XChainOperator(Le.Or(Lt).XOr(Ge.Or(Gt)).XOr(Eq.Or(Ne)).XOr(Sw.Or(Ew)).XOr(Co).XOr(Pr), Operand, ScimExpression.Binary);
// attrPath SP "pr"
Presence = Operand.SelectMany(operand => Pr, (operand, pr) => ScimExpression.Unary(pr, operand));
// attrExp = (attrPath SP "pr") /
// (attrPath SP compareOp SP compValue)
AttributeExpression = Presence.Or(Comparison);
// logExp = FILTER SP ("and" / "or") SP FILTER
LogicalExpression = Parse.XChainOperator(Or.Or(And), AttributeExpression, ScimExpression.Binary);
Filter = LogicalExpression;
}
示例2: ParsersUpdate
public Guid[] ParsersUpdate(Parser[] parsers, bool needSave = true)
{
Guid[] result = new Guid[] { };
if (parsers != null)
using (var dc = exelconverterEntities2.New())
{
var ids = parsers.Select(p => p.Id).ToArray();
var parsersInDb = dc.parsers.Where(p => ids.Contains(p.id));
result = parsersInDb.Select(p => p.id).Distinct().ToArray();
if (needSave && parsersInDb.Count() > 0)
{
foreach (var p in parsersInDb)
{
var pToUpdate = parsers.FirstOrDefault(p2 => p2.Id == p.id);
if (pToUpdate != null)
{
p.url = pToUpdate.Url;
p.xml = pToUpdate.SerializeXML();
}
}
dc.SaveChanges();
}
}
return result;
}
示例3: ParsersRemove
public Guid[] ParsersRemove(Parser[] parsers)
{
if (parsers != null)
return ParsersRemove(parsers.Select(p => p.Id).ToArray());
else
return new Guid[] { };
}