Пример #1
0
        /// <summary>
        /// Creates an EloquentObjects server with ability to specify custom settings and dependencies.
        /// </summary>
        /// <param name="address">Address of the server that hosts object. Can be prefixed with 'tcp://' for TCP binding or 'pipe://' for Named Pipes binding</param>
        /// <param name="settings">Custom settings</param>
        /// <param name="serializerFactory">Factory that can create serializer to be used for serializing/deserializing data sent between server and client</param>
        public EloquentServer(string address, EloquentSettings settings, [CanBeNull] ISerializerFactory serializerFactory = null)
        {
            _serializerFactory = serializerFactory ?? new DefaultSerializerFactory();

            var uri = new Uri(address);

            var scheme = uri.GetComponents(UriComponents.Scheme, UriFormat.Unescaped);

            var binding = new BindingFactory().Create(scheme, settings);

            var serverHostAddress = HostAddress.CreateFromUri(uri);

            _contractDescriptionFactory = new CachedContractDescriptionFactory(new ContractDescriptionFactory());

            try
            {
                _inputChannel = binding.CreateInputChannel(serverHostAddress);
            }
            catch (Exception e)
            {
                throw new IOException("Failed creating input channel", e);
            }

            _objectsRepository = new ObjectsRepository();

            _server = new Server(binding, _inputChannel, _objectsRepository);
        }
Пример #2
0
 public CachedContractDescriptionFactory(IContractDescriptionFactory contractDescriptionFactory)
 {
     _contractDescriptionFactory = contractDescriptionFactory;
 }