本文整理汇总了C#中IParserContext类的典型用法代码示例。如果您正苦于以下问题:C# IParserContext类的具体用法?C# IParserContext怎么用?C# IParserContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParserContext类属于命名空间,在下文中一共展示了IParserContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ValueExpression valueRight = Right.Evaluate(context);
if (Left is VariableExpression)
{
if ((context.AssignmentPermissions & AssignmentPermissions.Variable) == AssignmentPermissions.None)
throw new IllegalAssignmentException("Assignment to variable not allowed", this);
VariableExpression varExpr = (VariableExpression)Left;
bool exists = context.Exists(varExpr.VarName);
if (exists && (context.AssignmentPermissions & AssignmentPermissions.ExistingVariable) == AssignmentPermissions.None)
throw new IllegalAssignmentException("Assignment to existing variable not allowed", this);
if (!exists && (context.AssignmentPermissions & AssignmentPermissions.NewVariable) == AssignmentPermissions.None)
throw new IllegalAssignmentException("Assignment to new variable not allowed", this);
context.Set(varExpr.VarName, valueRight.Value, valueRight.Type);
return valueRight;
}
if (Left is FieldExpression)
{
if ((context.AssignmentPermissions & AssignmentPermissions.Property) == AssignmentPermissions.None)
throw new IllegalAssignmentException("Assignment to property not allowed", this);
return ((FieldExpression)Left).Assign(context, valueRight.Value);
}
throw new IllegalAssignmentException(this);
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:34,代码来源:AssignmentExpression.cs
示例2: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ValueExpression targetValue = _target.Evaluate(context);
Type targetType = targetValue.Type;
object targetObject = targetValue.Value;
ValueExpression[] parameters = EvaluateExpressionArray(_parameters, context);
Type[] parameterTypes = parameters.ConvertAll(expr => expr.Type);
object[] parameterValues = parameters.ConvertAll(expr => expr.Value);
if (targetType.IsArray)
{
if (targetType.GetArrayRank() != parameters.Length)
throw new Exception("Array has a different rank. Number of arguments is incorrect");
Type returnType = targetType.GetElementType();
bool useLong = false;
foreach (Type t in parameterTypes)
{
if (t == typeof(long) || t == typeof(long?))
useLong = true;
else if (t != typeof(int) & t != typeof(int?) && t != typeof(short) && t != typeof(short?) && t != typeof(ushort) && t != typeof(ushort?))
throw new BadArgumentException(t.GetType().Name + " is not a valid type for array indexers", this);
}
#if !WINDOWS_PHONE
if (useLong)
{
long[] indexes = new long[parameters.Length];
for (int i=0;i<parameters.Length;i++)
indexes[i] = Convert.ToInt64(parameterValues[i]);
return Exp.Value(TokenPosition, ((Array)targetObject).GetValue(indexes), returnType);
}
else
#endif
{
int[] indexes = new int[parameters.Length];
for (int i = 0; i < parameters.Length; i++)
indexes[i] = Convert.ToInt32(parameterValues[i]);
return Exp.Value(TokenPosition, ((Array)targetObject).GetValue(indexes), returnType);
}
}
else
{
DefaultMemberAttribute[] att = (DefaultMemberAttribute[]) targetType.GetCustomAttributes(typeof(DefaultMemberAttribute), true);
MethodInfo methodInfo = targetType.GetMethod("get_" + att[0].MemberName, parameterTypes);
object value = methodInfo.Invoke(targetObject, parameterValues);
return new ValueExpression(TokenPosition, value, methodInfo.ReturnType);
}
}
开发者ID:Niels-R,项目名称:core,代码行数:60,代码来源:IndexExpression.cs
示例3: FindResourceInTheme
void IEvaluableMarkupExtension.Initialize(IParserContext context)
{
_resource = ResourceDictionary.FindResourceInParserContext(_resourceKey, context) ?? FindResourceInTheme(_resourceKey, context);
if (_resource == null)
ServiceRegistration.Get<ILogger>().Error("StaticResourceMarkupExtension: Resource '{0}' not found", _resourceKey);
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:StaticResourceExtension.cs
示例4: SQLQueryParser
public SQLQueryParser(
string sqlQuery,
IParserContext context)
{
this.sqlQuery = sqlQuery;
this.context = context;
}
开发者ID:zibler,项目名称:zibler,代码行数:7,代码来源:SQLQueryParser.cs
示例5: Parse
public override LuaStatement Parse(INextAwareEnumerator<Token> reader, IParserContext context)
{
var token = reader.GetAndMoveNext();
if (string.IsNullOrWhiteSpace(token.Value) || token.Value == LuaToken.Semicolon)
return new EmptyStatement();
throw new UnexpectedTokenException(token);
}
开发者ID:DarkWanderer,项目名称:DW.Lua,代码行数:7,代码来源:EmptyStatementParser.cs
示例6: Convert
/// <summary>
/// Converts the parsed ab1 raw data file into a sequence, with the associated ab1 metadata setup. I use
/// this method because only a subset of the data is needed so there is no point in persisting a large amount
/// of unused metadata.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public static ISequence Convert(IParserContext context)
{
ISequence sequence = GetSequence(context);
Ab1Metadata metadata = GetAb1Metadata(context);
Ab1Metadata.SetAb1Data(sequence, metadata);
return sequence;
}
开发者ID:cpatmoore,项目名称:bio,代码行数:14,代码来源:Ab1ContextToSequenceConverter.cs
示例7: Parse
public override LuaStatement Parse(INextAwareEnumerator<Token> reader, IParserContext context)
{
reader.VerifyExpectedTokenAndMoveNext(Keywords.Function);
if (reader.Next.Value == LuaToken.Colon)
{
reader.MoveNext();
reader.MoveNext();
}
var functionName = reader.GetAndMoveNext();
reader.VerifyExpectedToken(LuaToken.LeftBracket);
var argumentNames = new List<string>();
reader.MoveNext();
while (reader.Current.Value != LuaToken.RightBracket)
{
argumentNames.Add(reader.Current.Value);
reader.MoveNext();
reader.VerifyExpectedToken(LuaToken.Comma, LuaToken.RightBracket);
if (reader.Current.Value == LuaToken.RightBracket)
break;
reader.MoveNext();
}
reader.VerifyExpectedTokenAndMoveNext(LuaToken.RightBracket);
var statementsParser = new StatementBlockParser(Keywords.End);
var body = statementsParser.ParseBlock(reader, context);
return new FunctionDeclarationStatement(functionName.Value,argumentNames,body);
}
开发者ID:DarkWanderer,项目名称:DW.Lua,代码行数:28,代码来源:FunctionDeclarationStatementParser.cs
示例8: LanguageItemWindow
public LanguageItemWindow (ILanguageItem item, IParserContext ctx, Ambience ambience,
string errorInformations) : base (WindowType.Popup)
{
Name = "gtk-tooltips";
// Approximate value for usual case
StringBuilder s = new StringBuilder(150);
if (item != null) {
if (item is IParameter) {
s.Append ("<small><i>");
s.Append (paramStr);
s.Append ("</i></small>\n");
s.Append (ambience.Convert ((IParameter)item, WindowConversionFlags));
} else if (item is LocalVariable) {
s.Append ("<small><i>");
s.Append (localStr);
s.Append ("</i></small>\n");
s.Append (ambience.Convert ((LocalVariable)item, WindowConversionFlags));
} else if (item is IField) {
s.Append ("<small><i>");
s.Append (fieldStr);
s.Append ("</i></small>\n");
s.Append (ambience.Convert ((IField)item, WindowConversionFlags));
} else if (item is IProperty) {
s.Append ("<small><i>");
s.Append (propertyStr);
s.Append ("</i></small>\n");
s.Append (ambience.Convert ((IProperty)item, WindowConversionFlags));
} else if (item is Namespace) {
s.Append ("namespace <b>");
s.Append (item.Name);
s.Append ("</b>");
} else
s.Append (ambience.Convert (item, WindowConversionFlags));
string doc = GetDocumentation (item.Documentation).Trim ('\n');
if (!string.IsNullOrEmpty (doc)) {
s.Append ("\n<small>");
s.Append (doc);
s.Append ("</small>");
}
}
if (!string.IsNullOrEmpty (errorInformations)) {
if (s.Length != 0)
s.Append ("\n\n");
s.Append ("<small>");
s.Append (errorInformations);
s.Append ("</small>");
}
Label lab = new Label ();
lab.Markup = s.ToString ();
lab.Xalign = 0;
lab.Xpad = 3;
lab.Ypad = 3;
Add (lab);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:59,代码来源:LanguageItemWindow.cs
示例9: LoadPeakLocations
private static void LoadPeakLocations(Ab1Metadata metadata, IParserContext context)
{
metadata.PeakLocations =
((ShortDataItem)context
.DataItems
.First(item =>
item.Entry.TagName == Constants.PeakLocationTagName)).Value;
}
开发者ID:cpatmoore,项目名称:bio,代码行数:8,代码来源:Ab1ContextToSequenceConverter.cs
示例10: FindResourceInTheme
protected object FindResourceInTheme(string resourceKey, IParserContext context)
{
object result = SkinContext.SkinResources.FindStyleResource(resourceKey);
if (result == null)
return null;
// See comment about the copying in method ResourceDictionary.FindResourceInParserContext()
return MpfCopyManager.DeepCopyCutLVPs(result);
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:8,代码来源:StaticResourceBase.cs
示例11: GetAb1Metadata
private static Ab1Metadata GetAb1Metadata(IParserContext context)
{
var metadata = new Ab1Metadata();
LoadPeakLocations(metadata, context);
LoadSequenceConfidence(metadata, context);
LoadColorWheelData(metadata, context);
return metadata;
}
开发者ID:cpatmoore,项目名称:bio,代码行数:8,代码来源:Ab1ContextToSequenceConverter.cs
示例12: Parse
public override LuaExpression Parse(INextAwareEnumerator<Token> reader, IParserContext context)
{
var leftExpression = SyntaxParser.ReadExpression(reader,context);
var operation = reader.Current.Value;
reader.VerifyExpectedTokenAndMoveNext(LuaToken.BinaryOperations);
var rightExpression = SyntaxParser.ReadExpression(reader, context);
return new BinaryExpression(leftExpression,rightExpression, operation);
}
开发者ID:DarkWanderer,项目名称:DW.Lua,代码行数:8,代码来源:BinaryOperationExpressionParser.cs
示例13: Parse
public override LuaStatement Parse(INextAwareEnumerator<Token> reader, IParserContext context)
{
reader.VerifyExpectedTokenAndMoveNext(Keywords.While);
var conditionExpression = SyntaxParser.ReadExpression(reader, context);
reader.VerifyExpectedTokenAndMoveNext(Keywords.Do);
var blockParser = new StatementBlockParser(Keywords.End);
var bodyBlock = blockParser.ParseBlock(reader, context);
return new WhileStatement(conditionExpression, bodyBlock);
}
开发者ID:DarkWanderer,项目名称:DW.Lua,代码行数:9,代码来源:WhileStatementParser.cs
示例14: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ValueExpression result = _value.Evaluate(context);
if (result.Value == null)
return _valueIfNull.Evaluate(context);
return result;
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:9,代码来源:CoalesceExpression.cs
示例15: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ValueExpression result = Condition.Evaluate(context);
if (context.ToBoolean(result.Value))
return Value.Evaluate(context);
else
return new ValueExpression(TokenPosition, null, typeof(object));
}
开发者ID:TheMouster,项目名称:core,代码行数:9,代码来源:ValueOrNullExpression.cs
示例16: XamlBindingException
void IEvaluableMarkupExtension.Initialize(IParserContext context)
{
if (Id == null)
throw new XamlBindingException("GetModelMarkupExtension: Property Id has to be given");
IModelLoader loader = context.GetContextVariable(typeof(IModelLoader)) as IModelLoader;
if (loader == null)
throw new XamlBindingException("GetModelMarkupExtension: No model loader instance present in parser context");
_model = loader.GetOrLoadModel(new Guid(Id));
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:9,代码来源:GetModelMarkupExtension.cs
示例17: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ClassName className = TypeExpression.Evaluate(context).Value as ClassName;
if (className == null)
throw new ExpressionEvaluationException("type cast requires a type. " + TypeExpression + " is not a type", this);
return Exp.Value(TokenPosition, Convert.ChangeType(TargetExpression.Evaluate(context).Value, className.Type, null), className.Type);
}
开发者ID:TheMouster,项目名称:core,代码行数:9,代码来源:TypeCastExpression.cs
示例18: Parse
public override LuaExpression Parse(INextAwareEnumerator<Token> reader, IParserContext context)
{
reader.VerifyExpectedToken(LuaToken.LeftBracket);
reader.MoveNext();
var expression = SyntaxParser.ReadExpression(reader, context);
reader.VerifyExpectedToken(LuaToken.RightBracket);
reader.MoveNext();
return new BracketedExpression(expression);
}
开发者ID:DarkWanderer,项目名称:DW.Lua,代码行数:9,代码来源:BracketedExpressionParser.cs
示例19: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
bool result = context.ToBoolean(_condition.Evaluate(context).Value);
if (result)
return _trueValue.Evaluate(context);
else
return _falseValue.Evaluate(context);
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:9,代码来源:ConditionalExpression.cs
示例20: Evaluate
public override ValueExpression Evaluate(IParserContext context)
{
ValueExpression value = Value.Evaluate(context);
if (context == null)
return Exp.Value(TokenPosition, !((bool)value.Value));
else
return Exp.Value(TokenPosition, !context.ToBoolean(value.Value));
}
开发者ID:TheMouster,项目名称:core,代码行数:9,代码来源:NegationExpression.cs
注:本文中的IParserContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论