示例#1
0
        public static void PushValues(IConfigStore store)
        {
            ModuleProc PROC = new ModuleProc("ConfigStoreManager", "ModifyValue");

            try
            {
                ConfigStoreManager manager = GetManager(store, true);
                if (manager != null)
                {
                    IConfigStore storeSaved = manager.Store;
                    if (Object.ReferenceEquals(store, storeSaved))
                    {
                        manager.SetPropertyValues();
                    }
                    else
                    {
                        manager.SetPropertyValues(store);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
        private void cboImplementations_SelectedIndexChanged(object sender, EventArgs e)
        {
            ModuleProc PROC = new ModuleProc("", "Method");

            try
            {
                if (cboImplementations.SelectedIndex != -1)
                {
                    if (lvwProcesses.SelectedItems.Count > 0)
                    {
                        ComboItem  item            = lvwProcesses.SelectedItems[0].Tag as ComboItem;
                        ComboItem2 configStoreImpl = cboImplementations.SelectedItem as ComboItem2;
                        //_store = _domain.CreateInstanceAndUnwrap(item.AsmName.FullName, configStoreImpl) as ConfigStore;
                        _store = Activator.CreateInstance(configStoreImpl.Value, true) as ConfigStore;
                        ConfigStoreManager.PullValues(_store);
                        propData.SelectedObject = _store;
                        btnSave.Enabled         = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
示例#3
0
        public ConfigStoreResponse SendMessage(ConfigStoreRequest request)
        {
            ModuleProc          PROC     = new ModuleProc(this.DYN_MODULE_NAME, "SendMessage");
            ConfigStoreResponse response = new ConfigStoreResponse();

            try
            {
                ConfigStoreManager.PushValues(request.Request);
                response.Response = true;
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(response);
        }
示例#4
0
        public static void PushValue(IConfigStore store, string propertyName, object value)
        {
            ModuleProc PROC = new ModuleProc("ConfigStoreManager", "ModifyValue");

            try
            {
                ConfigStoreManager manager = GetManager(store);
                if (manager != null)
                {
                    manager.SetPropertyValue(propertyName, value);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
示例#5
0
        private static Type RegisterInternal(Type typeOfT)
        {
            ModuleProc PROC = new ModuleProc("ConfigStoreManager", "Register");

            try
            {
                if (!_configStores.ContainsKey(typeOfT))
                {
                    IConfigStore       instance = Activator.CreateInstance(typeOfT, true) as IConfigStore;
                    ConfigStoreManager manager  = new ConfigStoreManager(instance);
                    _configStores.Add(typeOfT, manager);
                    return(typeOfT);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(null);
        }
 public void Reload()
 {
     ConfigStoreManager.GetPropertyValues(this);
 }
示例#7
0
        public bool Start()
        {
            ModuleProc PROC   = new ModuleProc(this.DYN_MODULE_NAME, "Start");
            bool       result = false;

            try
            {
                if (_host == null)
                {
                    lock (_lock)
                    {
                        if (_host == null)
                        {
                            // Host
                            string hostName = Dns.GetHostName();

                            // Add the base address
                            Type serviceType = typeof(ConfigStoreService);

                            Uri pipeUri = new Uri(ConfigStoreManager.GetPipeName(Process.GetCurrentProcess().Id));
                            Log.Info(PROC, pipeUri.AbsoluteUri);

                            // default servuce
                            if (true)
                            {
                                _host = new WcfServiceHost(serviceType, null, new Uri[] { pipeUri });
                                Type[] interfaces = serviceType.GetInterfaces();
                                string serviceContractAttrString = typeof(ServiceContractAttribute).ToString();
                                if (interfaces != null)
                                {
                                    foreach (Type iface in interfaces)
                                    {
                                        ServiceContractAttribute serviceContractAttr = (from c in iface.GetCustomAttributes(false)
                                                                                        where c.ToString() == serviceContractAttrString
                                                                                        select c).FirstOrDefault() as ServiceContractAttribute;
                                        if (serviceContractAttr != null)
                                        {
                                            // named pipe
                                            _host.AddServiceEndpoint(iface, CreateNamedPipeBinding(),
                                                                     pipeUri);
                                        }
                                    }
                                }
                            }

                            // Mex endpoings
                            _host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexNamedPipeBinding(),
                                                     "mex");
                            Log.Info(PROC, pipeUri.AbsoluteUri + "/mex");
                        }
                    }
                }

                // default service host
                try
                {
                    if (_host != null &&
                        _host.State == CommunicationState.Created)
                    {
                        _host.Open();
                        result = true;
                    }
                }
                catch (Exception ex)
                {
                    Log.Exception(PROC, ex);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
示例#8
0
 public ConfigStoreServiceProxy(int processId)
     : base(ConfigStoreServiceHostFactory.CreateNamedPipeBinding(), ConfigStoreManager.GetPipeName(processId))
 {
 }