예제 #1
0
        private Dictionary <Guid?, string> GetIdentityOptions(RootState state)
        {
            var identities        = state?.Settings?.Identities ?? Enumerable.Empty <IdentityViewModel>();
            var identitiesOptions = new Dictionary <Guid?, string>(identities.Count() + 1);

            identitiesOptions.Add(Guid.Empty, Constants.NoneLabel);
            foreach (var identity in identities)
            {
                identitiesOptions.Add(identity.Id, identity.Name);
            }

            return(identitiesOptions);
        }
예제 #2
0
        private IEnumerable <SelectOption <Guid> > GetIdentityOptions(RootState state)
        {
            var identities        = state?.Settings?.Identities ?? Enumerable.Empty <IdentityViewModel>();
            var identitiesOptions = new List <SelectOption <Guid> >(identities.Count() + 1);

            identitiesOptions.Add(new SelectOption <Guid>(Guid.Empty, string.Empty));

            foreach (var identity in identities)
            {
                identitiesOptions.Add(new SelectOption <Guid>(identity.Id, identity.Name));
            }

            return(identitiesOptions);
        }
예제 #3
0
        private IEnumerable <SelectOption <Guid> > GetOrganizationOptions(RootState state)
        {
            var organizations        = state?.Settings?.Organizations ?? Enumerable.Empty <OrganizationViewModel>();
            var organizationsOptions = new List <SelectOption <Guid> >(organizations.Count() + 1);

            organizationsOptions.Add(new SelectOption <Guid>(Guid.Empty, string.Empty));

            foreach (var organization in organizations)
            {
                organizationsOptions.Add(new SelectOption <Guid>(organization.Id, organization.Name));
            }

            return(organizationsOptions);
        }
예제 #4
0
        public EndlessTree(Player startPlayer = Player.Max)
        {
            A.CallTo(() => RootState.ToString()).Returns(nameof(RootState));
            A.CallTo(() => ChildState1.ToString()).Returns(nameof(ChildState1));
            A.CallTo(() => ChildState2.ToString()).Returns(nameof(ChildState2));

            A.CallTo(() => RootState.Turn).Returns(startPlayer);
            A.CallTo(() => ChildState1.Turn).Returns(startPlayer.GetReversePlayer());
            A.CallTo(() => ChildState2.Turn).Returns(startPlayer.GetReversePlayer());

            RootState.SetNeigbors(ChildState1, ChildState2);
            ChildState1.SetNeigbor(ChildState1);
            ChildState2.SetNeigbors(ChildState2);
        }
예제 #5
0
 public HttpResponseMessage GetStateFromCountry(string stateId)
 {
     try
     {
         string       restState     = System.IO.File.ReadAllText($"{AppContext.BaseDirectory}/RestJSON/states.json");
         RootState    state         = JsonConvert.DeserializeAnonymousType(restState, new RootState());
         List <State> filteredState = state.states.Where(x => x.countryId == stateId).ToList();
         return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, data = filteredState, totalStateFiltered = filteredState.Count, totalState = state.states.Count }));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new { success = false, data = ex.Message }));
     }
 }
예제 #6
0
        public void Start(int depth, bool playerTurn, int fieldSize)
        {
            if (this.GameStarted)
            {
                return;
            }

            this.GlobalDepth       = depth;
            this.PlayerTurn        = playerTurn;
            this.FieldSize         = fieldSize;
            this.CurrentState      = new RootState(fieldSize);
            this.playerStartedMark = playerTurn ? PlayerMark : ComputerMark;
            this.GameStarted       = true;
        }
예제 #7
0
 public MainViewModel(IAppReduxDispatcher appReduxDispatcher, IUpdater updater, IAppUpdater appUpdater, Func <Server, ServerViewModel> serverViewModelFactory)
 {
     logger.Info($"Welcome to AutoMasshTik v{typeof(MainViewModel).Assembly.GetName().Version}");
     this.appReduxDispatcher     = appReduxDispatcher;
     this.updater                = updater;
     this.appUpdater             = appUpdater;
     this.serverViewModelFactory = serverViewModelFactory;
     state                                 = appReduxDispatcher.InitialState;
     ServerModels                          = state.Servers;
     Servers                               = new ObservableCollection <ServerViewModel>();
     StartUpdateCommand                    = new RelayCommand <UpdateMode>(StartUpdate, m => !IsUpdating);
     StopUpdateCommand                     = new RelayCommand(StopUpdate, () => IsUpdating);
     ToggleShowPasswordCommand             = new RelayCommand(ToggleShowPassword);
     this.appReduxDispatcher.StateChanged += AppReduxDispatcher_StateChanged;
 }
예제 #8
0
        public static RootState ReceivedCurrentContainer(RootState state,
                                                         ReceivedCurrentContainerAction action)
        {
            BookmarkContainerDto?container = action.BookmarkContainer;

            container.BookmarkGroups = container.BookmarkGroups
                                       ?.SortGroups()
                                       .ToList();

            return(state with {
                CurrentContainerState = state.CurrentContainerState with {
                    Container = action.BookmarkContainer,
                    IsLoadingCurrentContainer = false,
                    ErrorMessage = null
                }
            });
        }
