コード例 #1
0
        /// <summary>
        /// 分析绑定member
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="components"></param>
        protected virtual void AnalysisBindingMembers(InvocationExpression invocation, List <ComponentItem> components)
        {
            var component = components.Find(x => invocation.Arguments.Count > 1 && invocation.Arguments.First().ToString().Contains(string.Format("m_{0}.", x.name)));

            if (component != null)
            {
                var sourceName = GenCodeUtil.FromSourceKey(invocation.Arguments.ToArray()[1].ToString());
                var info       = component.viewItems.Find(x => x.bindingSource == sourceName);
                var isMethod   = false;
                var targetName = AnalysisTargetFromLamdaArgument(invocation.Arguments.First().ToString(), out isMethod);
                //UnityEngine.Debug.Log("解析出字段:" + targetName);
                //UnityEngine.Debug.Log("目标名:" + sourceName);

                if (string.IsNullOrEmpty(targetName))
                {
                    UnityEngine.Debug.Assert(!string.IsNullOrEmpty(targetName), "annalysis err:" + invocation.Arguments.First().ToString());
                    return;
                }
                var type = GetTypeClamp(component.componentType, targetName);
                //UnityEngine.Debug.Log("解析出类型:" + type);
                if (info == null)
                {
                    info = new BindingShow();
                    info.bindingSource = sourceName;
                    info.bindingTarget = targetName;
                    info.isMethod      = isMethod;
                    component.viewItems.Add(info);
                }
                info.bindingTargetType.Update(type);
            }
        }
コード例 #2
0
        /// <summary>
        /// 分析绑定方法
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="components"></param>
        protected virtual void AnalysisBindingEvents(InvocationExpression invocation, List <ComponentItem> components)
        {
            var component = components.Find(x => invocation.Arguments.Count > 1 && invocation.Arguments.First().ToString().Contains("m_" + x.name));

            if (component != null)
            {
                var  sourceName = GenCodeUtil.FromSourceKey(invocation.Arguments.ToArray()[1].ToString());
                var  info       = component.eventItems.Find(x => x.bindingSource == sourceName);
                var  arg0       = invocation.Arguments.First().ToString();
                var  targetName = arg0.Substring(arg0.IndexOf(".") + 1);
                Type infoType   = GetTypeClamp(component.componentType, targetName);

                if (info == null)
                {
                    info = new BindingEvent();
                    info.bindingSource = sourceName;
                    info.bindingTarget = targetName;
                    info.bindingTargetType.Update(infoType);
                    component.eventItems.Add(info);
                }

                info.bindingTargetType.Update(infoType);

                if (invocation.Arguments.Count() > 2)
                {
                    info.type = BindingType.WithTarget;//3个参数
                }
                else
                {
                    info.type = BindingType.Normal;//2个参数
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 分析本地方法
        /// </summary>
        /// <param name="invocation"></param>
        /// <param name="components"></param>
        protected virtual void AnalysisLoaclInvocation(InvocationExpression invocation, List <ComponentItem> components)
        {
            var component = components.Find(x => invocation.Target.ToString().Contains("m_" + x.name));

            if (component != null)
            {
                string bindingSource = GenCodeUtil.FromSourceKey(invocation.Arguments.First().ToString());
                var    info          = component.eventItems.Find(x => invocation.Target.ToString().Contains("m_" + component.name + "." + x.bindingTarget) && x.type == BindingType.NoBinding && x.bindingSource == bindingSource);

                if (info == null)
                {
                    var  express  = invocation.Target as MemberReferenceExpression;
                    var  target   = (express.Target as MemberReferenceExpression).MemberNameToken.Name;
                    Type infoType = GetTypeClamp(component.componentType, target);
                    info               = new BindingEvent();
                    info.type          = BindingType.NoBinding;
                    info.bindingSource = bindingSource;
                    info.bindingTarget = target;
                    info.bindingTargetType.Update(infoType);
                    component.eventItems.Add(info);
                }
            }
        }