Beispiel #1
0
        /// <inheritdoc />
        protected override void BuildRenderInput(RenderTreeBuilder builder)
        {
            builder.OpenElement(0, GetElementName());
            BuildRenderInput_AddCommonAttributes(builder, GetTypeAttributeValue());

            int?maxLengthEffective = this.MaxLength ?? GetValueAttribute <MaxLengthAttribute>()?.Length;

            if (maxLengthEffective > 0)             // [MaxLength] attribute has a default value of -1
            {
                builder.AddAttribute(1000, "maxlength", maxLengthEffective);
            }

            builder.AddAttribute(1002, "value", FormatValueAsString(Value));
            builder.AddAttribute(1003, BindEvent.ToEventName(), EventCallback.Factory.CreateBinder <string>(this, value => CurrentValueAsString = value, CurrentValueAsString));

            if (this.InputModeEffective is not null)
            {
                builder.AddAttribute(1004, "inputmode", this.InputModeEffective.Value.ToString("f").ToLower());
            }

            builder.AddEventStopPropagationAttribute(1005, "onclick", true);
            builder.AddElementReferenceCapture(1006, elementReferece => InputElement = elementReferece);

            builder.CloseElement();
        }
Beispiel #2
0
 /// <summary>
 /// Gets the boolean value of the specified BindEvent&lt;string&gt;
 /// object.
 /// </summary>
 /// <param name="ev">
 /// The BindEvent&lt;string&gt; object that provides a boolean value.
 /// </param>
 /// <param name="defaultValue">
 /// The default value.
 /// </param>
 /// <returns>
 /// The boolean value if the specified BindEvent has a value and the
 /// value is parsed successfully and valid, the default value
 /// otherwise.
 /// </returns>
 public static bool ToBooleanValue(
     BindEvent <string>?ev, bool defaultValue)
 {
     return((ev is null)
         ? defaultValue
         : ParseBoolean(ev.Value) ?? defaultValue);
 }
Beispiel #3
0
    public void ChangeCode(string newCode)
    {
        Code = "require 'tilelib'\n" + newCode;
        LuaEnv.DoString(Code);

        BindEvent?.Invoke();
        UStart?.Invoke();
    }
Beispiel #4
0
    // Use this for initialization
    protected void Start()
    {
        LuaEnv     = new LuaEnv();
        BindEvent += Binding;
        BindEvent += BindLocalMethod;

        UUpdate += OUpdate;
        UStart  += OStart;

        BindEvent?.Invoke();
        UStart?.Invoke();
    }
Beispiel #5
0
        /// <summary>
        /// Validates the specified BindEvent&lt;string&gt; object and gets the
        /// tuples representing the error information.
        /// </summary>
        /// <param name="ev">
        /// The BindEvent&lt;string&gt; object.
        /// </param>
        /// <param name="invalidBooleanValueError">
        /// The error message when it is unable to parse a boolean value.
        /// </param>
        /// <returns>
        /// <see cref="NoError"/> if the specified BindEvent&lt;string&gt;
        /// object can be parsed successfully. Otherwise, the errors.
        /// </returns>
        public static IEnumerable <WhereWhy> ValidateBoolean(
            BindEvent <string>?ev,
            string invalidBooleanValueError)
        {
            if (ev is null)
            {
                return(NoError);
            }
            var v = ParseBoolean(ev.Value);

            return(!v.HasValue
                ? Enumerables.Of(ToError(ev, invalidBooleanValueError))
                : NoError);
        }
Beispiel #6
0
        /// <summary>
        /// Gets the integer value of the specified BindEvent&lt;string&gt;
        /// object.
        /// </summary>
        /// <param name="ev">
        /// The BindEvent&lt;string&gt; object that provides an integer value.
        /// </param>
        /// <param name="defaultValue">
        /// The default value.
        /// </param>
        /// <param name="isValidValue">
        /// The function that returns whether a value of the argument is valid
        /// or not.
        /// </param>
        /// <returns>
        /// The integer value if the specified BindEvent has a value and the
        /// value is parsed successfully and valid, the default value
        /// otherwise.
        /// </returns>
        public static int ToIntValue(
            BindEvent <string>?ev,
            int defaultValue,
            Func <int, bool> isValidValue)
        {
            if (ev is null)
            {
                return(defaultValue);
            }
            var v = ParseInt(ev.Value);

            return((v.HasValue && isValidValue(v.Value))
                ? v.Value
                : defaultValue);
        }
        private static void OnLoad()
        {
            LuaVM.OnPreRequestLoaded += () => {
                var luaVm               = CSharpServiceManager.Get <LuaVM>(CSharpServiceManager.ServiceType.LUA_SERVICE);
                var getLuaService       = luaVm.Global.GetInPath <GetLuaService>("_ServiceManager.GetService");
                var eventBindingService = getLuaService(8);
                m_dispatch    = eventBindingService.GetInPath <BindingEventDispatch>("Dispatch");
                m_bindEvent   = eventBindingService.GetInPath <BindEvent>("AddEventListener");
                m_unbindEvent = eventBindingService.GetInPath <BindEvent>("RemoveEventListener");
            };

            LuaVM.OnVMQuiting += () => {
                m_bindEvent   = null;
                m_unbindEvent = null;
                m_dispatch    = null;
            };
        }
Beispiel #8
0
        /// <summary>
        /// Validates the specified BindEvent&lt;string&gt; object and gets the
        /// tuples representing the error information.
        /// </summary>
        /// <param name="ev">
        /// The BindEvent&lt;string&gt; object.
        /// </param>
        /// <param name="isValidValue">
        /// The function that returns whether a value of the argument is valid
        /// or not.
        /// </param>
        /// <param name="invalidIntegerValueError">
        /// The error message when it is unable to parse an integer value.
        /// </param>
        /// <param name="invalidValueRangeError">
        /// The error message when the parsed value is invalid.
        /// </param>
        /// <returns>
        /// <see cref="NoError"/> if the specified BindEvent&lt;string&gt;
        /// object can be parsed successfully. Otherwise, the errors.
        /// </returns>
        public static IEnumerable <WhereWhy> ValidateInt(
            BindEvent <string>?ev,
            Func <int, bool> isValidValue,
            string invalidIntegerValueError,
            string invalidValueRangeError)
        {
            if (ev is null)
            {
                return(NoError);
            }
            var v = ParseInt(ev.Value);

            return(!v.HasValue
                ? Enumerables.Of(ToError(ev, invalidIntegerValueError))
                : !isValidValue(v.Value)
                ? Enumerables.Of(ToError(ev, invalidValueRangeError))
                : NoError);
        }
Beispiel #9
0
 private static WhereWhy ToError(BindEvent <string> ev, string message)
 => new WhereWhy(ev.Line, ev.Column, $"{message}: '{ev.Value}'");
Beispiel #10
0
 /// <summary>
 /// Gets the name of event as string.
 /// </summary>
 public static string ToEventName(this BindEvent value)
 {
     return(value.ToString().ToLower());
 }
 public void Notify(BindEvent <string> value) => Value = value;
 public void Notify(BindEvent <First> first)
 {
     this.first = first;
 }