Beispiel #1
0
        void InitializeMethods()
        {
            methods      = new Dictionary <string, List <ILMethod> >();
            constructors = new List <ILMethod>();
            foreach (var i in definition.Methods)
            {
                if (i.IsConstructor)
                {
                    if (i.IsStatic)
                    {
                        staticConstructor = new ILMethod(i, this, appdomain);
                    }
                    else
                    {
                        constructors.Add(new ILMethod(i, this, appdomain));
                    }
                }
                else
                {
                    List <ILMethod> lst;
                    if (!methods.TryGetValue(i.Name, out lst))
                    {
                        lst             = new List <ILMethod>();
                        methods[i.Name] = lst;
                    }
                    var m = new ILMethod(i, this, appdomain);
                    lst.Add(new ILMethod(i, this, appdomain));
                }
            }

            if (staticConstructor != null && (!TypeReference.HasGenericParameters || IsGenericInstance))
            {
                appdomain.Invoke(staticConstructor, null, null);
            }
        }
Beispiel #2
0
 public override void Start()
 {
     if (!m_bStartGot)
     {
         m_Start     = instance.Type.GetMethod("Start", 0);
         m_bStartGot = true;
     }
     if (m_Start != null)
     {
         appdomain.Invoke(m_Start, instance, null);//没有参数建议显式传递null为参数列表,否则会自动new object[0]导致GC Alloc
     }
 }
Beispiel #3
0
 public bool MoveNext()
 {
     if (!m_moveNextMethodGot)
     {
         m_moveNextMethod    = instance.Type.GetMethod("MoveNext", 0);
         m_moveNextMethodGot = true;
     }
     if (m_moveNextMethod != null)
     {
         return((bool)appdomain.Invoke(m_moveNextMethod, instance, null));
     }
     return(false);
 }
 public override void Start()
 {
     if (!m_bStartGot)
     {
         m_Start     = instance.Type.GetMethod("Start", 0);
         m_bStartGot = true;
     }
     if (m_Start != null)
     {
         appdomain.Invoke(m_Start, instance, null);
     }
     else
     {
     }
 }