Beispiel #1
0
        public MemberInspector Inspect(object host, MemberInfo memberInfo, InspectInfo inspectInfo)
        {
            MemberInspector memberInspector = null;

            if (inspectInfo != null)
            //如果识别成功
            {
                var prefab = GetMemberInspectorPrefabByKey(inspectInfo.Key);
                if (prefab)
                {
                    //生成memberInspector,并完成绑定工作
                    var memberInspectorObject = Instantiate(prefab);
                    memberInspector = memberInspectorObject.GetComponent <MemberInspector>();
                    if (!memberInspector)
                    {
                        throw new Exception("在目标检索器预制体中找不到合法的MemberInspector组件!");
                    }
                    memberInspector.Host        = host;
                    memberInspector.inspectInfo = inspectInfo;
                    memberInspector.InspectName = memberInfo.Name;
                    inspectInfo.member          = memberInfo;
                    Interf.Instance.Print("bind Member of {0} successfully from Type {1} !", memberInfo.ToString(), memberInfo.DeclaringType.ToString());
                }
                else
                {
                    //未找到合适的prefab,输出失败信息
                    Interf.Instance.Print("Failed to find the valid prefab to inspect the member by key of [{0}]", inspectInfo.Key);
                }
            }
            return(memberInspector);
        }
Beispiel #2
0
        /// <summary>
        /// 尝试检索某个Member
        /// </summary>
        /// <param name="host"></param>
        /// <param name="memberInfo"></param>
        /// <returns></returns>
        public MemberInspector TryInspect(object host, MemberInfo memberInfo)
        {
            InspectInfo inspectInfo = null;

            for (var i = 0; i < InspectorInfoFilterList.Count; i++)
            {
                //依次执行所有过滤器
                if (InspectorInfoFilterList[i](this, host, memberInfo, ref inspectInfo))
                {
                    //过滤器返回true,表明过滤终止
                    break;
                }
            }
            if (inspectInfo != null)
            {
                //识别成功,得到了该类成员的检索信息
                return(Inspect(host, memberInfo, inspectInfo));
            }
            else
            {
                //识别失败
                return(null);
            }
        }