CSLE.RegHelper_TypeFunction.MemberValueGet C# (CSharp) Метод

MemberValueGet() публичный Метод

public MemberValueGet ( CLS_Content environment, object object_this, string valuename ) : CLS_Content.Value
environment CLS_Content
object_this object
valuename string
Результат CLS_Content.Value
        public virtual CLS_Content.Value MemberValueGet(CLS_Content environment, object object_this, string valuename)
        {

            MemberValueCache c;

            if (!memberValuegetCaches.TryGetValue(valuename, out c))
            {
                c = new MemberValueCache();
                memberValuegetCaches[valuename] = c;
                c.finfo = type.GetField(valuename);
                if (c.finfo == null)
                {
                    c.minfo = type.GetMethod("get_" + valuename);
                    if (c.minfo == null)
                    {
                        c.einfo = type.GetEvent(valuename);
                        if (c.einfo == null)
                        {
                            c.type = -1;
                            return null;
                        }
                        else
                        {
                            c.type = 3;
                        }
                    }
                    else
                    {
                        c.type = 2;
                    }
                }
                else
                {
                    c.type = 1;
                }
            }

            if (c.type < 0) return null;
            CLS_Content.Value v = new CLS_Content.Value();
            switch (c.type)
            {
                case 1:

                    v.value = c.finfo.GetValue(object_this);
                    v.type = c.finfo.FieldType;
                    break;
                case 2:

                    v.value = c.minfo.Invoke(object_this, null);
                    v.type = c.minfo.ReturnType;
                    break;
                case 3:
                    v.value = new DeleEvent(object_this, c.einfo);
                    v.type = c.einfo.EventHandlerType;
                    break;

            }
            return v;

            //var targetf = type.GetField(valuename);
            //if (targetf != null)
            //{
            //    CLS_Content.Value v = new CLS_Content.Value();
            //    v.value = targetf.GetValue(object_this);
            //    v.type = targetf.FieldType;
            //    return v;
            //}

            //var targetp = type.GetProperty(valuename);
            //if (targetp != null)
            //{
            //    CLS_Content.Value v = new CLS_Content.Value();
            //    v.value = targetp.GetValue(object_this, null);
            //    v.type = targetp.PropertyType;
            //    return v;
            //}
            //else
            //{//用get set 方法替代属性操作,AOT环境属性操作有问题
            //    var methodf = type.GetMethod("get_" + valuename);
            //    if (methodf != null)
            //    {
            //        CLS_Content.Value v = new CLS_Content.Value();
            //        v.value = methodf.Invoke(object_this, null);
            //        v.type = methodf.ReturnType;
            //        return v;
            //    }
            //var targetf = type.GetField(valuename);
            //if (targetf != null)
            //{
            //    CLS_Content.Value v = new CLS_Content.Value();
            //    v.value = targetf.GetValue(object_this);
            //    v.type = targetf.FieldType;
            //    return v;
            //}
            //    else
            //    {
            //        System.Reflection.EventInfo targete = type.GetEvent(valuename);
            //        if (targete != null)
            //        {
            //            CLS_Content.Value v = new CLS_Content.Value();
            //            v.value = new DeleEvent(object_this, targete);
            //            v.type = targete.EventHandlerType;
            //            return v;
            //        }
            //    }
            //}

            //return null;
        }