本文整理汇总了C#中IContext.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.GetValue方法的具体用法?C# IContext.GetValue怎么用?C# IContext.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.GetValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayFunction
public ArrayFunction(IContext context)
: base(null, null, context)
{
var prototype = new DynamicObject();
if (context != null)
{
var obj = context.GetValue("Object");
if (obj != null && obj is DynamicObject)
{
var superproto = ((DynamicObject)obj).GetValue("prototype");
if (superproto != null && superproto is DynamicObject)
prototype.SetValue("prototype", superproto);
}
}
this.SetValue("isArray", isArrayFunction);
this.SetValue("prototype", prototype);
prototype.SetValue("push", pushFunction);
prototype.SetValue("pop", popFunction);
prototype.SetValue("unshift", unshiftFunction);
prototype.SetValue("shift", shiftFunction);
prototype.SetValue("join", joinFunction);
prototype.SetValue("slice", sliceFunction);
}
示例2: Evaluate
public object Evaluate(IContext context)
{
object value = context.GetValue(this.name);
Type type = null;
if (!(value is IFunction))
type = TypeUtilities.GetType(context, this.name);
object[] parameters = null;
if (this.arguments != null && this.arguments.Count > 0)
{
List<object> values = new List<object>();
foreach (IExpression argument in this.arguments)
values.Add(argument.Evaluate(context));
parameters = values.ToArray();
}
if (value is IFunction)
return ((IFunction)value).NewInstance(parameters);
return Activator.CreateInstance(type, parameters);
}
示例3: GetType
public static Type GetType(IContext context, string name)
{
object obj = context.GetValue(name);
if (obj != null && obj is Type)
return (Type)obj;
return GetType(name);
}
示例4: Evaluate
public object Evaluate(IContext context)
{
object value = context.GetValue(this.name);
if (value != null)
return value;
if (context.HasValue(this.name))
return value;
throw new NameError(string.Format("name '{0}' is not defined", this.name));
}
示例5: ResolveToDictionary
private static IDictionary ResolveToDictionary(VariableExpression expression, IContext context)
{
string name = expression.Name;
object obj = context.GetValue(name);
if (obj == null || obj == Undefined.Instance)
{
obj = new Hashtable();
// TODO Review if Local or not
context.SetValue(name, obj);
}
return (IDictionary)obj;
}
示例6: Evaluate
public object Evaluate(IContext context)
{
return context.GetValue(this.name);
}
示例7: ResolveToObject
private static object ResolveToObject(VariableExpression expression, IContext context)
{
string name = expression.Name;
object obj = context.GetValue(name);
if (obj == null || obj == Undefined.Instance)
{
obj = new DynamicObject();
// TODO Review if Local or not
context.SetValue(name, obj);
}
return obj;
}