Пример #1
0
 public static void ClearCache()
 {
     NamespaceWrapper.ClearCache();
     TypeWrapper.ClearCache();
     GenericWrapper.ClearCache();
     DelegateWrapper.ClearCache();
     InstanceMethodWrapper.ClearCache();
     StaticMethodWrapper.ClearCache();
     ConstructorWrapper.ClearCache();
 }
Пример #2
0
        public static InstanceMethodWrapper Wrap(MethodInfo mi)
        {
            if (cache.ContainsKey(mi))
            {
                return(cache[mi]);
            }
            var tw = new InstanceMethodWrapper(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);
                }
            }
        }