private static void Initialize()
        {
            if (!_initialized)
            {
                Logger.AddInformation("initializing wcf service connection");
                var pipeFactory =
                    new ChannelFactory <IRegistryServiceContract>(
                        new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport),
                        new EndpointAddress(
                            "net.pipe://localhost/SebWindowsServiceWCF/service"));

                _sebWindowsServicePipeProxy = pipeFactory.CreateChannel();

                //Get the current sid or/and username - without the sid or username the registry entries cannot be set
                if (String.IsNullOrEmpty(_username))
                {
                    _username = GetCurrentUsername();
                }
                if (String.IsNullOrEmpty(_sid))
                {
                    _sid = GetCurrentUserSID();
                }

                if (string.IsNullOrEmpty(_sid) && string.IsNullOrEmpty(_username))
                {
                    throw new Exception("Unable to get SID & Username");
                }

                _initialized = true;
            }
        }
        private static void Initialize()
        {
            if (!_initialized)
            {
                Logger.AddInformation("initializing wcf service connection");
                var pipeFactory =
                    new ChannelFactory<IRegistryServiceContract>(
                        new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport),
                        new EndpointAddress(
                            "net.pipe://localhost/SebWindowsService"));

                _sebWindowsServicePipeProxy = pipeFactory.CreateChannel();
                
                //Get the current username - without the username the registry entries cannot be set
                if (String.IsNullOrEmpty(_username))
                {
                    _username = GetCurrentUsername();
                }

                _initialized = true;
            }
        }
Exemple #3
0
 private static void Initialize()
 {
     if (SebWindowsServiceHandler._initialized)
     {
         return;
     }
     Logger.AddInformation("initializing wcf service connection", (object)null, (Exception)null, (string)null);
     SebWindowsServiceHandler._sebWindowsServicePipeProxy = new ChannelFactory <IRegistryServiceContract>((Binding) new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport), new EndpointAddress("net.pipe://localhost/SebWindowsServiceWCF/service")).CreateChannel();
     if (string.IsNullOrEmpty(SebWindowsServiceHandler._username))
     {
         SebWindowsServiceHandler._username = SebWindowsServiceHandler.GetCurrentUsername();
     }
     if (string.IsNullOrEmpty(SebWindowsServiceHandler._sid))
     {
         SebWindowsServiceHandler._sid = SebWindowsServiceHandler.GetCurrentUserSID();
     }
     if (string.IsNullOrEmpty(SebWindowsServiceHandler._sid) && string.IsNullOrEmpty(SebWindowsServiceHandler._username))
     {
         throw new Exception("Unable to get SID & Username");
     }
     SebWindowsServiceHandler._initialized = true;
 }