Пример #1
0
        /// <summary>
        /// Gets the proxies info a-sync.
        /// </summary>
        /// <param name="proxyWrappers">The proxy wrappers.</param>
        /// <returns></returns>
        private static Task <VisualRxInitResult> GetProxiesInfoAsync(VisualRxProxyWrapper[] proxyWrappers)
        {
            return(Task.Factory.StartNew(() =>
            {
                var info = new VisualRxInitResult();
                foreach (VisualRxProxyWrapper proxy in proxyWrappers)
                {
                    var proxyInfo = info.Add(proxy);
                    try
                    {
                        string initInfo = proxy.Initialize();
                        proxyInfo.InitInfo = initInfo;
                    }
                    #region Exception Handling

                    catch (Exception ex)
                    {
                        proxyInfo.Error = ex;
                    }

                    #endregion Exception Handling
                }

                return info;
            }));
        }
Пример #2
0
        /// <summary>
        /// Initializes by code.
        /// </summary>
        /// <param name="proxies">proxies that will publish the monitor</param>
        /// <returns>Monitor proxies plug-in load information</returns>
        public static Task <VisualRxInitResult> Initialize(
            params IVisualRxProxy[] proxies)
        {
            #region Validation

            if (proxies == null)
            {
                var result = new VisualRxInitResult();
                return(Task.FromResult <VisualRxInitResult>(result));
            }

            #endregion // Validation

            VisualRxProxyWrapper[] proxyWrappers = (from p in proxies
                                                    select new VisualRxProxyWrapper(p)).ToArray();

            lock (_syncProxies)
            {
                Proxies = proxyWrappers;
            }

            return(GetProxiesInfoAsync(proxyWrappers));
        }