本文整理汇总了C#中ServiceContainer.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer.Publish方法的具体用法?C# ServiceContainer.Publish怎么用?C# ServiceContainer.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceContainer
的用法示例。
在下文中一共展示了ServiceContainer.Publish方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TagLineListForm
public TagLineListForm(IServiceProvider provider, IEnumerable<TagLineInfo> tagLines)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
if (tagLines == null)
throw new ArgumentNullException(nameof(tagLines));
_serviceManager = new ServiceContainer(provider);
_tagLines = new ObservableList<TagLineInfo>(tagLines);
InitializeComponent();
_serviceManager.Publish<ITagLineListFormService>(new TagLineListFormService(this));
_serviceManager.Publish<IDefaultCommandService>(new DefaultCommandService("Janus.Forum.TagLine.Edit"));
_toolbarGenerator = new StripMenuGenerator(_serviceManager, _toolStrip, "Forum.TagLine.Toolbar");
_contextMenuGenerator = new StripMenuGenerator(_serviceManager, _contextMenuStrip, "Forum.TagLine.ContextMenu");
_listImages.Images.Add(
_serviceManager.GetRequiredService<IStyleImageManager>()
.GetImage(@"MessageTree\Msg", StyleImageType.ConstSize));
UpdateData();
_tagLines.Changed += (sender, e) => UpdateData();
}
示例2: MessageForm
public MessageForm(
[NotNull] IServiceProvider provider,
MessageFormMode mode,
MessageInfo message)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
_serviceManager = new ServiceContainer(provider);
InitializeComponent();
_formMode = mode;
_messageInfo = message ?? new MessageInfo();
_previewSourceNum = OutboxManager.RegisterPreviewSource(this);
_serviceManager.Publish<IMessageEditorService>(
new MessageEditorService(this));
CustomInitializeComponent();
_menuGenerator = new StripMenuGenerator(_serviceManager, _menuStrip, "MessageEditor.Menu");
_toolbarGenerator = new StripMenuGenerator(_serviceManager, _toolStrip, "MessageEditor.Toolbar");
_tagsbarGenerator = new SmilesToolbarGenerator(_serviceManager, "Forum.MessageEditor.TagsBar", _tagsBar);
_syntaxExtSvc = provider.GetRequiredService<IEditorSyntaxExtensibilityService>();
}
示例3: FavoritesDummyForm
private FavoritesDummyForm(IServiceProvider provider)
{
_serviceManager = new ServiceContainer(provider);
_favManager = provider.GetRequiredService<IFavoritesManager>();
InitializeComponent();
FillImages();
CustomInitializeComponent();
_serviceManager.Publish<IFavoritesDummyFormService>(new FavoritesDummyFormService(this));
_contextMenuGenerator = new StripMenuGenerator(_serviceManager, _contextMenuStrip, "Favorites.ContextMenu");
}
示例4: WebBrowserForm
public WebBrowserForm(IServiceProvider serviceProvider)
{
var serviceManager = new ServiceContainer(serviceProvider);
_asyncOp = AsyncHelper.CreateOperation();
InitializeComponent();
serviceManager.Publish<IBrowserFormService>(new JBrowserFormService(this));
serviceManager.Publish<IActiveMessagesService>(
new JBrowserActiveMessageService(serviceManager));
//Восстановление размера и положеня формы
Bounds = Config.Instance.WebBrowserFormBounds.Bounds;
if (Config.Instance.WebBrowserFormBounds.Maximized)
WindowState = FormWindowState.Maximized;
_menuGenerator = new StripMenuGenerator(serviceManager, _menuStrip, "JBrowser.Menu");
_toolbarGenerator = new StripMenuGenerator(serviceManager, _toolStrip, "JBrowser.Toolbar");
_webBrowser.BackColor = Color.White;
//Большинство событий браузера в дизайнере не видно, поэтому добавляем вручную
_webBrowser.ProgressChanged += WebBrowserProgressChanged;
_webBrowser.Navigated += WebBrowserNavigated;
_webBrowser.StatusTextChanged += WebBrowserStatusTextChanged;
_webBrowser.DocumentTitleChanged += WebBrowserDocumentTitleChanged;
_webBrowser.CanGoBackChanged += WebBrowserCanGoBackChanged;
_webBrowser.CanGoForwardChanged += WebBrowserCanGoForwardChanged;
_webBrowser.DocumentCompleted += WebBrowserDocCompleted;
var styleImageManager = serviceManager.GetService<IStyleImageManager>();
var image = styleImageManager?.TryGetImage("jbrowser", StyleImageType.Large);
if (image != null)
Icon = image.ToIcon();
#if DEBUG
_webBrowser.ScriptErrorsSuppressed = false;
#endif
}
示例5: JanusHost
internal JanusHost(IServiceProvider serviceProvider)
{
_serviceManager =
serviceProvider == null
? new ServiceContainer(true)
: new ServiceContainer(serviceProvider, true);
// TODO: Hack! Must be eliminated.
ApplicationManager.Instance.ServiceProvider = this;
_serviceManager.Publish<IEventBroker>(new EventBroker());
InitExtensibility();
_activePartManager = ActivePartsHelper.CreateAndPublishManager(_serviceManager);
}
示例6: MainForm
public MainForm([NotNull] IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException(nameof(serviceProvider));
var serviceManager = new ServiceContainer(serviceProvider);
Features.Instance.Init();
var activeMsgSvc = new FeatureActiveMessageService();
serviceManager.Publish<IActiveMessagesService>(activeMsgSvc);
_serviceProvider = serviceManager;
InitializeComponent();
CustomInitializeComponent();
}
示例7: SearchDummyForm
public SearchDummyForm(IServiceProvider provider)
{
_asyncOperation = AsyncHelper.CreateOperation();
_serviceManager = new ServiceContainer(provider);
_serviceManager.Publish<IDefaultCommandService>(
new DefaultCommandService("Janus.Forum.GoToMessage"));
this.AssignServices(provider);
InitializeComponent();
_msgViewer = new MsgViewer(_serviceManager) { Dock = DockStyle.Fill };
_splitContainer.Panel2.Controls.Add(_msgViewer);
CustomInitializeComponent();
}
示例8: OutboxDummyForm
public OutboxDummyForm(IServiceProvider provider, OutboxManager manager)
{
if (provider == null)
throw new ArgumentNullException(nameof(provider));
_serviceManager = new ServiceContainer(provider);
_manager = manager;
InitializeComponent();
_serviceManager.Publish<IDefaultCommandService>(
new DefaultCommandService("Janus.Outbox.EditItem"));
MessageForm.MessageSent += MessageSent;
_grid.Indent = Config.Instance.ForumDisplayConfig.GridIndent;
_grid.SmallImageList = OutboxImageManager.ImageList;
}
示例9: MsgViewer
public MsgViewer(IServiceProvider provider)
{
_serviceManager = new ServiceContainer(provider);
_serviceManager.Publish<IActiveMessagesService>(
new MessageViewerActiveMessageService(this));
this.AssignServices(_serviceManager);
InitializeComponent();
_messageBrowser.Navigating += MessageBrowserNavigating;
_messageBrowser.StatusTextChanged += MessageBrowserStatusTextChanged;
#if DEBUG
_messageBrowser.ScriptErrorsSuppressed = false;
#endif
_toolbarGenerator = new StripMenuGenerator(_serviceManager, _toolStrip, "MessageViewer.Toolbar", true);
}
示例10: NotifyIconService
public NotifyIconService([NotNull] IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException(nameof(serviceProvider));
_serviceManager = new ServiceContainer(serviceProvider);
_defaultCommandService = new DefaultCommandService("Janus.Application.ShowMainForm");
_serviceManager.Publish(_defaultCommandService);
_uiAsyncOperation = _serviceManager
.GetRequiredService<IUIShell>()
.CreateUIAsyncOperation();
_uiAsyncOperation.Send(
() =>
{
_notifyIcon = new NotifyIcon();
_notifyIcon.DoubleClick += NotifyIconDefaultAction;
_notifyIcon.BalloonTipClicked += NotifyIconDefaultAction;
Ticker.Instance.DoubleClick += NotifyIconDefaultAction;
});
}
示例11: ForumDummyForm
private ForumDummyForm(IServiceProvider provider)
{
_serviceManager = new ServiceContainer(provider);
_asyncOperation = AsyncHelper.CreateOperation();
_serviceManager.Publish<IDefaultCommandService>(
new DefaultCommandService("Janus.Forum.ReplyMessage"));
this.AssignServices(provider);
InitializeComponent();
SetPositionViewMsgArea(Config.Instance.MsgPosition);
CustomInitializeComponent();
_eventsSubscription = EventBrokerHelper.SubscribeEventHandlers(this, _serviceManager);
}
示例12: PerformSyncSession
private IStatisticsContainer PerformSyncSession(
Action<ISyncContext> syncProc,
bool activateUI)
{
var stats = new StatisticsContainer();
if (!InitStartSync())
return stats;
var svcManager = new ServiceContainer(_provider);
SyncForm syncForm = null;
var result = SyncResult.Failed;
Exception failException = null;
try
{
var context = new SyncContext(
svcManager,
stats,
// ReSharper disable AccessToModifiedClosure
() => syncForm != null && syncForm.IsCancelled);
// ReSharper restore AccessToModifiedClosure
if (_lastSyncFormInstance != null)
_uiAsyncOp.Send(_lastSyncFormInstance.Dispose);
if (Config.Instance.ShowSyncWindow)
{
_uiAsyncOp.Send(
() =>
{
syncForm =
new SyncForm(context)
{
WindowState = activateUI
? FormWindowState.Normal
: FormWindowState.Minimized
};
syncForm.Show();
});
syncForm.Closed += (sender, args) => _lastSyncFormInstance = null;
_lastSyncFormInstance = syncForm;
svcManager.Publish<ISyncProgressVisualizer>(syncForm);
svcManager.Publish<ITaskIndicatorProvider>(syncForm);
svcManager.Publish<ISyncErrorInformer>(syncForm);
}
syncProc(context);
if (!stats.IsEmpty())
_provider.LogInfo(stats.GetFormattedValues(_provider));
result = SyncResult.Finished;
}
catch (UserCancelledException ex)
{
_provider.LogWarning(SyncResources.SyncWarning.FormatWith(ex.Message));
result = SyncResult.Aborted;
}
catch (Exception ex)
{
_provider.LogError(SyncResources.SyncError.FormatWith());
result = SyncResult.Failed;
failException = ex;
}
finally
{
_isActive = false;
OnEndSync(new EndSyncEventArgs(stats, result, failException));
if (syncForm != null)
_uiAsyncOp.Send(syncForm.TryClose);
}
return stats;
}
示例13: Main
public static void Main()
{
TraceVerbose("Instance startup");
try
{
Console.WriteLine(
@"Janus project. Copyright (C) 2002-2012 by Rsdn Team. " +
@"See rsdn.ru for more information.");
// Проверка на единственность экземпляра приложения.
bool cn;
using (var m = new Mutex(true, "JanusRunningInstanceDetectionMutex", out cn))
{
if (!m.WaitOne(0, false))
{
WindowActivator.ActivateWindow(MainForm.GetCaption());
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Создаем контрол, чтобы инициализировать винформсный констекст синхронизации,
// если он еще не инициализирован
using (new Control()) { }
Thread.CurrentThread.CurrentUICulture = new CultureInfo((int)Config.Instance.UILanguage);
if (!CheckEnvironment())
return;
TraceVerbose("ResMgr");
var rootManager = new ServiceContainer(true);
rootManager.Publish<IUIShell>(
new UIShell(
() => ApplicationManager.Instance.MainForm,
freeze => ApplicationManager.Instance.MainForm.Enabled = freeze));
if (Config.Instance.ShowSplash)
{
EventHandler hider = null;
IDisposable informerCookie = null;
IDisposable progressCookie = null;
hider =
(sender, e) =>
{
progressCookie?.Dispose();
rootManager.Publish<IProgressService>(
new DefaultProgressService(rootManager));
informerCookie?.Dispose();
SplashHelper.Hide();
Application.Idle -= hider;
// ReSharper restore AccessToModifiedClosure
};
Application.Idle += hider;
informerCookie = rootManager.Publish(
SplashHelper.Show(rootManager));
progressCookie = rootManager.Publish(
SplashHelper.GetProgressService());
//Thread.Sleep(20000);
}
else
rootManager.Publish<IProgressService>(
new DefaultProgressService(rootManager));
using (var host = new JanusHost(rootManager))
{
using (host.InitScope())
{
rootManager.SetSplashMessage(SR.Splash.ApplicationStart);
TraceVerbose("JanusHost");
// Подписка сервиса на извещения об изменении конфигурации.
var configChangedNotifier = host.GetRequiredService<ConfigChangedNotifier>();
Config.Instance.ConfigChanged +=
(o, args) => configChangedNotifier.FireConfigChanged(Config.Instance);
try
{
//Проверка наличия пользователя
if (!LocalUser.UserExists())
using (var ouf = new OptionsUserForm(host, true))
ouf.ShowDialog();
rootManager.SetSplashMessage(SR.Splash.CheckDatabase);
if (!DBSchemaManager.CheckDB(host))
{
// User cancelled.
//
//.........这里部分代码省略.........