コード例 #1
0
        public void OnBorrowed(EvaluateWidget evaluator, Type genericConstraint)
        {
            this.evaluator   = evaluator;
            this.genericType = genericConstraint;

            typeCompleter.Enabled  = true;
            typeCompleter.BaseType = genericType;
            typeCompleter.CacheTypes();

            var constraints = genericType.GetGenericParameterConstraints();

            typeCompleter.GenericConstraints = constraints;

            var sb = new StringBuilder($"<color={SignatureHighlighter.CONST}>{genericType.Name}</color>");

            for (int j = 0; j < constraints.Length; j++)
            {
                if (j == 0)
                {
                    sb.Append(' ').Append('(');
                }
                else
                {
                    sb.Append(',').Append(' ');
                }

                sb.Append(SignatureHighlighter.Parse(constraints[j], false));

                if (j + 1 == constraints.Length)
                {
                    sb.Append(')');
                }
            }

            argNameLabel.text = sb.ToString();
        }
コード例 #2
0
        public void OnBorrowed(EvaluateWidget evaluator, ParameterInfo paramInfo)
        {
            this.evaluator = evaluator;
            this.paramInfo = paramInfo;

            this.paramType = paramInfo.ParameterType;
            if (paramType.IsByRef)
            {
                paramType = paramType.GetElementType();
            }

            this.argNameLabel.text =
                $"{SignatureHighlighter.Parse(paramType, false)} <color={SignatureHighlighter.LOCAL_ARG}>{paramInfo.Name}</color>";

            if (ParseUtility.CanParse(paramType) || typeof(Type).IsAssignableFrom(paramType))
            {
                usingBasicLabel = false;

                this.inputField.Component.gameObject.SetActive(true);
                this.basicLabelHolder.SetActive(false);
                this.typeCompleter.Enabled = typeof(Type).IsAssignableFrom(paramType);
                this.enumCompleter.Enabled = paramType.IsEnum;
                this.enumHelperButton.Component.gameObject.SetActive(paramType.IsEnum);

                if (!typeCompleter.Enabled)
                {
                    if (paramType == typeof(string))
                    {
                        inputField.PlaceholderText.text = "...";
                    }
                    else
                    {
                        inputField.PlaceholderText.text = $"eg. {ParseUtility.GetExampleInput(paramType)}";
                    }
                }
                else
                {
                    inputField.PlaceholderText.text = "Enter a Type name...";
                    this.typeCompleter.BaseType     = typeof(object);
                    this.typeCompleter.CacheTypes();
                }

                if (enumCompleter.Enabled)
                {
                    enumCompleter.EnumType = paramType;
                    enumCompleter.CacheEnumValues();
                }
            }
            else
            {
                // non-parsable, and not a Type
                usingBasicLabel = true;

                this.inputField.Component.gameObject.SetActive(false);
                this.basicLabelHolder.SetActive(true);
                this.typeCompleter.Enabled = false;
                this.enumCompleter.Enabled = false;
                this.enumHelperButton.Component.gameObject.SetActive(false);

                SetDisplayedValueFromPaste();
            }
        }