예제 #1
0
 public static void ClearCache()
 {
     NamespaceWrapper.ClearCache();
     TypeWrapper.ClearCache();
     GenericWrapper.ClearCache();
     DelegateWrapper.ClearCache();
     InstanceMethodWrapper.ClearCache();
     StaticMethodWrapper.ClearCache();
     ConstructorWrapper.ClearCache();
 }
예제 #2
0
        public static StaticMethodWrapper Wrap(MethodInfo mi)
        {
            if (cache.ContainsKey(mi))
            {
                return(cache[mi]);
            }
            var tw = new StaticMethodWrapper(mi);

            cache[mi] = tw;
            return(tw);
        }
예제 #3
0
 public static JavaScriptValue WrapMethod(MethodInfo mi)
 {
     if (mi.IsStatic)
     {
         var c = StaticMethodWrapper.Wrap(mi);
         return(c.GetJavaScriptValue());
     }
     else
     {
         var c = InstanceMethodWrapper.Wrap(mi);
         return(c.GetJavaScriptValue());
     }
 }
예제 #4
0
        void AssignMethodProc(JavaScriptValue setTo, MethodInfo[] methods)
        {
            var methodDic = new Dictionary <string, List <MethodInfo> >();

            foreach (var m in methods)
            {
                if (m.IsSpecialName)
                {
                    continue;
                }
                if (m.IsGenericMethodDefinition)
                {
                    continue;
                }
                if (m.IsGenericMethod)
                {
                    continue;
                }
                if (!methodDic.ContainsKey(m.Name))
                {
                    methodDic[m.Name] = new List <MethodInfo>();
                }
                methodDic[m.Name].Add(m);
            }
            foreach (var methodName in methodDic.Keys)
            {
                var ms = methodDic[methodName];
                if (ms.Count == 1)
                {
                    var m   = ms[0];
                    var smw = (m.IsStatic) ? (FunctionWrapper)StaticMethodWrapper.Wrap(m) : (FunctionWrapper)InstanceMethodWrapper.Wrap(m);
                    setTo.SetIndexedProperty(JavaScriptValue.FromString(m.Name), smw.GetJavaScriptValue());
                    methodWrappers.Add(smw);
                }
                else
                {
                    var os = new OverloadSelector();
                    foreach (var m in ms)
                    {
                        os.AppendMethod(m);
                    }
                    setTo.SetIndexedProperty(JavaScriptValue.FromString(os.GetName()), os.GetJavaScriptValue());
                    methodWrappers.Add(os);
                }
            }
        }