예제 #9
0
        /// <summary>
        /// This class contains the following tree:
        /// RootState -> Sate2 -> State3 -> EndState
        /// </summary>
        public UnaryDeterministicTree(Player rootPlayer = Player.Max)
        {
            A.CallTo(() => RootState.ToString()).Returns(nameof(RootState));
            A.CallTo(() => State2.ToString()).Returns(nameof(State2));
            A.CallTo(() => State3.ToString()).Returns(nameof(State3));
            A.CallTo(() => EndState.ToString()).Returns(nameof(EndState));

            A.CallTo(() => RootState.Turn).Returns(rootPlayer);
            A.CallTo(() => State2.Turn).Returns(rootPlayer.GetReversePlayer());
            A.CallTo(() => State3.Turn).Returns(rootPlayer);
            A.CallTo(() => EndState.Turn).Returns(rootPlayer.GetReversePlayer());

            RootState.SetNeigbor(State2);
            State2.SetNeigbor(State3);
            State3.SetNeigbor(EndState);
            EndState.SetAsEndState();
        }
예제 #10
0
        public static RootState RemoveBookmarkGroup(RootState state,
                                                    RemoveBookmarkGroupAction action)
        {
            BookmarkContainerDto?container = state.CurrentContainerState.Container;

            if (container == null)
            {
                return(state);
            }

            return(state with {
                CurrentContainerState = state.CurrentContainerState with {
                    Container = new BookmarkContainerDto(container.BookmarkContainerId,
                                                         container.Title, container.SortOrder, container.BookmarkGroups?
                                                         .Where(g => g.BookmarkGroupId != action.BookmarkGroupId)
                                                         .ToList())
                }
            });
        }
예제 #11
0
        public virtual ITableDataExporter CreateExporter(string tempPath)
        {
            var cultureName = "en-US";
            var delim       = "\t";
            var format      = DefaultFormat;

            var csvConfig = RootState.Select("export");

            if (csvConfig != null)
            {
                cultureName = csvConfig.TryGet("culture", cultureName);
                delim       = csvConfig.TryGet("delim", delim);
                format      = csvConfig.TryGet("format", format);
            }

            return(new CsvExporter(tempPath, delim, CultureInfo.GetCultureInfo(cultureName),
                                   binaryPartitions: format.HasFlag(OutputFormat.BinaryPartitions), binaryOutput: format.HasFlag(OutputFormat.Binary),
                                   keepOutput: !format.HasFlag(OutputFormat.Binary)));
        }
예제 #12
0
        public IList <TableData> Load(string tempPath)
        {
            var cultureName = "en-US";
            var delim       = "\t";

            var csvConfig = RootState.Select("export");

            if (csvConfig != null)
            {
                cultureName = csvConfig.TryGet("culture", cultureName);
                delim       = csvConfig.TryGet("delim", delim);
            }

            var schemas = TableDataHelpers.Deserialize(File.ReadAllText(Path.Combine(tempPath, "Schema.json")));

            return
                (schemas.Select(
                     s =>
                     (TableData) new CsvTableData(s, Path.Combine(tempPath, s.Name + ".txt"), delim,
                                                  CultureInfo.GetCultureInfo(cultureName))).ToList());
        }
예제 #13
0
 private void AppReduxDispatcher_StateChanged(object sender, StateChangedEventArgs <RootState> e)
 {
     isUpdatingState = true;
     try
     {
         state        = e.State;
         ServerModels = state.Servers;
         ServersText  = string.Join(Environment.NewLine, e.State.Servers.Select(s => s.Url));
         ReduxMerger.MergeList <int, Server, ServerViewModel>(state.Servers, Servers, serverViewModelFactory);
         Username            = e.State.Username;
         Password            = e.State.Password;
         IsUpdating          = e.State.IsUpdating;
         Port                = e.State.Port;
         OperationInProgress = e.State.OperationInProgress;
         ShowPassword        = state.ShowPassword;
     }
     finally
     {
         isUpdatingState = false;
     }
 }
예제 #14
0
 void UpdateReduxState(object sender, StateChangedEventArgs <RootState> e)
 {
     isUpdatingState = true;
     try
     {
         state       = e.State;
         AllChecked  = e.State.AllChecked;
         NewItemText = e.State.NewItemText;
         int itemsLeft = e.State.Items.Count(i => !i.IsChecked);
         ItemsLeftInfo = $"{itemsLeft} item{(itemsLeft != 1 ? "s" : "")} left";
         ReduxMerger.MergeList <int, TodoItem, TodoItemViewModel>(e.State.FilteredItems, Items, i => todoItemViewModelFactory(i));
         Filter = e.State.Filter;
         AddItemCommand.RaiseCanExecuteChanged();
         RemoveCompletedCommand.RaiseCanExecuteChanged();
         SetFilterCommand.RaiseCanExecuteChanged();
     }
     finally
     {
         isUpdatingState = false;
     }
 }
