Exemple #1
0
        public void Initialize(IVisualState visualState)
        {
            // Reflect through all properties and add to List.
            var values = new Dictionary <string, string>();

            _display?.Display(visualState.GetType().Name, values);
        }
Exemple #2
0
 public void Initialize(IVisualState visualState)
 {
     // Reflect through all properties and add to List.
     var values = new Dictionary<string, string>();
     
     _display?.Display(visualState.GetType().Name, values);
 }
Exemple #3
0
        public ViewModel(IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = nameof(ViewModel))
        {

            if (exrinContainer == null)
                throw new ArgumentNullException(nameof(IExrinContainer));

            _applicationInsights = exrinContainer.ApplicationInsights;
            _displayService = exrinContainer.DisplayService;
            _navigationService = exrinContainer.NavigationService;
            _errorHandlingService = exrinContainer.ErrorHandlingService;

            VisualState = visualState;

            if (VisualState != null)
                Task.Run(() => visualState.Init())
                    .ContinueWith((task) =>
                    {
                        if (task.Exception != null)
                            _applicationInsights.TrackException(task.Exception);
                    });

            Execution = new Execution()
            {
                HandleTimeout = TimeoutHandle,
                NotifyOfActivity = NotifyActivity,
                NotifyActivityFinished = NotifyActivityFinished,
                HandleResult = HandleResult
            };

        }
Exemple #4
0
        public ViewModel(IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = nameof(ViewModel))
        {
            if (exrinContainer == null)
            {
                throw new ArgumentNullException(nameof(IExrinContainer));
            }

            _applicationInsights  = exrinContainer.ApplicationInsights;
            _displayService       = exrinContainer.DisplayService;
            _navigationService    = exrinContainer.NavigationService;
            _errorHandlingService = exrinContainer.ErrorHandlingService;

            VisualState = visualState;

            if (VisualState != null)
            {
                Task.Run(() => visualState.Init())
                .ContinueWith((task) =>
                {
                    if (task.Exception != null)
                    {
                        _applicationInsights.TrackException(task.Exception);
                    }
                });
            }

            Execution = new Execution()
            {
                HandleTimeout          = TimeoutHandle,
                NotifyOfActivity       = NotifyActivity,
                NotifyActivityFinished = NotifyActivityFinished,
                HandleResult           = HandleResult
            };
        }
Exemple #5
0
 public void AddState(string id, IVisualState state)
 {
     if (_states.ContainsKey(id))
     {
         _states[id] = state;
     }
     else
     {
         _states.Add(id, state);
     }
 }
Exemple #6
0
        public IVisualState GetState(string id)
        {
            if (_states.ContainsKey(id))
            {
                CurrentState = _states[id];
                StateChanged?.Invoke(CurrentState);

                return(CurrentState);
            }

            return(null);
        }
Exemple #7
0
        public ViewModel(IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = "ViewModel")
        {
            if (exrinContainer == null)
            {
                throw new ArgumentNullException(nameof(IExrinContainer));
            }

            ApplicationInsights  = exrinContainer.ApplicationInsights;
            DisplayService       = exrinContainer.DisplayService;
            NavigationService    = exrinContainer.NavigationService;
            ErrorHandlingService = exrinContainer.ErrorHandlingService;
            _containerSet        = true;

            VisualState = visualState;

            SetExecution();
        }
Exemple #8
0
        public ViewModel(IDisplayService displayService, INavigationService navigationService,
                         IErrorHandlingService errorHandlingService, IStackRunner stackRunner, IVisualState visualState)

        {
            _displayService       = displayService;
            _navigationService    = navigationService;
            _errorHandlingService = errorHandlingService;
            _stackRunner          = stackRunner;

            VisualState = visualState;

            Execution = new Execution()
            {
                HandleTimeout          = TimeoutHandle,
                NotifyOfActivity       = NotifyActivity,
                NotifyActivityFinished = NotifyActivityFinished,
                HandleResult           = HandleResult
            };
        }
Exemple #9
0
 public BaseViewModel(IExrinContainer exrinContainer,
                      IVisualState visualState, string caller = nameof(BaseViewModel))
     : base(exrinContainer, visualState, caller)
 {
 }
Exemple #10
0
        public ViewModel(IVisualState visualState, [CallerFilePath] string caller = "ViewModel")
        {
            VisualState = visualState;

            SetExecution();
        }
Exemple #11
0
 public SettingsOperation(IVisualState visualState)
 {
     _visualState = visualState;
 }
Exemple #12
0
 public void Add(string id, IVisualState state)
 {
     _data.Add(new StateStorageData {
         ID = id, State = state
     });
 }
Exemple #13
0
 public BaseViewModel(IVisualState visualState, string caller = nameof(BaseViewModel))
     : base(visualState, caller)
 {
 }
 public BaseViewModel(IAuthModel authModel, IExrinContainer exrinContainer, IVisualState visualState, [CallerFilePath] string caller = nameof(BaseViewModel))
     : base(exrinContainer, visualState, caller)
 {
     AuthModel = authModel; Init();
 }
