示例#1
0
        void Subscribe(Dictionary <string, string> subs)
        {
            var sourceType = typeof(Blog);

            using (var repo = new Repo()) {
                var sources         = repo.GetActiveSources(sourceType);
                var existingSources = new Dictionary <string, Blog>();
                foreach (Blog s in sources)
                {
                    existingSources.Add(s.Url, s);
                }

                foreach (var s in subs)
                {
                    var url = s.Value;
                    if (!existingSources.ContainsKey(url))
                    {
                        var source = new Blog();
                        source.Url = url;
                        repo.Insert(source);
                        Console.WriteLine("GU: Subscribed to " + url);
                    }
                }
            }

            SourceUpdater.SetSourcesChanged();
            App.RunUI(delegate {
                App.Inst.RefreshInfo();
            });
        }
示例#2
0
        public override void ViewDidLoad()
        {
            try {
                AddLabel.Font = Theme.HugeFont;

                Source = (Source)Activator.CreateInstance(SourceType);

                AddLabel.Text = "ADD " + SourceTypes.GetTitle(SourceType);

                var y = AddLabel.Frame.Bottom + App.Inst.LabelGap;
                _form       = new Form(Source, new RectangleF(AddLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y));
                _form.OnOK += delegate {
                    try {
                        Repo.Foreground.AddOrActivateSource(Source);
                        SourceUpdater.SetSourcesChanged();
                        App.Inst.ShowSourceMessages(Source);
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };

                View.AddSubview(_form);
            } catch (Exception error) {
                Log.Error(error);
            }
        }