public static IDisposable WithAutoDIResolver(this AutoMocker mocker) { var provider = new AutoDIServiceProvider(mocker); GlobalDI.Register(provider); return(new Disposable(() => GlobalDI.Unregister(provider))); }
public MainWindow(Gtk.Application application) : base(application) { storage = GlobalDI.GetService <IDocumentsStorage>(); // Widget initialization DefaultSize = new Gdk.Size(800, 600); DeleteEvent += Window_DeleteEvent; // Init children widgets header = new Header(); Titlebar = header; container = new Norka.Widgets.Paned(Orientation.Horizontal, this); _docList = container.Sidebar.DocumentsList; _docList.SelectedRowsChanged += (sender, args) => DocumentSelected(); _docList.ItemRenamed += DocumentRename; _editor = container.Editor; Add(container); container.Sidebar.DocumentsList.RefreshItems(); var content = new Box(Orientation.Vertical, 0); content.PackStart(container, true, true, 0); Add(content); // Finally connect actins to window SetupActions(); }
static void Main(string[] args) { AutoDI.Generated.AutoDI.Init(); var quoteBoard = GlobalDI.GetService <QuoteBoard>(); quoteBoard.ShowQuotes(); System.Console.ReadLine(); }
public DocumentsList() { Hexpand = true; Vexpand = true; storage = GlobalDI.GetService <IDocumentsStorage>(); storage.DocumentAdded += (sender, args) => RefreshItems(); storage.DocumentRemoved += (sender, args) => RefreshItems(); }
public void UnregisterRemovesProvider() { var provider = new TestProvider(); GlobalDI.Register(provider); GlobalDI.Unregister(provider); Assert.IsFalse(GlobalDI.Providers.Contains(provider)); }
public void RegisterAddsProviders() { var provider1 = new TestProvider(); var provider2 = new TestProvider(); GlobalDI.Register(provider1); GlobalDI.Register(provider2); var providers = GlobalDI.Providers.ToList(); int index1 = providers.IndexOf(provider1); int index2 = providers.IndexOf(provider2); Assert.IsTrue(index1 >= 0); Assert.IsTrue(index2 >= 0); Assert.IsTrue(index1 > index2); }
public Editor(Gtk.Window parent) { Parent = parent; View = new Box(Orientation.Vertical, 0); // Load services storage = GlobalDI.GetService <IDocumentsStorage>(); // Init widgets var scrolled = new ScrolledWindow() { Expand = true }; View.StyleContext.AddClass("view"); FormatBar = new FormatBar(Orientation.Horizontal, 6); FormatRevealer = new Revealer(); FormatRevealer.Add(FormatBar); FormatRevealer.RevealChild = false; TextTagTable tagTable = new TextTagTable(); foreach (var tag in Tags) { tagTable.Add(tag.Value); } TextBuffer = new TextBuffer(tagTable); SerializeFormat = TextBuffer.RegisterSerializeTagset("text/markdown"); DeserializeFormat = TextBuffer.RegisterDeserializeTagset("text/markdown"); EditorView = new EditorView(TextBuffer); scrolled.Add(EditorView); View.PackStart(FormatRevealer, false, true, 0); View.PackEnd(scrolled, true, true, 0); }