コード例 #1
0
        private void AddFile()
        {
            var createController = new GistFileAddViewController();

            createController.SaveCommand.Subscribe(_ => NavigationController.PopToViewController(this, true));
            createController.Save = (name, content) => {
                if (string.IsNullOrEmpty(name))
                {
                    //Keep trying until we get a valid filename
                    while (true)
                    {
                        name = "gistfile" + (++_gistFileCounter) + ".txt";
                        if (ViewModel.Files.ContainsKey(name))
                        {
                            continue;
                        }
                        break;
                    }
                }

                if (ViewModel.Files.ContainsKey(name))
                {
                    throw new InvalidOperationException("A filename by that type already exists");
                }
                ViewModel.Files.Add(name, content);
                ViewModel.Files = ViewModel.Files;
            };

            NavigationController.PushViewController(createController, true);
        }
コード例 #2
0
ファイル: GistCreateView.cs プロジェクト: GitWatcher/CodeHub
        private void AddFile()
        {
            var createController = new GistFileAddViewController();
            createController.SaveCommand.Subscribe(_ => NavigationController.PopToViewController(this, true));
            createController.Save = (name, content) => {
                if (string.IsNullOrEmpty(name))
                {
                    //Keep trying until we get a valid filename
                    while (true)
                    {
                        name = "gistfile" + (++_gistFileCounter) + ".txt";
                        if (ViewModel.Files.ContainsKey(name))
                            continue;
                        break;
                    }
                }

                if (ViewModel.Files.ContainsKey(name))
                    throw new InvalidOperationException("A filename by that type already exists");
                ViewModel.Files.Add(name, content);
                ViewModel.Files = ViewModel.Files;
            };

            NavigationController.PushViewController(createController, true);
        }
コード例 #3
0
        private void AddFile()
        {
            var createController = new GistFileAddViewController();

            createController.SaveCommand.Subscribe(_ => NavigationController.PopToViewController(this, true));
            createController.Save = (name, content) => {
                if (string.IsNullOrEmpty(name))
                {
                    name = GenerateName();
                }

                if (IsDuplicateName(name))
                {
                    throw new InvalidOperationException("A filename by that type already exists");
                }
                _model.Files[name] = new GistFileUpdate {
                    Content = content
                };
            };
            NavigationController.PushViewController(createController, true);
        }