示例#1
1
 public static ICacheAside CreatePubSubDoubleCache(IConnectionMultiplexer redisConnection, IItemSerializer itemSerializer, TimeSpan? defaultTtl = null)
 {
     var remoteCache = new RedisCache(redisConnection.GetDatabase(), itemSerializer, defaultTtl);
     return new DoubleCache(
       new SubscribingCache(new LocalCache.MemCache(defaultTtl), new RedisSubscriber(redisConnection, remoteCache, itemSerializer)),
       new PublishingCache(remoteCache, new RedisPublisher(redisConnection, itemSerializer)));
 }
示例#2
0
 public void Setup()
 {
     this.contextProvider = new InMemoryPersistenceContextProvider();
     new DataInitialization(this.contextProvider, new NullLoggerFactory()).CreateInitialData(3, true);
     this.gameConfiguration = this.contextProvider.CreateNewConfigurationContext().Get <GameConfiguration>().First();
     this.itemSerializer    = new ItemSerializer();
 }
示例#3
0
 public DiskBTree(Stream stream, bool leaveOpen, int t, IComparer <T> comparer, IItemSerializer <T> serializer)
     : base(t, comparer)
 {
     if (stream == null)
     {
         throw new ArgumentNullException(nameof(stream));
     }
     if (serializer == null)
     {
         throw new ArgumentNullException(nameof(serializer));
     }
     if (!stream.CanRead)
     {
         throw new ArgumentException("Expected a readable stream", nameof(stream));
     }
     if (!stream.CanWrite)
     {
         throw new ArgumentException("Expected a writable stream", nameof(stream));
     }
     if (!stream.CanSeek)
     {
         throw new ArgumentException("Expected a seekable stream", nameof(stream));
     }
     _stream     = stream;
     _leaveOpen  = leaveOpen;
     _serializer = serializer;
     if (_stream.Length < HeaderSize)
     {
         Init();
     }
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldView"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="player">The player.</param>
 /// <param name="itemSerializer">The item serializer.</param>
 /// <param name="appearanceSerializer">The appearance serializer.</param>
 public WorldView(IConnection connection, Player player, IItemSerializer itemSerializer, IAppearanceSerializer appearanceSerializer)
 {
     this.connection           = connection;
     this.player               = player;
     this.itemSerializer       = itemSerializer;
     this.appearanceSerializer = appearanceSerializer;
 }
示例#5
0
 public void Setup()
 {
     this.contextProvider = new InMemoryPersistenceContextProvider();
     new MUnique.OpenMU.Persistence.Initialization.DataInitialization(this.contextProvider).CreateInitialData();
     this.gameConfiguration = this.contextProvider.CreateNewConfigurationContext().Get <GameConfiguration>().First();
     this.itemSerializer    = new ItemSerializer();
 }
示例#6
0
 public static IItemSerializer <TCurrentItem> Create <TCurrentItem, TLegacyItem>(
     IItemSerializer <TLegacyItem> legacyReader,
     Func <TLegacyItem, TCurrentItem> fromLegacyConverter,
     Func <TCurrentItem, TLegacyItem> toLegacyConverter)
 {
     return(new Impl <TCurrentItem, TLegacyItem>(legacyReader, fromLegacyConverter, toLegacyConverter));
 }
 public HabitatFitnessEventsController([NotNull] IEventDataService dataService, [NotNull] IItemScoringService itemScoringService, [NotNull] IItemSerializer itemSerializer, [NotNull] IStringValueListFacetService facetService)
 {
     this.dataService        = dataService;
     this.itemSerializer     = itemSerializer;
     this.itemScoringService = itemScoringService;
     this.facetService       = facetService;
 }
示例#8
0
 public RedisSubscriber(IConnectionMultiplexer connection, ICacheAside remoteCache, IItemSerializer itemSerializer)
 {
     connection.GetSubscriber().Subscribe("cacheUpdate", CacheUpdated);
     _remoteCache    = remoteCache;
     _itemSerializer = itemSerializer;
     _clientName     = connection.ClientName;
     _knownTypes     = new ConcurrentDictionary <string, Type>();
 }
示例#9
0
 public RedisSubscriber(IConnectionMultiplexer connection, ICacheAside remoteCache, IItemSerializer itemSerializer)
 {
     connection.GetSubscriber().Subscribe("cacheUpdate", CacheUpdated);
     _remoteCache = remoteCache;
     _itemSerializer = itemSerializer;
     _clientName = connection.ClientName;
     _knownTypes = new ConcurrentDictionary<string, Type>();
 }
示例#10
0
 public Impl(IItemSerializer <TLegacyItem> legacyReader,
             Func <TLegacyItem, TCurrentItem> fromLegacyConverter,
             Func <TCurrentItem, TLegacyItem> toLegacyConverter)
 {
     LegacyReader         = legacyReader;
     _fromLegacyConverter = fromLegacyConverter;
     _toLegacyConverter   = toLegacyConverter;
 }
示例#11
0
 public RedisSubscriber(IConnectionMultiplexer connection, ICacheAside remoteCache, IItemSerializer itemSerializer)
 {
     connection.GetSubscriber().Subscribe("cacheUpdate", CacheUpdated);
     connection.GetSubscriber().Subscribe("cacheDelete", CacheDeleted);
     _remoteCache    = remoteCache;
     _itemSerializer = itemSerializer;
     _clientName     = connection.ClientName;
 }
示例#12
0
        public RedisSubscriberTests()
        {
            _subscriber     = A.Fake <ISubscriber>();
            _remoteCache    = A.Fake <ICacheAside>();
            _itemSerializer = A.Fake <IItemSerializer>();

            _connection = A.Fake <IConnectionMultiplexer>();
            A.CallTo(() => _connection.GetSubscriber(A <object> ._)).Returns(_subscriber);
        }
示例#13
0
        public RedisSubscriberTests()
        {
            _subscriber = A.Fake<ISubscriber>();
            _remoteCache = A.Fake<ICacheAside>();
            _itemSerializer = A.Fake<IItemSerializer>();

            _connection = A.Fake<IConnectionMultiplexer>();
            A.CallTo(() => _connection.GetSubscriber(A<object>._)).Returns(_subscriber);
        }
示例#14
0
 public static bool TryGet <T>(out IItemSerializer <T> serializer)
 {
     if (!Instances.TryGetValue(typeof(T), out var obj))
     {
         serializer = default;
         return(false);
     }
     serializer = (IItemSerializer <T>)obj;
     return(true);
 }
        private static ItemEditorViewModel SetupClass(IItemSerializer itemSerializer = null,
            IItemDeserializer itemDeserializer = null)
        {
            itemSerializer = itemSerializer ?? new StubIItemSerializer();
            itemDeserializer = itemDeserializer ?? new StubIItemDeserializer
            {
                Deserialize = () => new List<IItem>()
            };

            return new ItemEditorViewModel(itemSerializer, itemDeserializer);
        }
示例#16
0
        public PublisherTests()
        {
            _connection = A.Fake <IConnectionMultiplexer>();
            _serializer = A.Fake <IItemSerializer>();
            _subscriber = A.Fake <ISubscriber>();

            A.CallTo(() => _connection.GetSubscriber(null)).Returns(_subscriber);
            A.CallTo(() => _connection.ClientName).Returns("C");
            A.CallTo(() => _serializer.Serialize(A <CacheUpdateNotificationArgs> .Ignored)).Returns(new byte[] { 1 });

            publisher = new RedisPublisher(_connection, _serializer);
        }
        public ItemEditorViewModel(IItemSerializer itemSerializer, IItemDeserializer itemDeserializer)
        {
            Check.IfIsNull(itemSerializer).Throw<ArgumentNullException>(() => itemSerializer);
            Check.IfIsNull(itemDeserializer).Throw<ArgumentNullException>(() => itemDeserializer);

            this.itemSerializer = itemSerializer;
            this.itemDeserializer = itemDeserializer;

            AddNewItemCommand = new Command(AddNewItem);

            RefreshItemsList();
        }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteView"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="player">The player.</param>
 /// <param name="context">The context.</param>
 /// <param name="appearanceSerializer">The appearance serializer.</param>
 public RemoteView(IConnection connection, Player player, IGameServerContext context, IAppearanceSerializer appearanceSerializer)
     : base(connection)
 {
     this.context              = context;
     this.itemSerializer       = new ItemSerializer();
     this.connection           = connection;
     this.player               = player;
     this.PartyView            = new PartyView(connection, player);
     this.MessengerView        = new MessengerView(connection, player, context.FriendServer, appearanceSerializer);
     this.TradeView            = new TradeView(connection, player, this.itemSerializer);
     this.GuildView            = new GuildView(connection, player);
     this.WorldView            = new WorldView(connection, player, this.itemSerializer, appearanceSerializer);
     this.InventoryView        = new InventoryView(connection, player, this.itemSerializer);
     this.appearanceSerializer = appearanceSerializer;
     this.lowestClientVersion  = this.GetLowestClientVersionOfConfiguration();
 }
示例#19
0
 public RedisPublisher(IConnectionMultiplexer connection, IItemSerializer itemSerializer)
 {
     _connection = connection;
     _itemSerializer = itemSerializer;
 }
示例#20
0
 /// <summary>
 /// Create a new instance of the <see cref="saveDataBuilder"/> class.
 /// </summary>
 /// <param name="itemSerializer">The <see cref="IItemSerializer"/> instance to (de-)serialize <see cref="Item"/> instances.</param>
 public SaveDataBuilder(IItemSerializer itemSerializer)
 {
     this.itemSerializer = itemSerializer;
 }
示例#21
0
 private static void AssignTo(this QuestReward questReward, Network.Packets.ServerToClient.QuestReward rewardStruct, IItemSerializer itemSerializer)
 {
     rewardStruct.Type        = questReward.RewardType.Convert();
     rewardStruct.RewardCount = (uint)questReward.Value;
     if (questReward.RewardType == QuestRewardType.Item && questReward.ItemReward is { } itemReward)
     {
         rewardStruct.RewardId = itemReward.Definition.GetItemType();
         itemSerializer.SerializeItem(rewardStruct.RewardedItemData, itemReward);
     }
 }
示例#22
0
 public RedisPublisher(IConnectionMultiplexer connection, IItemSerializer itemSerializer)
 {
     _connection     = connection;
     _itemSerializer = itemSerializer;
 }
示例#23
0
 public DiskBTree(Stream stream, int t, IItemSerializer <T> serializer)
     : this(stream, false, t, Comparer <T> .Default, serializer)
 {
 }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TradeView"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="trader">The trader.</param>
 /// <param name="itemSerializer">The item serializer.</param>
 public TradeView(IConnection connection, ITrader trader, IItemSerializer itemSerializer)
 {
     this.connection     = connection;
     this.trader         = trader;
     this.itemSerializer = itemSerializer;
 }
示例#25
0
 public DiskBTree(string fileName, int t, IComparer <T> comparer, IItemSerializer <T> serializer)
     : this(File.Open(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite), t, comparer, serializer)
 {
 }
示例#26
0
 public CachingDiskBTree(Stream stream, bool leaveOpen, int t, IComparer <T> comparer, IItemSerializer <T> serializer, long memoryLimit)
     : base(stream, leaveOpen, t, comparer, serializer)
 {
     _cache = new BTreeCache(memoryLimit);
 }
示例#27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InventoryView"/> class.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="player">The player.</param>
 /// <param name="itemSerializer">The item serializer.</param>
 public InventoryView(IConnection connection, Player player, IItemSerializer itemSerializer)
 {
     this.connection     = connection;
     this.player         = player;
     this.itemSerializer = itemSerializer;
 }
 public HabitatFitnessProductsController([NotNull] IProductDataService dataService, IItemScoringService itemScoringService, IItemSerializer itemSerializer)
 {
     this.dataService        = dataService;
     this.itemSerializer     = itemSerializer;
     this.itemScoringService = itemScoringService;
 }
示例#29
0
 public DiskBTree(string fileName, int t, IItemSerializer <T> serializer)
     : this(fileName, t, Comparer <T> .Default, serializer)
 {
 }
示例#30
0
 public RedisCache(IDatabase database, IItemSerializer itemSerializer, TimeSpan?defaultTtl = null)
 {
     _database       = database;
     _itemSerializer = itemSerializer;
     _defaultTtl     = defaultTtl;
 }
示例#31
0
 public DiskBTree(Stream stream, bool leaveOpen, int t, IItemSerializer <T> serializer)
     : this(stream, leaveOpen, t, Comparer <T> .Default, serializer)
 {
 }
示例#32
0
 public DiskBTree(Stream stream, int t, IComparer <T> comparer, IItemSerializer <T> serializer)
     : this(stream, false, t, comparer, serializer)
 {
 }
示例#33
0
 public SheetHistoryController(ISheetController sheetController, IItemSerializer itemSerializer)
 {
     this._sheetController = sheetController;
     this._itemSerializer  = itemSerializer;
 }
示例#34
0
        public static ICacheAside CreatePubSubDoubleCache(IConnectionMultiplexer redisConnection, IItemSerializer itemSerializer, TimeSpan?defaultTtl = null)
        {
            var remoteCache = new RedisCache(redisConnection.GetDatabase(), itemSerializer, defaultTtl);

            return(new DoubleCache(
                       new SubscribingCache(new LocalCache.MemCache(defaultTtl), new RedisSubscriber(redisConnection, remoteCache, itemSerializer)),
                       new PublishingCache(remoteCache, new RedisPublisher(redisConnection, itemSerializer))));
        }
示例#35
0
 public ProductExcludingMultilistFieldSerializer(IItemSerializer itemSerializer, IFieldRenderer fieldRenderer)
     : base(fieldRenderer)
 {
     Assert.ArgumentNotNull(itemSerializer, nameof(itemSerializer));
     ItemSerializer = itemSerializer;
 }
示例#36
0
 public CachingDiskBTree(string fileName, int t, IComparer <T> comparer, IItemSerializer <T> serializer, long memoryLimit)
     : base(fileName, t, comparer, serializer)
 {
     _cache = new BTreeCache(memoryLimit);
 }