Esempio n. 1
0
        public void TestObjectComparerEquals()
        {
            ObjectComparer comparer = new ObjectComparer();

            Assert.IsTrue(comparer.Equals(intObject, floatObject));
            Assert.IsTrue(comparer.Equals(stringObject, stringObject));
            Assert.IsTrue(comparer.Equals(listObject, listObject));
            Assert.IsTrue(comparer.Equals(listObject, secondListObject));

            Assert.IsFalse(comparer.Equals(intObject, boolObject));
            Assert.IsFalse(comparer.Equals(charObject, stringObject));
            Assert.IsFalse(comparer.Equals(listObject, new List <object>()
            {
                true
            }));
        }
Esempio n. 2
0
        protected async Task UpdateUser()
        {
            IsBusy = true; FormValid = false;
            Profile.Configuration = JsonSerializer.Serialize(Configuration).ToString();

            Task <UserEditViewModel> result = CustomerService.UpdateUserAsync(Profile);
            UserEditViewModel        user   = await result;

            if (result.IsCompletedSuccessfully)
            {
                Profile = user;
                IsBusy  = false;
                await JsRuntime.InvokeAsync <string>("SetToLocalStorege", "user-conf", Profile.Configuration);

                IsDefaultParams = ObjectComparer.Equals(new UserConfiguration(), JsonSerializer.Deserialize <UserConfiguration>(Profile.Configuration));
                UserSettings.UserConfiguration = JsonSerializer.Deserialize <UserConfiguration>(Profile.Configuration);
            }
        }
Esempio n. 3
0
        protected override async Task OnInitializedAsync()
        {
            Profile = await CustomerService.GetUserAsync();

            Selections = await CustomerService.GetUserRolesAsync(CurrentUserInfo.CurrentUser.Id);

            Profile.Roles = Selections.ToArray();

            Languages = (await LanguageService.GetAsync()).OrderBy(l => l.Id).ToList();
            if (!string.IsNullOrEmpty(Profile.Configuration))
            {
                Configuration   = JsonSerializer.Deserialize <UserConfiguration>(Profile.Configuration);
                IsDefaultParams = ObjectComparer.Equals(new UserConfiguration(), JsonSerializer.Deserialize <UserConfiguration>(Profile.Configuration));
            }

            ProfileContext = new EditContext(Profile);
            ProfileContext.OnFieldChanged       += ProfileHandleFieldChanged;
            ConfigurationContext                 = new EditContext(Configuration);
            ConfigurationContext.OnFieldChanged += HandleFieldChanged;
            await base.OnInitializedAsync();
        }
        /// <summary>
        /// グローバル変数をセットする
        /// </summary>
        /// <param name="name">グローバル変数名</param>
        /// <param name="value">値</param>
        /// <param name="zone"ゾーン名</param>
        /// <returns>is changed</returns>
        public static bool SetVariable(
            string name,
            object value,
            string zone = null)
        {
            var result   = false;
            var variable = default(TimelineVariable);

            lock (ExpressionLocker)
            {
                if (Variables.ContainsKey(name))
                {
                    variable = Variables[name];
                }
                else
                {
                    variable        = new TimelineVariable(name);
                    Variables[name] = variable;
                    result          = true;
                }

                switch (value)
                {
                case bool b:
                    if (!(variable.Value is bool current1) ||
                        current1 != b)
                    {
                        variable.Value      = b;
                        variable.Expiration = DateTime.MaxValue;
                        result = true;
                    }
                    break;

                case string s:
                    if (s.TryParse0xString2Int(out int i2))
                    {
                        if (!(variable.Value is int current2) ||
                            current2 != i2)
                        {
                            variable.Value      = i2;
                            variable.Expiration = DateTime.MaxValue;
                            result = true;
                        }
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                default:
                    if (!ObjectComparer.Equals(value, variable.Value))
                    {
                        variable.Value      = value;
                        variable.Expiration = DateTime.MaxValue;
                        result = true;
                    }
                    break;
                }

                variable.Zone = zone ?? string.Empty;
            }

            if (result)
            {
                OnVariableChanged?.Invoke(new EventArgs());

                if (ReferedTriggerRecompileDelegates.ContainsKey(variable.Name))
                {
                    lock (variable)
                    {
                        ReferedTriggerRecompileDelegates[variable.Name]?.Invoke();
                    }
                }
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// グローバル変数をセットする
        /// </summary>
        /// <param name="name">グローバル変数名</param>
        /// <param name="value">値</param>
        /// <param name="zone"ゾーン名</param>
        /// <returns>is changed</returns>
        public static bool SetVariable(
            string name,
            object value,
            string zone = null)
        {
            var result = false;

            lock (ExpressionLocker)
            {
                var variable = default(TimelineVariable);
                if (Variables.ContainsKey(name))
                {
                    variable = Variables[name];
                }
                else
                {
                    variable        = new TimelineVariable(name);
                    Variables[name] = variable;
                    result          = true;
                }

                switch (value)
                {
                case bool b:
                    if (!(variable.Value is bool current) ||
                        current != b)
                    {
                        variable.Value      = b;
                        variable.Expiration = DateTime.MaxValue;
                        result = true;
                    }
                    break;

                case int i:
                    if (variable.Counter != i)
                    {
                        variable.Counter    = i;
                        variable.Expiration = DateTime.MaxValue;
                        result = true;
                    }
                    break;

                default:
                    if (!ObjectComparer.Equals(value, variable.Value))
                    {
                        variable.Value      = value;
                        variable.Expiration = DateTime.MaxValue;
                        result = true;
                    }
                    break;
                }

                variable.Zone = zone ?? string.Empty;
            }

            if (result)
            {
                OnVariableChanged?.Invoke(new EventArgs());
            }

            return(result);
        }