예제 #15
0
        public DeterministicTree(Player startPlayer = Player.Max)
        {
            A.CallTo(() => EndState1.ToString()).Returns(nameof(EndState1));
            A.CallTo(() => EndState2.ToString()).Returns(nameof(EndState2));
            A.CallTo(() => EndState3.ToString()).Returns(nameof(EndState3));
            A.CallTo(() => RootState.ToString()).Returns(nameof(RootState));
            A.CallTo(() => ChildState1.ToString()).Returns(nameof(ChildState1));
            A.CallTo(() => ChildState2.ToString()).Returns(nameof(ChildState2));

            A.CallTo(() => EndState1.Turn).Returns(startPlayer);
            A.CallTo(() => EndState2.Turn).Returns(startPlayer);
            A.CallTo(() => EndState3.Turn).Returns(startPlayer);
            A.CallTo(() => RootState.Turn).Returns(startPlayer);
            A.CallTo(() => ChildState1.Turn).Returns(startPlayer.GetReversePlayer());
            A.CallTo(() => ChildState2.Turn).Returns(startPlayer.GetReversePlayer());

            RootState.SetNeigbors(ChildState1, ChildState2);
            ChildState1.SetNeigbor(EndState1);
            ChildState2.SetNeigbors(EndState2, EndState3);
            EndState1.SetAsEndState();
            EndState2.SetAsEndState();
            EndState3.SetAsEndState();
        }
예제 #16
0
        public virtual void Initialize(Job job)
        {
            try
            {
                Database = Database.GetDatabase(job.ExecutionSettings.DatabaseName);
            }
            catch (Exception ex) { Log.Error("Error initializing database", ex, this); }

            job.JobEnded += (sender, args) =>
            {
                var export = RootState.Select("export");
                if (export != null)
                {
                    var ping = export.TryGet <string>("ping");
                    if (!string.IsNullOrEmpty(ping))
                    {
                        new WebClient().DownloadString(
                            ping.Replace("{id}", job.Id.ToString("D"))
                            .Replace("{status}", Enum.GetName(typeof(JobStatus), job.Status)));
                    }
                }
            };
        }
예제 #17
0
        public static RootState RemoveBookmark(RootState state, RemoveBookmarkAction action)
        {
            BookmarkContainerDto?container = state.CurrentContainerState.Container;

            if (container == null)
            {
                return(state);
            }

            List <BookmarkGroupDto>?groups = container.BookmarkGroups
                                             ?.Select(bg => new BookmarkGroupDto(bg.BookmarkGroupId, bg.Title, bg.Color,
                                                                                 bg.SortOrder, bg.BookmarkContainerId, bg.Bookmarks
                                                                                 ?.Where(b => b.BookmarkId != action.BookmarkId)
                                                                                 .ToList()))
                                             .ToList();

            return(state with {
                CurrentContainerState = state.CurrentContainerState with {
                    Container = new BookmarkContainerDto(container.BookmarkContainerId,
                                                         container.Title, container.SortOrder, groups)
                }
            });
        }
예제 #18
0
 private IEnumerable <ReportViewModel> GetReports(RootState state)
 {
     return(state?.Reports?.Reports ?? null);
 }
예제 #19
0
 private void MapStateToProps(RootState state, ReportsListProps props)
 {
     props.Reports = GetReports(state);
 }
예제 #20
0
 private bool IsProfilesStateFetched(RootState state)
 {
     return(state?.Profiles != null);
 }
예제 #21
0
 private IEnumerable <ProfileViewModel> GetProfiles(RootState state)
 {
     return(state?.Profiles?.Profiles ?? Enumerable.Empty <ProfileViewModel>());
 }
예제 #22
0
 private GenerateReportViewModel GetForm(RootState state)
 {
     return(state?.GenerateReportForm?.Form);
 }
예제 #23
0
 private IEnumerable <ReporterDescriptorViewModel> GetReportTypes(RootState state)
 {
     return(state?.GenerateReportForm?.ReportTypes ?? Enumerable.Empty <ReporterDescriptorViewModel>());
 }
예제 #24
0
 private bool IsReportTypesStateFetched(RootState state)
 {
     return(state?.GenerateReportForm?.ReportTypes != null);
 }
 private VstsDataSourceViewModel GetVstsDataSource(RootState state)
 {
     return(state?.Settings?.DataSource);
 }
 private bool IsIdentityOptionsInitialized(RootState state)
 {
     return(state?.Settings?.Identities != null);
 }
 private void MapStateToProp(RootState state, VstsConfigurationSettingsProps props)
 {
     props.VstsDataSource    = GetVstsDataSource(state);
     props.IdentitiesOptions = GetIdentityOptions(state);
 }
예제 #28
0
 private bool IsReportsSstateInitialized(RootState state)
 {
     return(state?.Reports?.Reports != null);
 }
예제 #29
0
 //constructor
 public IdleState(RootState root)
 {
     rootState     = root;
     m_childStates = new List <StateNode>();
 }
예제 #30
0
 public static RootState ShowSidebar(RootState state)
 {
     return(state with {
         ShowSidebar = true
     });
 }