private void GetValue_Clicked(object sender, RoutedEventArgs e)
        {
            //create channel erstellt den
            var factory = new WcfFactory <IDemo>();

            ValueRead.Text = factory.Proxy.GetValue().ToString();
        }
 private void AppDomain_Clicked(object sender, RoutedEventArgs e)
 {
     using (var factory = new WcfFactory <IDemo>())
     {
         AppDomainNameServer.Text = factory.Proxy.GetApplicationDomainName();
     }
 }
        private void SetValue_Clicked(object sender, RoutedEventArgs e)
        {
            //create channel erstellt den
            var factory = new WcfFactory <IDemo>();
            var entry   = Convert.ToDouble(ValueEntry.Text);

            factory.Proxy.SetValue(entry);
        }
 private void NextEnum_Clicked(object sender, RoutedEventArgs e)
 {
     //create channel erstellt den
     using (var factory = new WcfFactory <IDemo>())
     {
         var result = factory.Proxy.NextValue(DemoEnum.Unknown);
         EnumValue.Text = Enum.GetName(typeof(DemoEnum), result);
     }
 }
        private void FillList_Clicked(object sender, RoutedEventArgs e)
        {
            var demoData = new DemoData
            {
                Data      = new byte[] { 0x99 },
                Date      = DateTime.MinValue,
                EnumValue = DemoEnum.Large,
                Id        = Guid.NewGuid(),
                Name      = "Test",
                Value     = 22d
            };

            var factory = new WcfFactory <IDemo>();
            var result  = factory.Proxy.Update(demoData, 20);

            factory.CloseProxy();

            result.ToList().ForEach(r => DetailList.Items.Add(r.Data + " " + r.Date + "  " + r.Id + " " + r.Name + " " + r.Value));
        }
 public UserServiceWrapper(IApplicationContext applicationContext)
 {
     _userClient = WcfFactory.GetWcfClient <UserClient>(applicationContext.Settings.WcfUrl);;
 }
        private async Task <LocalAgentInformation> GetOrRegisterLocalAgent(AgentConfiguration configuration, bool isInternal, bool forceRegister = false)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            foreach (var folder in configuration.DependencyFolders)
            {
                _dependencyFolders.Add(folder);
            }

            var agentId = GetAgentId(this.LocalPeerNode, configuration.Name);

            var newLazyLocal = new Lazy <LocalAgentInformation>(
                () =>
            {
                var agentType = Type.GetType(configuration.TypeName, true, true);
                var agent     = (IAgent)Activator.CreateInstance(agentType);
                agent.LoadConfiguration(agentId, configuration);

                var hostAndContracts = WcfFactory.CreateServer(agent, GetAgentUri(this.LocalPeerNode, agent.Id));
                Log.Trace().Message("Serveur WCF créé à l'adresse '{0}'.", string.Join(",", hostAndContracts.Item1.BaseAddresses.Select(uri => uri.ToString()))).WithAgent(agentId).Write();

                // start the ServiceHost
                // that should normally be done async, but we do not want to exit this function with a server that is not listening
                try
                {
                    hostAndContracts.Item1.Open();
                }
                catch (Exception ex)
                {
                    Log.Warn().Message("Opening WCF server at address '{0}' has failed.", string.Join(",", hostAndContracts.Item1.BaseAddresses.Select(uri => uri.ToString()))).Exception(ex).WithAgent(agentId).Write();
                    throw;
                }

                return(new LocalAgentInformation(this.LocalPeerNode, agentId, configuration, hostAndContracts.Item2.Select(t => t.AssemblyQualifiedName), isInternal, agent, hostAndContracts.Item1));
            }, LazyThreadSafetyMode.ExecutionAndPublication);

            Lazy <LocalAgentInformation> lazyLocal;

            if (forceRegister)
            {
                lazyLocal = _localAgents.AddOrUpdate(agentId, newLazyLocal, (id, old) => newLazyLocal);
            }
            else
            {
                lazyLocal = _localAgents.GetOrAdd(agentId, newLazyLocal);
            }

            if (!lazyLocal.IsValueCreated)
            {
                if (lazyLocal.Value.ServiceHost.State != CommunicationState.Opened)
                {
                    await Task.Factory.FromAsync(lazyLocal.Value.ServiceHost.BeginOpen, lazyLocal.Value.ServiceHost.EndOpen, null).ConfigureAwait(false);
                }

                _agentSubject.OnNext(new SerializableAgentInformation(lazyLocal.Value));
                RegisterObserver(lazyLocal.Value.Agent.StateDataSource.Subscribe(state => _agentSubject.OnNext(new SerializableAgentInformation(lazyLocal.Value))));
            }

            return(lazyLocal.Value);
        }
示例#8
0
 public TokenServiceWrapper(IApplicationContext applicationContext)
 {
     _tokenClient = WcfFactory.GetWcfClient <TokenClient>(applicationContext.Settings.WcfUrl);
 }