本文整理汇总了C#中IDynamicMetaObjectProvider类的典型用法代码示例。如果您正苦于以下问题:C# IDynamicMetaObjectProvider类的具体用法?C# IDynamicMetaObjectProvider怎么用?C# IDynamicMetaObjectProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDynamicMetaObjectProvider类属于命名空间,在下文中一共展示了IDynamicMetaObjectProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetMember
internal static void SetMember(IDynamicMetaObjectProvider o, string name, object value)
{
CallSite<Action<CallSite, object, object>> site;
if(!setSites.TryGetValue(name, out site)) {
site = CallSite<Action<CallSite, object, object>>.Create(new DoHelpersSetMemberBinder(name));
setSites.Add(name, site);
}
site.Target(site, o, value);
}
示例2: IDOIndexSet
internal static void IDOIndexSet(IDynamicMetaObjectProvider Instance, object[] Arguments, string[] ArgumentNames)
{
SaveCopyBack back = new SaveCopyBack(null);
using (back)
{
object[] packedArgs = null;
CallInfo callInfo = null;
IDOUtils.PackArguments(1, ArgumentNames, Arguments, ref packedArgs, ref callInfo);
IDOUtils.CreateFuncCallSiteAndInvoke(new VBIndexSetBinder(callInfo), Instance, packedArgs);
}
}
示例3: TryGetMember
internal bool TryGetMember(IDynamicMetaObjectProvider dynamicProvider, string name, out object value)
{
ValidationUtils.ArgumentNotNull(dynamicProvider, "dynamicProvider");
var callSite = _callSiteGetters.Get(name);
var result = callSite.Target(callSite, dynamicProvider);
if (!ReferenceEquals(result, NoThrowExpressionVisitor.ErrorResult))
{
value = result;
return true;
}
value = null;
return false;
}
示例4: ExecuteFileInScope
// ExecuteFileInScope executes the file in the given module scope. This
// does NOT store the module scope on Globals. This function returns
// nothing.
//
public void ExecuteFileInScope(string filename,
IDynamicMetaObjectProvider moduleEO) {
var f = new StreamReader(filename);
// Simple way to convey script rundir for RuntimeHelpes.SymplImport
// to load .sympl files.
DynamicObjectHelpers.SetMember(moduleEO, "__file__",
Path.GetFullPath(filename));
try {
var moduleFun = ParseFileToLambda(filename, f);
var d = moduleFun.Compile();
d(this, moduleEO);
} finally {
f.Close();
}
}
示例5: ForwardingMetaObject
public ForwardingMetaObject(
Expression expression,
BindingRestrictions restrictions,
object forwarder,
IDynamicMetaObjectProvider forwardee,
Func<Expression, Expression> forwardeeGetter
)
: base(expression, restrictions, forwarder)
{
// We'll use forwardee's meta-object to bind dynamic operations.
metaForwardee = forwardee.GetMetaObject(
forwardeeGetter(
Expression.Convert(expression, forwarder.GetType()) // [1]
)
);
}
示例6: IDOGet
internal static object IDOGet(IDynamicMetaObjectProvider Instance, string MemberName, object[] Arguments, string[] ArgumentNames, bool[] CopyBack)
{
object obj2;
SaveCopyBack back = new SaveCopyBack(CopyBack);
using (back)
{
object[] packedArgs = null;
CallInfo callInfo = null;
IDOUtils.PackArguments(0, ArgumentNames, Arguments, ref packedArgs, ref callInfo);
try
{
return IDOUtils.CreateRefCallSiteAndInvoke(new VBGetBinder(MemberName, callInfo), Instance, packedArgs);
}
finally
{
IDOUtils.CopyBackArguments(callInfo, packedArgs, Arguments);
}
}
return obj2;
}
示例7: ProtoTypalObjectWithMethods
public ProtoTypalObjectWithMethods( IDynamicMetaObjectProvider prototype )
: base(prototype)
{
StaticMethodWithNoReturnValueOrParametersWasCalled = false;
}
示例8: TheDude
public TheDude( IDynamicMetaObjectProvider module )
: base(module)
{
}
示例9: GetDynamicProperties
private static PropertyReader[] GetDynamicProperties(IDynamicMetaObjectProvider provider)
{
var metaObject = provider.GetMetaObject(Expression.Constant(provider));
var memberNames = metaObject.GetDynamicMemberNames(); // may return property names as well as method names, etc.
var result = new List<PropertyReader>();
foreach (var name in memberNames)
{
try
{
var argumentInfo = new[] {CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)};
var binder = Binder.GetMember(CSharpBinderFlags.None, name, provider.GetType(), argumentInfo);
var site = CallSite<Func<CallSite, object, object>>.Create(binder);
var value = site.Target(site, provider); // will throw if no valid property getter
result.Add(new PropertyReader
{
Name = name,
DeclaringType = provider.GetType(),
Read = o => value
});
}
catch (RuntimeBinderException)
{
}
}
return result.ToArray();
}
示例10: Scope
/// <summary>
/// Creates a new scope which is backed by an arbitrary object for it's storage.
/// </summary>
/// <param name="storage"></param>
public Scope(IDynamicMetaObjectProvider storage)
{
_extensions = ScopeExtension.EmptyArray;
_storage = storage;
}
示例11: CreateScope
public ScriptScope CreateScope(string languageId, IDynamicMetaObjectProvider storage) {
return GetEngine(languageId).CreateScope(storage);
}
示例12: HasPropertyNaive
private static bool HasPropertyNaive(IDynamicMetaObjectProvider dynamicProvider, string name)
{
try
{
var callSite =
CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, name, typeof(Program),
new[]
{
CSharpArgumentInfo.Create(
CSharpArgumentInfoFlags.None, null)
}));
callSite.Target(callSite, dynamicProvider);
return true;
}
catch (RuntimeBinderException)
{
return false;
}
}
示例13: ExecuteExpr
// Execute a single expression parsed from string in the provided module
// scope and returns the resulting value.
//
public object ExecuteExpr(string expr_str,
IDynamicMetaObjectProvider moduleEO) {
var moduleFun = ParseExprToLambda(new StringReader(expr_str));
var d = moduleFun.Compile();
return d(this, moduleEO);
}
示例14: CreateFromDynamicMetaObject
private static TableItem CreateFromDynamicMetaObject( IDynamicMetaObjectProvider entity, bool throwOnReservedPropertyName )
{
var properties = new Dictionary<string, Tuple<object, Type>>();
IEnumerable<string> memberNames = Dynamic.GetMemberNames( entity );
foreach ( var memberName in memberNames )
{
dynamic result = Dynamic.InvokeGet( entity, memberName );
properties[memberName] = new Tuple<object, Type>( (object) result, result.GetType() );
}
return new TableItem( properties, throwOnReservedPropertyName );
}
示例15: _OnStartExecute
private void _OnStartExecute(IDynamicMetaObjectProvider executingScope, SourceUnit sourceUnit)
{
ContractUtils.Requires(executingScope is Scope);
ExecutingScope = executingScope as Scope;
ExecutingScopeStorage = ExecutingScope.Storage;
//We should update the context under which this LuaTable is executing
//so that it resolves metamethod overrides correctly.
//TODO: Decide whether we should keep this if it is non-null, it may be that this is coming from a different
// CodeContext which has some metamethod stuff set particularly for this scope, or its contents, and we
// shouldn't change this.
if (ExecutingScopeStorage is LuaTable)
(ExecutingScopeStorage as LuaTable).Context = this;
_LoadedPackages.Clear();
_FunctionStacks.Clear();
_EnvironmentMappings.Clear(); //We clear this here as opposed to in OnFinishExecute in case the last execution failed
}