public void Add_CacheCapacityReached_MRUKVPRemovedAndNewKVPAdded() { _cache = new CacheDictionary<int, int>(5,CachePurgeStatergy.MRU); FillCache(); _cache.Add(5, 5); Assert.IsFalse(_cache.ContainsKey(4)); Assert.IsTrue(_cache.ContainsKey(5)); Assert.AreEqual(_cache.CacheCapacity, _cache.Count); }
public GeometryCache(Factory factory2D) { Contract.Requires(factory2D != null); _Factory2D = factory2D; _Builder = new GeometryBuilder(_Factory2D); _Cache = new CacheDictionary<Shape, DxGeometry>(CacheLimit); }
public FrameworkElement() { Triggers = new ObservableCollection<ITrigger>(); Triggers.CollectionChanged += OnTriggersCollectionChanged; resourcesCache = new CacheDictionary<object, object>(TryResolveResource); actualWidthValueEntry = GetValueEntry(ActualWidthPropertyKey); actualHeightValueEntry = GetValueEntry(ActualHeightPropertyKey); ActualSize = Size.Empty; Size = Size.Empty; MinSize = Size.Zero; MaxSize = Size.Infinity; }
public UIElement() { logicalChildren = new List<object>(); LogicalChildren = new ReadOnlyCollection<object>(logicalChildren); routedEventHandlers = new ListDictionary<RoutedEvent, RoutedEventHandlerItem>(); routedEventHandlersCache = new CacheDictionary<RoutedEvent, IEnumerable<RoutedEventHandlerItem>>(ResolveRoutedEventHandlers); PreviousFinalRect = Rect.Empty; PreviousAvailableSize = Size.Empty; previousDesiredSize = Size.Empty; SetIsVisible(); VisualClipToBounds = ClipToBounds; VisualIsHitTestVisible = IsHitTestVisible; VisualIsVisible = IsVisible; VisualOpacity = Opacity; }
public PlatformClient(Uri plusBaseUrl, Uri talkBaseUrl, System.Net.CookieContainer cookie, IApiAccessor accessor, ICacheDictionary<string, ProfileCache, ProfileData> profileCacheStorage, CacheDictionary<string, ActivityCache, ActivityData> activityCacheStorage) { var handler = new System.Net.Http.HttpClientHandler() { CookieContainer = cookie }; Cookies = cookie; ServiceApi = accessor; PlusBaseUrl = plusBaseUrl; TalkBaseUrl = talkBaseUrl; NormalHttpClient = new System.Net.Http.HttpClient(handler); NormalHttpClient.DefaultRequestHeaders.Add("user-agent", ApiAccessorUtility.UserAgent); StreamHttpClient = new System.Net.Http.HttpClient(handler); StreamHttpClient.Timeout = TimeSpan.FromMinutes(15); StreamHttpClient.DefaultRequestHeaders.Add("user-agent", ApiAccessorUtility.UserAgent); People = new PeopleContainer(this, profileCacheStorage); Activity = new ActivityContainer(this, activityCacheStorage); Notification = new NotificationContainer(this); }
public FunctionInliner(Function root) { _root = root; _funStack.Push(root); _sim = new ScopedIdentifierManager(true); _locals = new CacheDictionary<Tuple<Function, IStorableLiteral>, IStorableLiteral>(CreateLocal); }
public EmbeddedResourceObjectFactory(HtmlValueConverter converter) { this.converter = converter; objectUrlCache = CacheDictionary <Uri, string> .CreateUsingStringKeys(ResolveObjectUrl, uri => uri.GetAbsoluteUri()); }
public UserFriend() { Friends = new CacheList <FriendsData>(); FriendDict = new CacheDictionary <int, FriendsData>(); }
public override ItemType GetById(int id) { ItemType returnValue; return(!CacheDictionary.TryGetValue(id, out returnValue) ? ItemType.Undefined : returnValue); }
public void IndexerSet_MRUDicAndKeyPresent_ValueUpdatedAndMarkedForPurge() { _cache = new CacheDictionary<int, int>(5, CachePurgeStatergy.MRU); FillCache(); _cache[0] = 100; Assert.AreEqual(100, _cache[0]); _cache.Add(5, 5); Assert.IsTrue(_cache.ContainsKey(5)); //newly added key 5 is present Assert.IsFalse(_cache.ContainsKey(0)); //0 is not present }
public SystemResources() { resourcesCache = new CacheDictionary <object, object>(TryResolveResource); }
public override CctRepurchaseType GetById(int id) { CctRepurchaseType returnValue; return(!CacheDictionary.TryGetValue(id, out returnValue) ? null : returnValue); }
private ICache <TK, TV> BuildMockForCache <TK, TV>(string cacheName) { lock (CacheDictionary) { if (CacheDictionary.TryGetValue(cacheName, out var cache)) { return((ICache <TK, TV>)cache); } } var mockCache = new Mock <ICache <TK, TV> >(MockBehavior.Strict); var mockCacheDictionary = new Dictionary <TK, TV>(); mockCache.Setup(x => x.Get(It.IsAny <TK>())).Returns((TK key) => { lock (mockCacheDictionary) { if (mockCacheDictionary.TryGetValue(key, out var value)) { return(value); } } throw new KeyNotFoundException($"Key {key} not found in mock cache"); }); mockCache.Setup(x => x.GetAsync(It.IsAny <TK>())).Returns((TK key) => { var task = new Task <TV>(() => { lock (mockCacheDictionary) { if (mockCacheDictionary.TryGetValue(key, out var value)) { return(value); } } throw new KeyNotFoundException($"Key {key} not found in mock cache"); }); task.Start(); return(task); }); mockCache.Setup(x => x.Put(It.IsAny <TK>(), It.IsAny <TV>())).Callback((TK key, TV value) => { lock (mockCacheDictionary) { // Ignite behaviour is writing an existing key updates the value with no error if (mockCacheDictionary.ContainsKey(key)) { mockCacheDictionary[key] = value; } else { mockCacheDictionary.Add(key, value); } } }); mockCache.Setup(x => x.PutAsync(It.IsAny <TK>(), It.IsAny <TV>())).Returns((TK key, TV value) => { var task = new Task(() => { lock (mockCacheDictionary) { // Ignite behaviour is writing an existing key updates the value with no error if (mockCacheDictionary.ContainsKey(key)) { mockCacheDictionary[key] = value; } else { mockCacheDictionary.Add(key, value); } } }); task.Start(); return(task); }); mockCache.Setup(x => x.PutIfAbsent(It.IsAny <TK>(), It.IsAny <TV>())).Returns((TK key, TV value) => { lock (mockCacheDictionary) { if (!mockCacheDictionary.ContainsKey(key)) { mockCacheDictionary.Add(key, value); return(true); } } return(false); }); mockCache.Setup(x => x.Name).Returns(cacheName); mockCache.Setup(x => x.RemoveAll(It.IsAny <IEnumerable <TK> >())).Callback((IEnumerable <TK> keys) => { lock (mockCacheDictionary) { keys.ForEach(key => mockCacheDictionary.Remove(key)); } }); mockCache.Setup(x => x.Remove(It.IsAny <TK>())).Returns((TK key) => { lock (mockCacheDictionary) { if (mockCacheDictionary.ContainsKey(key)) { mockCacheDictionary.Remove(key); return(true); } } return(false); }); mockCache.Setup(x => x.RemoveAsync(It.IsAny <TK>())).Returns((TK key) => { var task = new Task <bool>(() => { lock (mockCacheDictionary) { if (mockCacheDictionary.ContainsKey(key)) { mockCacheDictionary.Remove(key); return(true); } } return(false); }); task.Start(); return(task); }); mockCache.Setup(x => x.PutAll(It.IsAny <IEnumerable <KeyValuePair <TK, TV> > >())).Callback((IEnumerable <KeyValuePair <TK, TV> > values) => { values.ForEach(value => { lock (mockCacheDictionary) { // Ignite behaviour is writing an existing key updates the value with no error if (mockCacheDictionary.ContainsKey(value.Key)) { mockCacheDictionary[value.Key] = value.Value; } else { mockCacheDictionary.Add(value.Key, value.Value); } } }); }); mockCache .Setup(x => x.Query(It.IsAny <ScanQuery <TK, TV> >())) .Returns((ScanQuery <TK, TV> query) => { // This mock treats the query as an unconstrained query and returns all elements if (query == null) { return(null); } lock (mockCacheDictionary) { var queryResult = new Mock <IQueryCursor <ICacheEntry <TK, TV> > >(); queryResult.Setup(x => x.GetAll()).Returns(() => mockCacheDictionary.Select(x => (ICacheEntry <TK, TV>)(new IgniteMockCacheEntry <TK, TV>(x.Key, x.Value))).ToList()); return(queryResult.Object); } }); lock (CacheDictionary) { CacheDictionary.Add(cacheName, mockCache.Object); } lock (MockedCacheDictionaries) { MockedCacheDictionaries.Add(cacheName, mockCacheDictionary); } return(mockCache.Object); }
public PlayerMeridian() : base(false) { UnlockedMeridians = new CacheDictionary <int, Meridian>(); }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="creator">property value creator</param> public CacheBasedPropMap(Func <TThis, TValue> creator) { _map = new CacheDictionary <TThis, TValue>(creator); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="allocation">resource allocation information</param> /// <param name="scheduleLength">schedule length</param> internal AllocationStatistics(IEnumerable<Tuple<Component, ReservationTable>> allocation, long scheduleLength) { Allocation = allocation; ScheduleLength = scheduleLength; _stats = new CacheDictionary<Type, FUTypeStatistics>(CreateFUTypeStats); Setup(); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="xmm">XIL mapper manager</param> /// <param name="host">component instance to host all created functional units</param> /// <param name="targetProject">target project</param> internal XILAllocator(XILMapperManager xmm, Component host, IProject targetProject) { _xmm = xmm; _host = host; _targetProject = targetProject; _resTables = new CacheDictionary<ITransactionSite, ReservationTable>(CreateReservationTable); Policy = new DefaultAllocationPolicy(); }
private SystemCTypes() { _allTypes = _converters.Keys.Union(_converters.SelectMany(kvp => kvp.Value.Keys)).Distinct(); _typePaths = new CacheDictionary <Type, TypePaths>(CreateTypePaths); }
public FieldLocalizer(Function root) { _root = root; _f2loc = new CacheDictionary <FieldRef, Variable>(CreateVariableForField); }
/// <summary> /// Creates a new metadata dictionary using the specified external and local metadata services. /// </summary> /// <param name="external"> /// External metadata dictionary to fall back to for lookups. /// </param> /// <param name="local"> /// Local metadata dictionary used for caching of immutable resources that can be shared safely across users of the metadata dictionary. /// This dictionary should be thread-safe for lookup and add calls. /// </param> public LeveledCacheQueryableDictionary(IQueryableDictionary <Uri, TMetadataEntity> external, IDictionary <Uri, TMetadataEntity> local) { _external = external; _local = new CacheDictionary <Uri, TMetadataEntity>(local); _callLocal = new CallContextLocal <CallContextLocalCache>(() => new CallContextLocalCache()); }
private RenderImageSourceFactory(IHtmlValueConverter converter) { this.converter = converter; objectUrlCache = new CacheDictionary<string, string>(ResolveObjectUrl); }
/// <summary> /// </summary> public NoviceTaskInfo() : base() { _PrizeList = new CacheDictionary <int, CacheList <int> >(); }
public UserFriend() { Friends = new CacheList<FriendsData>(); FriendDict = new CacheDictionary<int, FriendsData>(); }
public async Task<PlatformClient> Create(System.Net.CookieContainer cookie, int accountIndex, IApiAccessor[] accessors = null, CacheDictionary<string, ProfileCache, ProfileData> profileCacheStorage = null, CacheDictionary<string, ActivityCache, ActivityData> activityCacheStorage = null) { var accountPrefix = string.Format("u/{0}/", accountIndex); accessors = accessors ?? new IApiAccessor[] { new DefaultAccessor() }; //accessors内で使えるものを検索 //G+apiバージョンで降順にしたIApiAccessor配列が用いられることを想定してる foreach (var item in accessors) { var client = new PlatformClient( new Uri(PlusBaseUrl, accountPrefix), new Uri(TalkBaseUrl, accountPrefix), cookie, item, profileCacheStorage ?? new CacheDictionary<string, ProfileCache, ProfileData>(1200, 400, true, dt => new ProfileCache() { Value = dt }), activityCacheStorage ?? new CacheDictionary<string, ActivityCache, ActivityData>(1200, 400, true, dt => new ActivityCache() { Value = dt })); try { await client.UpdateHomeInitDataAsync(true); return client; } catch (FailToOperationException) { client.Dispose(); } } throw new FailToOperationException("Create()に失敗。使用できるIApiAccessorがありませんでした。", null); }
static SessionContainer() { LoginSessions = new CacheDictionary(); }
public PlayerHeros() : base(false) { Heros = new CacheDictionary <int, Hero>(); }
CacheDictionary <int, RefleshCacheInfo> copy(CacheDictionary <int, RefleshCacheInfo> cacheDIC) { return(null); }
public UserPackage() { Items = new CacheDictionary <uint, uint>(); }
public PlayerFriends() { Friends = new CacheDictionary <int, Friend>(); Invitations = new CacheList <int>(); RemovedFriends = new CacheDictionary <int, Friend>(); }
public The3rdUserIDMap() : base(false) { the3rdMap = new CacheDictionary<string, int>(); }
public PlayerMoneyChance() { UnopenedChanceRewards = new CacheDictionary <int, DropItem>(); OpenedChanceRewards = new CacheDictionary <int, DropItem>(); }
public PlayerAchievement() { TrackingAchievements = new CacheDictionary <int, TrackingAchievement>(); CompletedAchievements = new CacheList <int>(); }
public override string GetById(int id) { string returnValue; return(!CacheDictionary.TryGetValue(id, out returnValue) ? "" : returnValue); }
internal CoreConfigurator() { _map = new CacheDictionary<Tuple<FloatingPointCore.EPrecision, FloatingPointCore.EFunction>, CoreConfiguration>(CreateConfiguration); }
/// <summary> /// </summary> public NoviceTaskInfo() : base() { _PrizeList = new CacheDictionary<int, CacheList<int>>(); }
public PlayerDailyQuest() { TrackingDailyQuests = new CacheDictionary <int, TrackingDailyQuest>(); CompletedDailyQuests = new CacheList <int>(); }
public SystemResources() { themeResourcesCache = CacheDictionary <Assembly, ResourceDictionary> .CreateUsingStringKeys(ResolveAssemblyThemeResources, assembly => assembly.FullName); }
private RenderImageSourceFactory(IHtmlValueConverter converter) { this.converter = converter; objectUrlCache = new CacheDictionary <string, string>(ResolveObjectUrl); }
public SystemResources() { resourcesCache = new CacheDictionary<object, object>(TryResolveResource); }
protected override object this[string index] { get { #region switch (index) { case "ID": return ID; case "Name": return Name; case "Description": return Description; case "NextID": return NextID; case "PrizeList": return PrizeList; case "Type": return Type; case "SubType": return SubType; default: throw new ArgumentException(string.Format("NoviceTaskInfo index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "ID": _ID = value.ToInt(); break; case "Name": _Name = value.ToNotNullString(); break; case "Description": _Description = value.ToNotNullString(); break; case "NextID": _NextID = value.ToInt(); break; case "PrizeList": _PrizeList = ConvertCustomField<CacheDictionary<int, CacheList<int>>>(value, index); break; case "Type": _Type = value.ToInt(); break; case "SubType": _SubType = value.ToInt(); break; default: throw new ArgumentException(string.Format("NoviceTaskInfo index[{0}] isn't exist.", index)); } #endregion } }
public PlayerCosmosCrack() { ChosenInstance = new CacheDictionary <int, CosmosCrackInstance>(); }
public The3rdUserIDMap() : base(false) { the3rdMap = new CacheDictionary <string, int>(); }
public CosmosCrackInstance() { RewardItem = new CacheDictionary <int, int>(); }
protected override object this[string index] { get { #region switch (index) { case "ID": return(ID); case "Name": return(Name); case "Description": return(Description); case "NextID": return(NextID); case "PrizeList": return(PrizeList); case "Type": return(Type); case "SubType": return(SubType); default: throw new ArgumentException(string.Format("NoviceTaskInfo index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "ID": _ID = value.ToInt(); break; case "Name": _Name = value.ToNotNullString(); break; case "Description": _Description = value.ToNotNullString(); break; case "NextID": _NextID = value.ToInt(); break; case "PrizeList": _PrizeList = ConvertCustomField <CacheDictionary <int, CacheList <int> > >(value, index); break; case "Type": _Type = value.ToInt(); break; case "SubType": _SubType = value.ToInt(); break; default: throw new ArgumentException(string.Format("NoviceTaskInfo index[{0}] isn't exist.", index)); } #endregion } }
public RoomData() { _tableVersion = new VersionConfig(); _tables = new CacheDictionary <int, TableData>(); _tablePool = new CacheQueue <TableData>(); }
public void IndexerSet_MRUDicAndKeyNotPresent_KVPAddedAndMarkedForPurge() { _cache = new CacheDictionary<int, int>(5,CachePurgeStatergy.MRU); FillCache(); _cache[5] = 5; Assert.AreEqual(5, _cache[5]); Assert.IsTrue(_cache.ContainsKey(5)); //newly added key 5 is present Assert.IsFalse(_cache.ContainsKey(4)); //0 is not present _cache.Add(6,6); Assert.IsFalse(_cache.ContainsKey(5)); //key 5 is not present }
public RewardChessField() { RewardItems = new CacheDictionary <int, int>(); }
public void TryGetValue_MRUDicAndKeyPresent_KeyMarkedLastForPurge() { _cache = new CacheDictionary<int, int>(5, CachePurgeStatergy.MRU); FillCache(); int value; Assert.IsTrue(_cache.TryGetValue(0, out value)); //0 moved to top of MRU list Assert.AreEqual(0, value); _cache.Add(5, 5); Assert.IsTrue(_cache.ContainsKey(5)); //newly added key 5 is present Assert.IsFalse(_cache.ContainsKey(0)); //0 is not present }
public RoomData() { _tableVersion = new VersionConfig(); _tables = new CacheDictionary<int, TableData>(); _tablePool = new CacheQueue<TableData>(); }
public override bool TakeAction() { InstanceProgressLogic ip = new InstanceProgressLogic(); ip.SetUser(m_UserId); if (!(ip.GetInstanceProgress()).ContainsKey(m_RequestPacket.InstanceId)) { ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You have not passed this instance"; return(false); } PlayerInstanceLogic pi = new PlayerInstanceLogic(); pi.SetUser(m_UserId); CacheDictionary <int, int> dropItems = new CacheDictionary <int, int>(); for (int i = 0; i < m_RequestPacket.Count; i++) { PBInstanceDrop instanceDrop = new PBInstanceDrop(); List <PBDropInfo> dropList = new List <PBDropInfo>(); List <PBDropInfo> dropPack; var dropDict = pi.GenerateDropList(m_RequestPacket.InstanceId, true, out dropPack); GameUtils.MergeItemDict(dropItems, dropDict); foreach (var dropItem in dropDict) { PBDropInfo item = new PBDropInfo() { DropId = dropItem.Key, DropCount = dropItem.Value }; instanceDrop.Items.Add(item); } m_ResponsePacket.Drops.Add(instanceDrop); } PlayerPackageLogic pp = new PlayerPackageLogic(); pp.SetUser(m_UserId); if (!pp.CheckPackageSlot(dropItems)) { ErrorCode = (int)ErrorType.PackageSlotFull; ErrorInfo = "Package full"; return(false); } PlayerLogic p = new PlayerLogic(); p.SetUser(m_UserId); int energy = PlayerInstanceLogic.GetInstanceEnergy(m_RequestPacket.InstanceId); long nextRecoverTime; if (!p.DeductEnergy(energy * m_RequestPacket.Count, out nextRecoverTime)) { ErrorCode = (int)ErrorType.RequireNotMet; ErrorInfo = "You have not enough energy"; return(false); } PBReceivedItems receivedItems; pp.GetItems(dropItems, ReceiveItemMethodType.CompleteInstance, out receivedItems); m_ResponsePacket.ReceivedItems = receivedItems; DTInstance instanceData = PlayerInstanceLogic.GetInstanceData(m_RequestPacket.InstanceId); p.AddCoin(instanceData.Coin * m_RequestPacket.Count); p.AddExp(instanceData.PlayerExp * m_RequestPacket.Count); m_ResponsePacket.Count = m_RequestPacket.Count; m_ResponsePacket.InstanceId = m_RequestPacket.InstanceId; m_ResponsePacket.PlayerInfo = new PBPlayerInfo() { Id = m_UserId, Coin = p.MyPlayer.Coin, Exp = p.MyPlayer.Exp, Level = p.MyPlayer.Level, Energy = p.MyPlayer.Energy, NextEnergyRecoveryTime = nextRecoverTime }; HeroTeamLogic heroTeam = new HeroTeamLogic(); heroTeam.SetUser(m_UserId); PlayerHeroLogic playerHero = new PlayerHeroLogic(); playerHero.SetUser(m_UserId); foreach (int heroId in heroTeam.MyHeroTeam.Team) { if (heroId == 0) { continue; } //playerHero.SetHero(heroId).AddExp(instanceData.HeroExp); m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo() { Type = heroId, Exp = playerHero.MyHeros.Heros[heroId].HeroExp, Level = playerHero.MyHeros.Heros[heroId].HeroLv }); } PlayerDailyQuestLogic.GetInstance(m_UserId).UpdateDailyQuest(DailyQuestType.CleanOutInstance, m_RequestPacket.Count); return(true); }
public FieldLocalizer(Function root) { _root = root; _f2loc = new CacheDictionary<FieldRef, Variable>(CreateVariableForField); }