public UdpBridge(IPEndPoint host) { _host = host; _serializer = new BinaryFormatterSerializer <Message>(); _socket = new UdpSocket(); _socket.MaxPayloadSizeBytes = 2048; }
public void SetUp() { Logger.Debug("Setting up test..."); _barrier.Reset(); _exceptions.Clear(); var serializer = new BinaryFormatterSerializer <TestCollection>(); _server = new NamedPipeServer <TestCollection>(PipeName, serializer); _client = new NamedPipeClient <TestCollection>(PipeName, serializer); _expectedData = null; _expectedHash = 0; _actualData = null; _actualHash = 0; _clientDisconnected = false; _server.ClientMessage += ServerOnClientMessage; _server.Error += OnError; _client.Error += OnError; _server.Start(); _client.Start(); // Give the client and server a few seconds to connect before sending data Thread.Sleep(TimeSpan.FromSeconds(1)); Logger.Debug("Client and server started"); Logger.Debug("---"); _startTime = DateTime.Now; }
public BinaryFormatterFixture() { Serializer = new BinaryFormatterSerializer(Helper.EventFactory); var services = Helper.CreateAggregateRootServices(0); var rootAggregate = UseCases.Full().AsDirtyCustomerAggregate(services); EventsFromDomain = rootAggregate.UncommitedEvents; }
public BusSettings() { TypeToTopicName = type => type.FullName; TypeToSubscriptionName = type => DefaultSubscriptionName; DefaultSubscriptionName = "default"; MaxMessagesInFlight = 10; NumberOfReceiversPerSubscription = 5; Serializer = new BinaryFormatterSerializer(); }
/// <summary> /// Initializes a new instance of the <see cref="OneFilePerItemQueue{T}" /> class. /// </summary> /// <param name="queueName">Name of the queue.</param> /// <exception cref="System.ArgumentNullException">queueName</exception> public OneFilePerItemQueue(string queueName) { if (queueName == null) { throw new ArgumentNullException("queueName"); } QueueName = queueName; Serializer = new BinaryFormatterSerializer(); DataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "GriffinFramework"); }
private void RunTest(object value, int times, bool useGZip) { var vType = value?.GetType() ?? typeof(object); var compressor = useGZip ? CompressorManager.GetByEncodingType("gzip") : null; var memStream = new RecycleMemoryStream(); var jsonSerializer = new JsonTextSerializer { Compressor = compressor }; var xmlSerializer = new XmlTextSerializer { Compressor = compressor }; var binarySerializer = new BinaryFormatterSerializer { Compressor = compressor }; var ut8JsonSerializer = new Utf8JsonTextSerializer { Compressor = compressor }; var msgPackSerializer = new MsgPackSerializer { Compressor = compressor }; var nBinarySerializer = new NBinarySerializer { Compressor = compressor }; var rawBinarySerializer = new RawBinarySerializer { Compressor = compressor }; var wBinarySerializer = new WBinarySerializer { Compressor = compressor }; var pwBinarySerializer = new PWBinarySerializer { Compressor = compressor }; Core.Log.Warning("Running Serializer Test. Use GZIP = {0}", useGZip); Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("By size:"); Core.Log.InfoBasic("\tJson Bytes Count: {0}", SerializerSizeProcess(value, vType, jsonSerializer)); Core.Log.InfoBasic("\tXml Bytes Count: {0}", SerializerSizeProcess(value, vType, xmlSerializer)); Core.Log.InfoBasic("\tBinaryFormatter Bytes Count: {0}", SerializerSizeProcess(value, vType, binarySerializer)); Core.Log.InfoBasic("\tUtf8Json Bytes Count: {0}", SerializerSizeProcess(value, vType, ut8JsonSerializer)); Core.Log.InfoBasic("\tMessagePack Bytes Count: {0}", SerializerSizeProcess(value, vType, msgPackSerializer)); Core.Log.InfoBasic("\tNBinary Bytes Count: {0}", SerializerSizeProcess(value, vType, nBinarySerializer)); Core.Log.InfoBasic("\tRawBinary Bytes Count: {0}", SerializerSizeProcess(value, vType, rawBinarySerializer)); Core.Log.InfoBasic("\tWBinary Bytes Count: {0}", SerializerSizeProcess(value, vType, wBinarySerializer)); Core.Log.InfoBasic("\tPortable WBinary Bytes Count: {0}", SerializerSizeProcess(value, vType, pwBinarySerializer)); Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("By Times: {0}", times); SerializerProcess("Json", value, vType, times, jsonSerializer, memStream); SerializerProcess("Utf8Json", value, vType, times, ut8JsonSerializer, memStream); SerializerProcess("NBinary", value, vType, times, nBinarySerializer, memStream); SerializerProcess("RawBinary", value, vType, times, rawBinarySerializer, memStream); SerializerProcess("WBinary", value, vType, times, wBinarySerializer, memStream); SerializerProcess("PWBinary", value, vType, times, pwBinarySerializer, memStream); Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the <see cref="PersistentQueueConfiguration"/> class. /// </summary> /// <param name="queueName">Name of the queue.</param> /// <exception cref="System.ArgumentNullException">queueName</exception> public PersistentQueueConfiguration(string queueName) { if (queueName == null) { throw new ArgumentNullException("queueName"); } QueueName = queueName; Serializer = new BinaryFormatterSerializer(); MaxCount = 100; DataDirectory = Path.GetTempPath(); }
/// <summary> /// Initializes a new instance of the <see cref="BusSettings"/> class. /// </summary> public BusSettings() { EndpointName = Environment.MachineName; ApplicationName = "app"; MaxMessagesInFlight = 10; NumberOfReceiversPerSubscription = 5; TopicNameResolver = t => t.FullName.Replace("[]", "_Array").Right(50); Serializer = new BinaryFormatterSerializer(); Logger = new BitBucketLogger(); RenewalThreshold = 0.5f; MaxDeliveryCount = 5; LockDuration = TimeSpan.FromSeconds(60); ThrowOnOversizeMessage = true; CompressMessages = true; }
private void WaitForConnection(string pipeName, PipeSecurity pipeSecurity) { NamedPipeServerStream handshakePipe = null; NamedPipeServerStream dataPipe = null; NamedPipeConnection <TRead, TWrite> connection = null; var connectionPipeName = GetNextConnectionPipeName(pipeName); try { // Send the client the name of the data pipe to use handshakePipe = PipeServerFactory.CreateAndConnectPipe(pipeName, pipeSecurity); var stringSerializer = new BinaryFormatterSerializer <string>(); var handshakeWrapper = new PipeStreamWrapper <string, string>(handshakePipe, stringSerializer, stringSerializer); handshakeWrapper.WriteObject(connectionPipeName); handshakeWrapper.WaitForPipeDrain(); handshakeWrapper.Close(); // Wait for the client to connect to the data pipe dataPipe = PipeServerFactory.CreatePipe(connectionPipeName, pipeSecurity); dataPipe.WaitForConnection(); // Add the client's connection to the list of connections connection = ConnectionFactory.CreateConnection <TRead, TWrite>(dataPipe, this.deserializer, this.serializer); connection.ReceiveMessage += ClientOnReceiveMessage; connection.Disconnected += ClientOnDisconnected; connection.Error += ConnectionOnError; connection.Open(); lock (_connections) { _connections.Add(connection); } ClientOnConnected(connection); } // Catch the IOException that is raised if the pipe is broken or disconnected. catch (Exception e) { Console.Error.WriteLine("Named pipe is broken or disconnected: {0}", e); Cleanup(handshakePipe); Cleanup(dataPipe); ClientOnDisconnected(connection); } }
public void TesMessagesSerializeAndDeserialize() { var serializer = new BinaryFormatterSerializer(); CheckSerialization(serializer, new Message()); const string notEmptyString = "test"; CheckSerialization(serializer, new CreateObjectOfTypeCommand { AssemblyPath = notEmptyString, TypeFullName = notEmptyString }); CheckSerialization(serializer, new MethodCallCommand { MethodName = notEmptyString, Arguments = new object[0], MethodId = Guid.NewGuid().ToString() }); CheckSerialization(serializer, new MethodCallResultAnswer()); CheckSerialization(serializer, new UnexpectedExceptionMessage()); CheckSerialization(serializer, new SubscribeToEventCommand()); CheckSerialization(serializer, new UnsubscribeFromEventCommand()); CheckSerialization(serializer, new EventInvokeCommand()); }
public GenericConsumer() { _serializer = new BinaryFormatterSerializer <T>(); _serverStates = new Dictionary <ITcpSocket, GenericState>(); }
public void Setup() { Core.InitDefaults(); var sTest = new STest { FirstName = "Daniel", LastName = "Redondo", Age = 35, value = 166 }; _data = new List <STest> { sTest, sTest, sTest, sTest, sTest, sTest, sTest, sTest, sTest, sTest, sTest, sTest, new STest { FirstName = "Person", LastName = "Person" + "." + 0, Age = 1, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 1, Age = 2, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 2, Age = 3, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 3, Age = 4, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 4, Age = 5, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 5, Age = 6, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 6, Age = 7, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 7, Age = 8, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 8, Age = 9, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 9, Age = 10, Brother = sTest }, new STest { FirstName = "Person", LastName = "Person" + "." + 10, Age = 11 }, new STest { FirstName = "Person", LastName = "Person" + "." + 11, Age = 12 }, new STest { FirstName = "Person", LastName = "Person" + "." + 12, Age = 13 }, new STest { FirstName = "Person", LastName = "Person" + "." + 13, Age = 14 }, new STest { FirstName = "Person", LastName = "Person" + "." + 14, Age = 15 }, new STest { FirstName = "Person", LastName = "Person" + "." + 15, Age = 16 }, new STest { FirstName = "Person", LastName = "Person" + "." + 16, Age = 17 }, new STest { FirstName = "Person", LastName = "Person" + "." + 17, Age = 18 }, new STest { FirstName = "Person", LastName = "Person" + "." + 18, Age = 19 }, }; _jsonSerializer = new JsonTextSerializer(); _binData = _jsonSerializer.Serialize(_data); _jsonSerializerStream = new MemoryStream(); _jsonSerializer.Serialize(_data, _jsonSerializerStream); _xmlSerializer = new XmlTextSerializer(); _binData = _xmlSerializer.Serialize(_data); _xmlSerializerStream = new MemoryStream(); _xmlSerializer.Serialize(_data, _xmlSerializerStream); _binSerializer = new BinaryFormatterSerializer(); _binData = _binSerializer.Serialize(_data); _binSerializerStream = new MemoryStream(); _binSerializer.Serialize(_data, _binSerializerStream); _utf8jsonSerializer = new Utf8JsonTextSerializer(); _binData = _utf8jsonSerializer.Serialize(_data); _utf8jsonSerializerStream = new MemoryStream(); _utf8jsonSerializer.Serialize(_data, _utf8jsonSerializerStream); _msgPackSerializer = new MsgPackSerializer(); _binData = _msgPackSerializer.Serialize(_data); _msgPackSerializerStream = new MemoryStream(); _msgPackSerializer.Serialize(_data, _msgPackSerializerStream); _nBinary = new NBinarySerializer(); _binData = _nBinary.Serialize(_data); _nBinaryStream = new MemoryStream(); _nBinary.Serialize(_data, _nBinaryStream); _rawBinary = new RawBinarySerializer(); _binData = _rawBinary.Serialize(_data); _rawBinaryStream = new MemoryStream(); _rawBinary.Serialize(_data, _rawBinaryStream); }