public DtoOutputFormatter(IDtoSerializer dtoSerializer) { _dtoSerializer = dtoSerializer; SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/json")); SupportedEncodings.Add(Encoding.UTF8); SupportedEncodings.Add(Encoding.Unicode); }
public TableWriterForSerializer(ITableReaderWriter <T> internalReaderWriter, IDtoConverter <TDto, T> converter, IDtoSerializer <TDto> serializer) { this.internalReaderWriter = internalReaderWriter; this.converter = converter; this.serializer = serializer; this.isLoaded = false; }
public ConnectionManager( ITransportResource transport, CommandBuffer commandBuffer, CommandParser commandParser, RequestsHandler requestsHandler, IDtoSerializer serializer) { _transport = transport; _commandBuffer = commandBuffer; _commandParser = commandParser; _requestsHandler = requestsHandler; _serializer = serializer; _commandBuffer.CommandAssembled += CommandBuffer_CommandAssembled; _transport.DataReceived += data => _commandBuffer.AppendBytes(data); _transport.ConnectionError += Transport_ConnectionError; }
public ApplicationManager( ITransportResource transportResource, IDtoSerializer dtoSerializer, IStorage storage, IDeviceInfo deviceInfo) { var commandParser = new CommandParser(); var connectionManager = new ConnectionManager(transportResource, new CommandBuffer(commandParser), commandParser, new RequestsHandler(), dtoSerializer); AccountManager = new AccountManager(storage, deviceInfo, connectionManager, new ProfileServiceProxy(connectionManager), new RegistrationServiceProxy(connectionManager), new AuthenticationServiceProxy(connectionManager)); ChatManager = new ChatManager(connectionManager, new ChatServiceProxy(connectionManager), AccountManager); FriendsManager = new FriendsManager(connectionManager, new FriendsServiceProxy(connectionManager)); SearchManager = new SearchManager(connectionManager, new UsersSearchServiceProxy(connectionManager)); ConnectionManager = connectionManager; }
public ApplicationManager( ITransportResource transportResource, IDtoSerializer dtoSerializer, IStorage storage, IDeviceInfo deviceInfo) { //we don't have autofac so let's build the tree var commandParser = new CommandParser(); var connectionManager = new ConnectionManager(transportResource, new CommandBuffer(commandParser), commandParser, new RequestsHandler(), dtoSerializer); AccountManager = new AccountManager(storage, deviceInfo, connectionManager, new ProfileServiceProxy(connectionManager), new RegistrationServiceProxy(connectionManager), new AuthenticationServiceProxy(connectionManager)); ChatManager = new ChatManager(connectionManager, new ChatServiceProxy(connectionManager), AccountManager); FriendsManager = new FriendsManager(connectionManager, new FriendsServiceProxy(connectionManager)); SearchManager = new SearchManager(connectionManager, new UsersSearchServiceProxy(connectionManager)); ConnectionManager = connectionManager; }
public void SizeTests() { var serializers = new IDtoSerializer[] { new ProtobufDtoSerializer(), new ZippedProtobufDtoSerializer(), new XmlDtoSerializer(), new JsonDtoSerializer(), new ProtobufDtoSerializer(), new ZippedProtobufDtoSerializer(), new XmlDtoSerializer(), new JsonDtoSerializer(), }; var players = new List<UserDto>(); var messages = new List<PublicMessageDto>(); for (int i = 0; i < 30; i++) { var message = new PublicMessageDto() { AuthorName = GenerateString(5, 25), Body = GenerateString(5, 120), Role = (UserRoleEnum)_random.Next(0, 3), Timestamp = DateTime.Now.AddHours(_random.Next(0, 1000)) }; messages.Add(message); } for (int i = 0; i < 450; i++) { var dto = new UserDto { Age = _random.Next(13, 40), Country = GenerateString(5, 15), GamesCount = _random.Next(1, 5000), Id = i, IsDevoiced = _random.Next(0, 2) == 1, Name = GenerateString(5, 25), PhotoId = _random.Next(1, 15000), Role = (UserRoleEnum)_random.Next(0, 3), Sex = _random.Next(0, 2) == 1, VictoriesCount = _random.Next(1, 2000), Xp = _random.Next(1, 15000) }; players.Add(dto); } string result = ""; foreach (var serializer in serializers) { Stopwatch sw = new Stopwatch(); sw.Start(); var playerBytes = serializer.Serialize(players); var msgBytes = serializer.Serialize(messages); sw.Stop(); result += string.Format("{0}: {1} in {2} ms;\r\n", serializer.GetType().Name, StringExtensions.ToShortSizeInBytesString(playerBytes.Length /* 450*/ + msgBytes.Length /** 40*/), sw.ElapsedMilliseconds); } }
public CommandBuilder(IDtoSerializer dtoSerializer, IUserIdProvider userIdprovider) { _dtoSerializer = dtoSerializer; _userIdprovider = userIdprovider; }