Exemple #15
0
        protected object UpdateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, object model)
        {
            bool       cont         = true;
            int        index        = 0;
            int        notNullCount = 0;
            int        prevErrors;
            List <int> trueIndexes       = null;
            Type       previousModelType = null;

            while (cont)
            {
                string displayPrefix = bindingContext.ModelName;
                if (displayPrefix == "model" || (bindingContext.ModelMetadata.PropertyName == null && !displayPrefix.Contains('.') && !displayPrefix.Contains('[') && !displayPrefix.Contains('$')))
                {
                    displayPrefix = "updatemodel";
                }
                ValueProviderResult attemptedTransformer = bindingContext.ValueProvider.GetValue(displayPrefix + string.Format(".$${0}", index));
                if (attemptedTransformer != null && attemptedTransformer.AttemptedValue != null)
                {
                    Type displayModelType = BasicHtmlHelper.DecodeUpdateInfo(attemptedTransformer.AttemptedValue, previousModelType, bindingContext.ValueProvider);

                    if (displayModelType != null && displayModelType.IsClass && displayModelType.GetInterface("IUpdateModel") != null)
                    {
                        prevErrors        = bindingContext.ModelState.Keys.Count;
                        previousModelType = displayModelType;
                        IUpdateModel displayModel = BindDisplayModel(controllerContext, bindingContext, displayModelType, string.Format(".$${0}.$", index)) as IUpdateModel;
                        if (trueIndexes == null)
                        {
                            trueIndexes = new List <int>();
                        }
                        if (displayModel == null)
                        {
                            trueIndexes.Add(-1);
                        }
                        else
                        {
                            string[]            fields = null;
                            ValueProviderResult fieldsAttemptedTransformer = bindingContext.ValueProvider.GetValue(displayPrefix + string.Format(".$${0}.f$ields", index));
                            if (fieldsAttemptedTransformer != null && !string.IsNullOrWhiteSpace(fieldsAttemptedTransformer.AttemptedValue))
                            {
                                fields = BasicHtmlHelper.DecodeFieldsInfo(fieldsAttemptedTransformer.AttemptedValue).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            }
                            else
                            {
                                fields = new string[0];
                            }
                            int         beforeElements   = -1;
                            ICollection beforeCollection = model as ICollection;

                            if (beforeCollection != null)
                            {
                                beforeElements = beforeCollection.Count;
                            }
                            IUpdateModelState updateModelState = displayModel as IUpdateModelState;
                            bool finished = false;
                            if (updateModelState != null)
                            {
                                if (updateModelState.MoveState && index != notNullCount)
                                {
                                    trueIndexes.Add(notNullCount);
                                    AlignModelState(
                                        bindingContext.ModelState,
                                        trueIndexes,
                                        LowerModelName(displayPrefix, ".$$"));
                                    finished = true;
                                }

                                updateModelState.GetCurrState(displayPrefix, notNullCount, bindingContext.ModelState);
                            }
                            IVisualState visualStateStorage = displayModel as IVisualState;
                            if (visualStateStorage != null)
                            {
                                visualStateStorage.ModelName = bindingContext.ModelName;
                                visualStateStorage.Store     = controllerContext.HttpContext.Items;
                            }
                            IHandleUpdateIndex handleUpdateIndex = displayModel as IHandleUpdateIndex;
                            if (handleUpdateIndex != null)
                            {
                                handleUpdateIndex.Index      = index;
                                handleUpdateIndex.ModelState = bindingContext.ModelState;
                            }
                            try
                            {
                                model = displayModel.UpdateModel(model, fields);
                            }
                            catch (Exception ex)
                            {
                                bindingContext.ModelState.AddModelError(bindingContext.ModelName, string.Format(ex.Message, bindingContext.ModelMetadata.GetDisplayName()));
                            }
                            if (finished)
                            {
                                break;
                            }
                            int         afterElements   = -1;
                            ICollection afterCollection = model as ICollection;
                            if (afterCollection != null)
                            {
                                afterElements = afterCollection.Count;
                            }
                            bool noCollections = afterElements == -1 && beforeElements == -1;

                            if (model != null && (noCollections || beforeElements != afterElements))
                            {
                                trueIndexes.Add(notNullCount);

                                notNullCount++;
                            }
                            else
                            {
                                trueIndexes.Add(-1);
                            }
                        }
                    }
                }
                else
                {
                    if (index != notNullCount)
                    {
                        AlignModelState(
                            bindingContext.ModelState,
                            trueIndexes,
                            LowerModelName(displayPrefix, ".$$"));
                    }
                    cont = false;
                    break;
                }
                index++;
            }
            return(model);
        }