コード例 #1
0
        private bool ApplyEventModificators(DepartmentPropertyInfo info, EventArgs args, object invoker, DepartmentPropertyModificator.OnEventInputModel.EventType type, string eventName = null)
        {
            if (type != DepartmentPropertyModificator.OnEventInputModel.EventType.Other)
            {
                eventName = type.ToString();
            }
            else if (eventName != null)
            {
            }
            else
            {
                throw new InvalidOperationException("Invalid eventName");
            }

            var  mods   = info.GetModificators();
            bool result = false;

            foreach (var mod in mods)
            {
                var input = new DepartmentPropertyModificator.OnEventInputModel();
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.ValueStoreProperty, this);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.PropertyInfoProperty, info);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.InvokerProperty, invoker);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.EventArgsProperty, args);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.EventNameProperty, eventName);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnEventInputModel.EventTypeProperty, type);

                var output = mod.OnEvent(input);

                result = output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnEventOutputModel.IsCancelEventInvokeProperty) == true || result;
            }

            return(!result);
        }
コード例 #2
0
        private object ApplyGetModificators(DepartmentPropertyInfo info)
        {
            object returnValue = GetPropertyValueDirect(info);
            var    mods        = info.GetModificators();

            foreach (var mod in mods)
            {
                var input = new DepartmentPropertyModificator.OnGetInputModel();
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnGetInputModel.PropertyValueProperty, returnValue);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnGetInputModel.PropertyInfoProperty, info);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnGetInputModel.ValueStoreProperty, this);

                var output = mod.OnGet(input);

                if (output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnGetOutputModel.IsChangeReturnPropertyValueProperty) == true)
                {
                    returnValue = output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnGetOutputModel.NewReturnPropertyValueProperty);
                }

                if (output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnGetOutputModel.IsChangeRealPropertyValueProperty) == true)
                {
                    SetPropertyValue(info, output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnGetOutputModel.NewRealPropertyValueProperty));
                }
            }

            return(returnValue);
        }
コード例 #3
0
        private object ApplySetModificators(DepartmentPropertyInfo info, object value, bool hasValidToken)
        {
            object returnValue = value;
            var    mods        = info.GetModificators();

            foreach (var mod in mods)
            {
                var input = new DepartmentPropertyModificator.OnSetInputModel();
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnSetInputModel.PropertyCurrentValueProperty, GetPropertyValue(info));
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnSetInputModel.PropertySettableValueProperty, returnValue);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnSetInputModel.HasValidTokenProperty, hasValidToken);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnSetInputModel.PropertyInfoProperty, info);
                input.DepartmentStore.SetPropertyValue(DepartmentPropertyModificator.OnSetInputModel.ValueStoreProperty, this);

                var output = mod.OnSet(input);

                if (output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnSetOutputModel.IsChangePropertyValueProperty))
                {
                    returnValue = output.DepartmentStore.GetPropertyValue(DepartmentPropertyModificator.OnSetOutputModel.NewPropertyValueProperty);
                }
            }

            return(returnValue);
        }