Exemplo n.º 1
0
        public void RegisterExport(MethodBase methodBase, bool bindToInstance, string script)
        {
            var ei = new ExportInfo {
                MethodBase = methodBase, Script = script
            };

            if (bindToInstance)
            {
                var ti = FindTypeInfo(methodBase.DeclaringType);
                if (ti == null)
                {
                    throw new InvalidOperationException("no type info for exported instance's type");
                }
                if (ti.InstanceExports == null)
                {
                    ti.InstanceExports = new List <ExportInfo>();
                }
                ti.InstanceExports.Add(ei);
            }
            else
            {
                staticExports.Add(ei);
                InteropContextManager.WithAllRuntimes
                    (runtime => runtime.BindExportedMethod(methodBase, null, script));
            }
        }
Exemplo n.º 2
0
 public void RegisterExport(MethodBase methodBase, bool bindToInstance, string script)
 {
     var ei = new ExportInfo { MethodBase = methodBase, Script = script };
     if (bindToInstance)
     {
         var ti = FindTypeInfo(methodBase.DeclaringType);
         if (ti == null)
             throw new InvalidOperationException("no type info for exported instance's type");
         if (ti.InstanceExports == null)
             ti.InstanceExports = new List<ExportInfo>();
         ti.InstanceExports.Add(ei);
     }
     else
     {
         staticExports.Add(ei);
         InteropContextManager.WithAllRuntimes
             (runtime => runtime.BindExportedMethod(methodBase, null, script));
     }
 }