예제 #1
0
        /// <summary>
        // Activate the remote interface IServiceInterface
        /// </summary>
        /// <returns>true if activated else false</returns>
        public virtual bool ActivateTheInterface()
        {
            bool activated = false;

            try
            {
                WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(typeof(IServiceInterface), StateServerConfig.RestServicesUrl, WellKnownObjectMode.SingleCall);

                if (RemotingConfiguration.ApplicationName == null)
                {
                    RemotingConfiguration.ApplicationName = "RestService";
                    RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);
                }

                callToService = (IServiceInterface)Activator.GetObject(typeof(IServiceInterface), WKSTE.ObjectUri);

                if (callToService != null)
                {
                    activated = true;
                }
            }

            catch (System.Exception ex)
            {
                StateServerAssert.Assert(ex);
            }

            return(activated);
        }
예제 #2
0
        public void SingletoneByInterface_GetTwice_SameInstances()
        {
            IServiceProvider  scopedProvider = _provider.CreateScope().ServiceProvider;
            IServiceInterface singletone1    = _provider.GetService <IServiceInterface>();
            IServiceInterface singletone2    = _provider.GetService <IServiceInterface>();
            IServiceInterface singletone3    = scopedProvider.GetService <IServiceInterface>();

            Assert.AreEqual(singletone1, singletone2);
            Assert.AreEqual(singletone2, singletone3);
        }
 // Connect to the service
 public void connect()
 {
     var binding = new NetTcpBinding();
     var endpoint = new EndpointAddress("net.tcp://localhost:9000/IGameService");
     var channelFactory = new DuplexChannelFactory<IServiceInterface>(callback, binding, endpoint);
     try
     {
         connection = channelFactory.CreateChannel();
         getCommObj().Open();
     }
     catch (Exception ex)
     {
         Trace.WriteLine("Exception on connecting to service: " + ex);
     }
 }
예제 #4
0
        // Connect to the service
        public void connect()
        {
            var binding        = new NetTcpBinding();
            var endpoint       = new EndpointAddress("net.tcp://localhost:9000/IGameService");
            var channelFactory = new DuplexChannelFactory <IServiceInterface>(callback, binding, endpoint);

            try
            {
                connection = channelFactory.CreateChannel();
                getCommObj().Open();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Exception on connecting to service: " + ex);
            }
        }
 void InitWithFailingService()
 {
     service = new FailingServiceImplementation();
     Init();
 }
 void InitWithService()
 {
     service = new ServiceImplmentation();
     Init();
 }
 /// <summary>
 /// The dependencies are injected.
 /// </summary>
 /// <param name="asyncMethodCaller">Use TestAsyncMethodCaller for tests, AsyncMethodCaller in production.</param>
 /// <param name="service">Inject the service for easier faking and faster tests.</param>
 public ViewModel(AsyncMethodCaller asyncMethodCaller, IServiceInterface service)
 {
     this.asyncMethodCaller = asyncMethodCaller;
     this.service           = service;
 }
 public ClassWithMethodCallingMethodReturningReferenceType(IServiceInterface service)
 {
     _service = service;
 }
 public ClassUsingMethodOfInjectedService(IServiceInterface service)
 {
     _service = service;
 }
 /// <summary>
 /// The dependencies are injected.
 /// </summary>
 /// <param name="asyncMethodCaller">Use TestAsyncMethodCaller for tests, AsyncMethodCaller in production.</param>
 /// <param name="service">Inject the service for easier faking and faster tests.</param>
 public ViewModel(AsyncMethodCaller asyncMethodCaller, IServiceInterface service)
 {
     this.asyncMethodCaller = asyncMethodCaller;
     this.service = service;
 }
 void InitWithService()
 {
     service = new ServiceImplmentation();
     Init();
 }
 void InitWithFailingService()
 {
     service = new FailingServiceImplementation();
     Init();
 }
예제 #13
0
 public ClassWithMethodCallingMethodReturningBoolean(IServiceInterface service)
 {
     _service = service;
 }
 public HomeController(IModelFactory modelFactory, IServiceInterface serviceInterface)
 {
     this.modelFactory     = modelFactory;
     this.serviceInterface = serviceInterface;
 }
 public ServiceDecorator1(IServiceInterface wrapped)
 {
     this.wrapped = wrapped;
 }
예제 #16
0
 public ServiceDecorator2(IServiceInterface wrapped, int aParam)
 {
     this.wrapped = wrapped;
     this.aParam  = aParam;
 }