Example #1
0
 public ServiceEndpoint(Binding binding, Type contractType, string address, Guid uuid)
 {
     _binding      = binding;
     _serializer   = _binding.Serializer;
     _contractType = contractType;
     _address      = address;
     _uuid         = uuid;
 }
        /// <summary>
        /// Serializes the given object to bytes
        /// </summary>
        /// <param name="object">The object to serialize</param>
        /// <returns>The bytes</returns>
        /// <seealso cref="Org.IdentityConnectors.Framework.Common.Serializer.ObjectSerializerFactory" />
        public static byte[] SerializeBinaryObject(object obj)
        {
            ObjectSerializerFactory fact = ObjectSerializerFactory.GetInstance();
            MemoryStream            mem  = new MemoryStream();
            BinaryObjectSerializer  ser  = fact.NewBinarySerializer(mem);

            ser.WriteObject(obj);
            ser.Close();
            return(mem.ToArray());
        }
Example #3
0
        private void Init(TcpClient socket, Stream stream)
        {
            _socket = socket;
            _stream = stream;
            ObjectSerializerFactory fact =
                ObjectSerializerFactory.GetInstance();

            _encoder = fact.NewBinarySerializer(_stream);
            _decoder = fact.NewBinaryDeserializer(_stream);
        }
Example #4
0
        //TODO: split RpcProxyRouter and RpcCallbackProxy
        public ClientRuntime(string address, ServiceEndpoint endpoint, bool callback = false, InstanceContext context = null, Guid customUuid = default(Guid), Type generatedProxyType = null)
        {
            _endpoint      = endpoint;
            _binding       = endpoint._binding;
            _serializer    = _binding.Serializer;
            _typeOfService = endpoint._contractType;
            _context       = context;
            if (_context != null && _context._useSynchronizationContext)
            {
                _syncContext = SynchronizationContext.Current;
            }
            _generatedProxyType = generatedProxyType;

            _address = address;

            _operations = DispatchTableFactory.GetOperations(_typeOfService);


            _uuid = EndpointMapper.CreateUuid(_address, _typeOfService);
            if (customUuid != Guid.Empty) // callback proxy
            {
                _uuid = customUuid;
            }

            var serviceContract = AttributesReader.GetServiceContract(_typeOfService);

            //TODO: null check only for duplex callback, really should always be here
            if (serviceContract != null && serviceContract.SessionMode == SessionMode.Required)
            {
                _session = Guid.NewGuid().ToString();
            }
            //TODO: allow to be initialized with pregenerated proxy
            var realProxy = new RpcRealProxy(_typeOfService, this, _endpoint, _encoder);

            _remote = realProxy.GetTransparentProxy();
            _client = RpcRequestReplyChannelFactory.CreateClient(_binding, _uuid, _address);
            foreach (var behavior in _endpoint.Behaviors)
            {
                behavior.ApplyClientBehavior(_endpoint, this);
            }
        }
Example #5
0
 private void Init(TcpClient socket, Stream stream)
 {
     _socket = socket;
     _stream = stream;
     ObjectSerializerFactory fact =
         ObjectSerializerFactory.GetInstance();
     _encoder = fact.NewBinarySerializer(_stream);
     _decoder = fact.NewBinaryDeserializer(_stream);
 }