private static List <XElement> RunProvider(XElement config, IInfoProvider provider) { List <XElement> result = new List <XElement>(); DateTime endTime = DateTime.Now.AddMinutes(double.Parse(ConfigurationManager.AppSettings["TskMgrMinutesTotal"])); while (DateTime.Now < endTime) { Tools.WriteLine($"{nameof(TskMgrDataTask)}: Collecting info (until {endTime.ToString("dd-MM-yyyy HH:mm:ss")})..."); var info = provider.ProvideInfo(config); if (info != null) { result.Add(new XElement(provider.GetType().Name, new XAttribute("Date", DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss")), info)); } if (DateTime.Now < endTime) { Tools.WriteLine($"{nameof(TskMgrDataTask)}: Info collected. Going to sleep for {int.Parse(ConfigurationManager.AppSettings["TskMgrMinutesInterval"])} minutes"); System.Threading.Thread.Sleep(1000 * 60 * int.Parse(ConfigurationManager.AppSettings["TskMgrMinutesInterval"])); } } return(result); }
public string GetValue(string username, string password) { Type asstype = this.PluginAssembly.GetType("MainClass"); IInfoProvider i = (IInfoProvider)Activator.CreateInstance(asstype); return(i.GetValue()); }
protected IEnumerable <PanelViewContainer> GetListeners(IInfoProvider provider) { List <PanelViewContainer> views; if (!providerToViewMap.TryGetValue(provider, out views)) { return(Enumerable.Empty <PanelViewContainer>()); } return(views.Where(c => !c.Pinned)); }
public string GetValue() { if (valid) { Type asstype = PluginAssembly.GetType("MainClass"); IInfoProvider i = (IInfoProvider)Activator.CreateInstance(asstype); return(laststring = i.GetValue(username, password)); } return("Плагин неправильный"); }
private Task <T> InvokeAsync <T>(IInfoProvider provider, Func <T> func) { if (provider is IDispatcherObject dispatcherObject) { return(dispatcherObject.Dispatcher.InvokeAsync(func)); } else { return(Task.Run(func)); } }
private void Invoke(IInfoProvider provider, Action action) { if (provider is IDispatcherObject dispatcherObject) { dispatcherObject.Dispatcher.Invoke(action); } else { action(); } }
private T Invoke <T>(IInfoProvider provider, Func <T> func) { if (provider is IDispatcherObject dispatcherObject) { return(dispatcherObject.Dispatcher.Invoke(func)); } else { return(func()); } }
public override string ToString() { IInfoProvider infovalue = m_value as IInfoProvider; if (infovalue != null) { return(infovalue.Info); } else { return("Not defined: " + m_value.GetType().ToString()); } }
public static IEnumerable <object> GetInfos(this IInfoProvider provider) { foreach (var entry in provider.InfoMetadata) { if (provider.TryGetInfo(entry.Name, out var value)) { yield return(value); } else { yield return(null); } } }
public static UiDataProviderNode Create <T>(InfoProviderGroup <T> providers) where T : class { UiContextMenu menu = UiContextMenuFactory.Create(); for (int index = 0; index < providers.Count; index++) { IInfoProvider <T> provider = providers[index]; UiMenuItem menuItem = UiMenuItemFactory.Create(provider.Title, new UiDataProviderNodeRefreshCommand(() => providers.Refresh(provider))); menuItem.ToolTip = provider.Description; menu.AddChild(menuItem); } UiDataProviderNode node = new UiDataProviderNode(providers.Title, providers.Description, menu); providers.InfoLost += node.OnInfoLost; providers.InfoProvided += node.OnInfoProvided; return(node); }
public void SetInfoProvider(IInfoProvider provider) { if (this.currentInfoProvider == provider) { return; } this.currentInfoProvider = provider; if (!providerToViewMap.ContainsKey(provider)) { var views = PanelViewFactory.CreateAll(provider.InfoWidgets) .Select(v => PanelViewContainer.Wrap(v)) .ToList(); views.ForEach(v => v.Unpinned += OnContainerUnpinned); views.ForEach(v => v.InfoProvider = provider); views.ForEach(v => (v.Widget as IPanelView)?.Refresh()); providerToViewMap.Add(provider, views); } var childrenToRemove = content.Children.Where(v => !(v as PanelViewContainer).Pinned); foreach (var child in childrenToRemove) { content.Remove(child); } List <PanelViewContainer> newViews; if (!providerToViewMap.TryGetValue(provider, out newViews)) { return; } foreach (var viewContainer in newViews) { bool alreadyOnPanel = viewContainer.Pinned; if (!alreadyOnPanel) { content.Add(viewContainer); content.SetChildPacking(viewContainer, false, false, 0, PackType.Start); viewContainer.Visible = viewContainer.VisibleOnPanel; } } UpdatePanelVisibility(); }
public void OnInfoProviderDisposed(IInfoProvider provider) { List <PanelViewContainer> views; if (providerToViewMap.TryGetValue(provider, out views)) { foreach (var view in views) { view.InfoProvider = null; } foreach (var view in views.Where(c => !c.Pinned)) { content.Remove(view); view.Widget?.Destroy(); view.Dispose(); } providerToViewMap.Remove(provider); } }
public T Refresh(IInfoProvider <T> provider) { lock (_lock) { ClearValue(); T result = provider.Provide(); if (Count == 0) { Add(provider); } else if (this[0] != provider) { Remove(provider); Insert(0, provider); } return(SetValue(result)); } }
public TemplateServiceImpl(DataContext dc, IInfoProvider ip) : base(dc, ip) { }
public TemplateService(IInfoProvider infoProvider) : base(infoProvider) { Impl = new TemplateServiceImpl(this.DataContext, this.InfoProvider); }
public static IServiceCollection AddInfo(this IServiceCollection services, IInfoProvider infoProvider) { _infoProvider = infoProvider ?? throw new ArgumentNullException(nameof(infoProvider)); return(services); }
public PartAnalyzer(IObjectFactory objectFactory, IInfoProvider infoProvider) : base(objectFactory) { _infoProvider = infoProvider; }
public static void RegisterExternalInfoProvider(IInfoProvider provider) { infoProviderList.Add(provider); }
public FormHostServiceFacade(IInfoProvider ip) { this.DataContext = new DataContext(); this.InfoProvider = ip; }
public FormHostService(DataContext dc, IInfoProvider ip) { this.DataContext = dc; this.InfoProvider = ip; }
public TurboFactory(IObjectFactory objectFactory, IInfoProvider infoProvider) { _objectFactory = objectFactory; _infoProvider = infoProvider; }
public FillServiceImpl(DataContext dc, IInfoProvider ip) : base(dc, ip) { }
public InfoHandler(IInfoProvider provider) { this.provider = provider; }
public FillService(IInfoProvider infoProvider) : base(infoProvider) { Impl = new FillServiceImpl(this.DataContext, this.InfoProvider); }