コード例 #1
0
ファイル: MethodDrawer.cs プロジェクト: MCV-Univalle/Rivit
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && DEBUG_BUILD_MEMBERS
            Debug.Log(Msg(ToString(), ".DoBuildMembers with hasResult=", hasResult, ", hasParameters=", hasParameters, ", isGeneric=", isGeneric));
                        #endif

            if (!hasResult && !hasParameters && !isGeneric)
            {
                DrawerArrayPool.Resize(ref members, 0);
            }
            else
            {
                int size = 0;
                if (hasResult)
                {
                    size++;
                }
                if (isGeneric)
                {
                    size++;
                }
                if (hasParameters)
                {
                    size++;
                }
                DrawerArrayPool.Resize(ref members, size);

                bool readOnly = ReadOnly;

                int index = 0;
                if (isGeneric)
                {
                    members[0] = GenericsDrawer.Create(memberInfo, this, GUIContentPool.Create("Generics"), readOnly);
                    index++;
                }

                if (hasParameters)
                {
                    members[index] = ParameterDrawer.Create(MethodInfo.GetParameters(), memberInfo, this, GUIContentPool.Create("Parameters"), readOnly);
                    index++;
                }

                if (hasResult)
                {
                    string tooltip = LinkedMemberInfo.TooltipDatabase.GetTooltipFromParent(MethodInfo.ReturnParameter, memberInfo, "Returns");
                    if (tooltip.Length == 0)
                    {
                        tooltip = "Value returned by method.";
                    }

                    var resultMemberInfo = resultMemberHierarchy.Get(null, typeof(MethodDrawer).GetField("result", BindingFlags.Instance | BindingFlags.NonPublic), LinkedMemberParent.ClassInstance, null);
                    members[index] = DrawerProvider.GetForField(result, Type, resultMemberInfo, this, GUIContentPool.Create("Result", tooltip), readOnly);
                }
            }
        }
コード例 #2
0
        /// <summary> Creates a new instance of the drawer or returns a reusable instance from the pool. </summary>
        /// <param name="methodInfo"> LinkedMemberInfo of the method whose generic parameters the drawer represent. Not null. </param>
        /// <param name="parent"> The parent drawer of the created drawer. Can be null. </param>
        /// <param name="label"> The prefix label. </param>
        /// <param name="setReadOnly"> True if control should be read only. </param>
        /// <returns> The instance, ready to be used. </returns>
        public static GenericsDrawer Create([NotNull] LinkedMemberInfo methodInfo, [NotNull] MethodDrawer parent, GUIContent label, bool setReadOnly)
        {
            GenericsDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new GenericsDrawer();
            }
            result.Setup(ArrayPool <Type> .ZeroSizeArray, typeof(Type[]), methodInfo, parent, label, setReadOnly);
            result.LateSetup();
            return(result);
        }