Пример #1
0
        public ClientDictionary(string uri, IEnumerable<string> clients)
        {
            var syncContext = new TestSynchronizationContext();
            foreach (var clientLogin in clients)
            {
                var client = new ChatHubProxy(new HubConnection(uri), syncContext);

                _clients[clientLogin] = client;
            }
        }
Пример #2
0
        private static CompositionContainer ConfigureContainer()
        {
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof (Program).Assembly));

            var container = new CompositionContainer(catalog, CompositionOptions.DisableSilentRejection);

            if(SynchronizationContext.Current == null)
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

            var hubProxy = new ChatHubProxy(new HubConnection("http://localhost:5000"), SynchronizationContext.Current);

            container.ComposeExportedValue<IChatHubProxy>(hubProxy);

            var adapter = new MefServiceLocatorAdapter(container);

            container.ComposeExportedValue<IServiceLocator>(adapter);

            ServiceLocator.SetLocatorProvider(() => adapter);

            return container;
        }