本文整理汇总了C#中IParseContext类的典型用法代码示例。如果您正苦于以下问题:C# IParseContext类的具体用法?C# IParseContext怎么用?C# IParseContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParseContext类属于命名空间,在下文中一共展示了IParseContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (context.CurrentStateLength == 1) {
context.Nodes.Push (new XProcessingInstruction (context.LocationMinus ("<?".Length)));
}
if (c == '?') {
if (context.StateTag == NOMATCH) {
context.StateTag = QUESTION;
return null;
}
} else if (c == '>' && context.StateTag == QUESTION) {
// if the '?' is followed by a '>', the state has ended
// so attach a node to the DOM and end the state
XProcessingInstruction xpi = (XProcessingInstruction) context.Nodes.Pop ();
if (context.BuildTree) {
xpi.End (context.Location);
((XContainer) context.Nodes.Peek ()).AddChildNode (xpi);
}
return Parent;
} else {
context.StateTag = NOMATCH;
}
return null;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:XmlProcessingInstructionState.cs
示例2: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (context.CurrentStateLength == 0)
context.StateTag = 0;
if (c == '<') {
if (context.StateTag == 0) {
context.StateTag++;
return null;
}
}
if (context.StateTag > 0) {
if (CLOSE[context.StateTag] == c) {
context.StateTag++;
if (context.StateTag == CLOSE.Length) {
var el = (XElement) context.Nodes.Pop ();
var closing = new XClosingTag (new XName ("script"), context.LocationMinus (CLOSE.Length));
closing.End (context.Location);
el.Close (closing);
return Parent;
}
} else {
context.StateTag = 0;
}
}
return null;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:27,代码来源:HtmlScriptBodyState.cs
示例3: ParseMethodCall
protected override IParseContext ParseMethodCall(ExpressionParser parser, IParseContext parent, MethodCallExpression methodCall, SqlQuery sqlQuery)
{
var sequence = parser.ParseSequence(parent, methodCall.Arguments[0], sqlQuery);
var defaultValue = methodCall.Arguments.Count == 1 ? null : methodCall.Arguments[1].Unwrap();
return new DefaultIfEmptyContext(sequence, defaultValue);
}
开发者ID:Firebie,项目名称:ItemsUsage,代码行数:7,代码来源:DefaultIfEmptyParser.cs
示例4: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (context.CurrentStateLength == 1) {
context.Nodes.Push (new XCData (context.LocationMinus ("<![CDATA[".Length + 1)));
}
if (c == ']') {
//make sure we know when there are two ']' chars together
if (context.StateTag == NOMATCH)
context.StateTag = SINGLE_BRACKET;
else
context.StateTag = DOUBLE_BRACKET;
} else if (c == '>' && context.StateTag == DOUBLE_BRACKET) {
// if the ']]' is followed by a '>', the state has ended
// so attach a node to the DOM and end the state
XCData cdata = (XCData) context.Nodes.Pop ();
if (context.BuildTree) {
cdata.End (context.Location);
((XContainer) context.Nodes.Peek ()).AddChildNode (cdata);
}
return Parent;
} else {
// not any part of a ']]>', so make sure matching is reset
context.StateTag = NOMATCH;
}
return null;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:XmlCDataState.cs
示例5: AddExpressionNode
internal static void AddExpressionNode (char c, IParseContext context)
{
Debug.Assert (c != '@' && c!= '-', "AspNetExpressionState should not be passed a directive or comment");
switch (c) {
//DATABINDING EXPRESSION <%#
case '#':
context.Nodes.Push (new AspNetDataBindingExpression (context.LocationMinus (3)));
break;
//RESOURCE EXPRESSION <%$
case '$':
context.Nodes.Push (new AspNetResourceExpression (context.LocationMinus (3)));
break;
//RENDER EXPRESSION <%=
case '=':
context.Nodes.Push (new AspNetRenderExpression (context.LocationMinus (3)));
break;
//HTML ENCODED EXPRESSION <%:
case ':':
context.Nodes.Push (new AspNetHtmlEncodedExpression (context.LocationMinus (3)));
break;
// RENDER BLOCK
default:
context.Nodes.Push (new AspNetRenderBlock (context.LocationMinus (3)));
break;
}
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:27,代码来源:AspNetExpressionState.cs
示例6: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
System.Diagnostics.Debug.Assert (((XAttribute) context.Nodes.Peek ()).Value == null);
if (c == '<') {
//the parent state should report the error
rollback = string.Empty;
return Parent;
}
if (context.CurrentStateLength == 1) {
if (c == '\'' || c == '"') {
context.StateTag = c;
return null;
}
context.StateTag = '\0';
} else if (context.StateTag == '\0') {
return BuildUnquotedValue (c, context, ref rollback);
}
if (c == context.StateTag) {
//ending the value
var att = (XAttribute) context.Nodes.Peek ();
att.Value = context.KeywordBuilder.ToString ();
return Parent;
}
context.KeywordBuilder.Append (c);
return null;
}
开发者ID:jrhtcg,项目名称:monodevelop,代码行数:30,代码来源:XmlAttributeValueState.cs
示例7: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (context.CurrentStateLength == 1) {
AddExpressionNode (c, context);
}
else if (c == '%') {
context.StateTag = PERCENT;
}
else if (c == '>') {
if (context.StateTag == PERCENT) {
XNode expr = (XNode) context.Nodes.Pop ();
expr.End (context.Location);
if (context.BuildTree) {
XObject ob = context.Nodes.Peek ();
var xc = ob as XContainer;
if (xc != null) {
xc.AddChildNode (expr);
}
//FIXME: add to other kinds of node, e.g. if used within a tag
}
return Parent;
} else {
context.StateTag = NONE;
}
}
return null;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:28,代码来源:AspNetExpressionState.cs
示例8: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
System.Diagnostics.Debug.Assert (((XAttribute) context.Nodes.Peek ()).Value == null);
if (c == '<') {
//the parent state should report the error
rollback = string.Empty;
return Parent;
} else if (c == '>' && context.KeywordBuilder.Length > 0) {
string fullName = ((XAttribute) context.Nodes.Peek ()).Name.FullName;
context.LogError ("The value of attribute '" + fullName + "' ended unexpectedly.");
rollback = string.Empty;
return Parent;
} else if (char.IsLetterOrDigit (c) || c == '_' || c == '.') {
context.KeywordBuilder.Append (c);
return null;
} else if (char.IsWhiteSpace (c) || c == '>' || c == '\\') {
//ending the value
XAttribute att = (XAttribute) context.Nodes.Peek ();
att.Value = context.KeywordBuilder.ToString ();
} else {
//MalformedTagState handles error reporting
//context.LogWarning ("Unexpected character '" + c + "' getting attribute value");
return MalformedTagState;
}
rollback = string.Empty;
return Parent;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:29,代码来源:XmlAttributeValueState.cs
示例9: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
//NOTE: This is (mostly) duplicated in HtmlTagState
//handle inline tags implicitly closed by block-level elements
if (context.CurrentStateLength == 1 && context.PreviousState is XmlNameState)
{
XClosingTag ct = (XClosingTag) context.Nodes.Peek ();
if (!ct.Name.HasPrefix && ct.Name.IsValid) {
//Note: the node stack will always be at least 1 deep due to the XDocument
var parent = context.Nodes.Peek (1) as XElement;
//if it's not a matching closing tag
if (parent != null && !string.Equals (ct.Name.Name, parent.Name.Name, StringComparison.OrdinalIgnoreCase)) {
//attempt to implicitly close the parents
while (parent != null && parent.ValidAndNoPrefix () && parent.IsImplicitlyClosedBy (ct)) {
context.Nodes.Pop ();
context.Nodes.Pop ();
if (warnAutoClose) {
context.LogWarning (string.Format ("Tag '{0}' implicitly closed by closing tag '{1}'.",
parent.Name.Name, ct.Name.Name), parent.Region);
}
//parent.Region.End = element.Region.Start;
//parent.Region.EndColumn = Math.Max (parent.Region.EndColumn - 1, 1);
parent.Close (parent);
context.Nodes.Push (ct);
parent = context.Nodes.Peek (1) as XElement;
}
}
}
}
return base.PushChar (c, context, ref rollback);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:33,代码来源:HtmlClosingTagState.cs
示例10: ParseSkip
static void ParseSkip(ExpressionParser parser, IParseContext sequence, ISqlExpression prevSkipValue, ISqlExpression expr)
{
var sql = sequence.SqlQuery;
parser.SqlProvider.SqlQuery = sql;
sql.Select.Skip(expr);
parser.SqlProvider.SqlQuery = sql;
if (sql.Select.TakeValue != null)
{
if (parser.SqlProvider.IsSkipSupported || !parser.SqlProvider.IsTakeSupported)
sql.Select.Take(parser.Convert(
sequence,
new SqlBinaryExpression(typeof(int), sql.Select.TakeValue, "-", sql.Select.SkipValue, Precedence.Additive)));
if (prevSkipValue != null)
sql.Select.Skip(parser.Convert(
sequence,
new SqlBinaryExpression(typeof(int), prevSkipValue, "+", sql.Select.SkipValue, Precedence.Additive)));
}
if (!parser.SqlProvider.TakeAcceptsParameter)
{
var p = sql.Select.SkipValue as SqlParameter;
if (p != null)
p.IsQueryParameter = false;
}
}
开发者ID:Firebie,项目名称:ItemsUsage,代码行数:31,代码来源:TakeSkipParser.cs
示例11: CanParse
public override bool CanParse(IParseContext context)
{
var fileExtensions = " " + context.Configuration.GetString(Constants.Configuration.BuildProjectContentFiles) + " ";
var extension = " " + Path.GetExtension(context.Snapshot.SourceFile.AbsoluteFileName) + " ";
return fileExtensions.IndexOf(extension, StringComparison.OrdinalIgnoreCase) >= 0;
}
开发者ID:Hafeok,项目名称:Sitecore.Pathfinder,代码行数:7,代码来源:ContentFileParser.cs
示例12: CanParse
public override bool CanParse(IParseContext context)
{
var extension = Path.GetExtension(context.Snapshot.SourceFile.AbsoluteFileName).TrimStart('.').ToLowerInvariant();
var templateIdOrPath = context.Configuration.Get(Constants.Configuration.BuildProjectMediaTemplate + ":" + extension);
return templateIdOrPath != null;
}
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:7,代码来源:MediaFileParser.cs
示例13: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (c == '<') {
}
return base.PushChar (c, context, ref rollback);
}
开发者ID:jrhtcg,项目名称:monodevelop,代码行数:7,代码来源:AspNetDirectiveState.cs
示例14: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (c == '@' && context.StateTag == FREE) {
context.StateTag = TRANSITION;
return null;
} else if (context.StateTag == TRANSITION) {
rollback = String.Empty;
switch (c) {
case '{': // Code block @{
return CodeBlockState;
case '*': // Comment @*
return ServerCommentState;
case '(': // Explicit expression @(
return ExpressionState;
default:
// If char preceding @ was a letter or a digit, don't switch to expression, e.g. [email protected]
if (context.CurrentStateLength <= 2 || (!Char.IsLetterOrDigit (previousChar)
&& (Char.IsLetter (c) || c == '_'))) // Statement, directive or implicit expression
return SpeculativeState;
else
context.StateTag = FREE;
break;
}
}
previousChar = c;
return base.PushChar (c, context, ref rollback);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:28,代码来源:RazorFreeState.cs
示例15: ValidateSchema
public override bool ValidateSchema(IParseContext context)
{
if (string.IsNullOrEmpty(SchemaFileName) || string.IsNullOrEmpty(SchemaNamespace))
{
return true;
}
var doc = RootElement?.Document;
if (doc == null)
{
return true;
}
XmlSchemaSet schema;
if (!Schemas.TryGetValue(SchemaNamespace, out schema))
{
schema = GetSchema(context, SchemaFileName, SchemaNamespace);
Schemas[SchemaNamespace] = schema;
}
if (schema == null)
{
return true;
}
var isValid = true;
ValidationEventHandler validateHandler = delegate(object sender, ValidationEventArgs args)
{
var length = 0;
var element = sender as XElement;
if (element != null)
{
length = element.Name.LocalName.Length;
}
switch (args.Severity)
{
case XmlSeverityType.Error:
context.Trace.TraceError(Msg.P1001, args.Message, SourceFile.AbsoluteFileName, new TextSpan(args.Exception.LineNumber, args.Exception.LinePosition, length));
isValid = false;
break;
case XmlSeverityType.Warning:
context.Trace.TraceWarning(Msg.P1002, args.Message, SourceFile.AbsoluteFileName, new TextSpan(args.Exception.LineNumber, args.Exception.LinePosition, length));
break;
}
};
try
{
doc.Validate(schema, validateHandler);
}
catch (Exception ex)
{
context.Trace.TraceError(Msg.P1003, Texts.The_file_does_not_contain_valid_XML, context.Snapshot.SourceFile.AbsoluteFileName, TextSpan.Empty, ex.Message);
}
return isValid;
}
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:59,代码来源:XmlTextSnapshot.cs
示例16: Parse
public override void Parse(IParseContext context)
{
var mediaFile = context.Factory.MediaFile(context.Project, context.Snapshot, context.DatabaseName, context.ItemName, context.ItemPath, context.FilePath);
mediaFile.UploadMedia = context.UploadMedia;
context.Project.AddOrMerge(mediaFile);
context.Project.Ducats += 100;
}
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:8,代码来源:MediaFileParser.cs
示例17: CanParse
public override bool CanParse(IParseContext context)
{
// todo: potential incorrect as an extension might match part of another extension
var fileExtensions = context.Configuration.GetString(Constants.Configuration.MappingContentFiles);
var extension = Path.GetExtension(context.Snapshot.SourceFile.AbsoluteFileName);
return fileExtensions.IndexOf(extension, StringComparison.OrdinalIgnoreCase) >= 0;
}
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:8,代码来源:ContentFileParser.cs
示例18: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
if (context.CurrentStateLength == 1) {
Debug.Assert (c != '@' && c!= '-',
"AspNetExpressionState should not be passed a directive or comment");
switch (c) {
//DATABINDING EXPRESSION <%#
case '#':
context.Nodes.Push (new AspNetDataBindingExpression (context.LocationMinus (3)));
break;
//RESOURCE EXPRESSION <%$
case '$':
context.Nodes.Push (new AspNetResourceExpression (context.LocationMinus (3)));
break;
//RENDER EXPRESSION <%=
case '=':
context.Nodes.Push (new AspNetRenderExpression (context.LocationMinus (3)));
break;
//HTML ENCODED EXPRESSION <%:
case ':':
context.Nodes.Push (new AspNetHtmlEncodedExpression (context.LocationMinus (3)));
break;
// RENDER BLOCK
default:
context.Nodes.Push (new AspNetRenderBlock (context.LocationMinus (2)));
break;
}
return null;
}
else if (c == '%') {
if (context.StateTag != PERCENT)
context.StateTag = PERCENT;
}
else if (c == '>') {
if (context.StateTag == PERCENT) {
XNode expr = (XNode) context.Nodes.Pop ();
expr.End (context.Location);
if (context.BuildTree) {
XObject ob = context.Nodes.Peek ();
if (ob is XContainer) {
((XContainer)ob).AddChildNode (expr);
}
//FIXME: add to other kinds of node, e.g. if used within a tag
}
return Parent;
} else {
context.StateTag = NONE;
}
}
return null;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:58,代码来源:AspNetExpressionState.cs
示例19: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
INamedXObject namedObject = context.Nodes.Peek () as INamedXObject;
if (namedObject == null || namedObject.Name.Prefix != null)
throw new InvalidOperationException ("Invalid state");
Debug.Assert (context.CurrentStateLength > 1 || char.IsLetter (c) || c == '_',
"First character pushed to a XmlTagNameState must be a letter.");
Debug.Assert (context.CurrentStateLength > 1 || context.KeywordBuilder.Length == 0,
"Keyword builder must be empty when state begins.");
if (c == ':') {
if (namedObject.Name.Name != null || context.KeywordBuilder.Length == 0) {
context.LogError ("Unexpected ':' in name.");
return Parent;
}
namedObject.Name = new XName (context.KeywordBuilder.ToString ());
context.KeywordBuilder.Length = 0;
return null;
}
if (XmlChar.IsWhitespace (c) || c == '<' || c == '>' || c == '/' || c == '=') {
rollback = string.Empty;
if (context.KeywordBuilder.Length == 0) {
context.LogError ("Zero-length name.");
} else if (namedObject.Name.Name != null) {
//add prefix (and move current "name" to prefix)
namedObject.Name = new XName (namedObject.Name.Name, context.KeywordBuilder.ToString ());
} else {
namedObject.Name = new XName (context.KeywordBuilder.ToString ());
}
//note: parent's MalformedTagState logs an error, so skip this
//if (c == '<')
//context.LogError ("Unexpected '<' in name.");
return Parent;
}
if (c == ':') {
if (namedObject.Name.Name != null || context.KeywordBuilder.Length == 0) {
context.LogError ("Unexpected ':' in name.");
return Parent;
}
namedObject.Name = new XName (context.KeywordBuilder.ToString ());
context.KeywordBuilder.Length = 0;
return null;
}
if (XmlChar.IsNameChar (c)) {
context.KeywordBuilder.Append (c);
return null;
}
rollback = string.Empty;
context.LogError ("Unexpected character '" + c +"'");
return Parent;
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:57,代码来源:XmlNameState.cs
示例20: PushChar
public override State PushChar (char c, IParseContext context, ref string rollback)
{
// allow < in values
if (context.StateTag != '\0' && context.CurrentStateLength > 1 && c == '<') {
context.KeywordBuilder.Append (c);
return null;
}
return base.PushChar (c, context, ref rollback);
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:9,代码来源:AspNetDirectiveState.cs
注:本文中的IParseContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论