Example #1
0
        // Token: 0x060017DE RID: 6110 RVA: 0x0008CF34 File Offset: 0x0008B134
        internal void Remove(EasDeviceBudget budget)
        {
            bool flag = false;

            lock (this.instanceLock)
            {
                EasDeviceBudget    objB = null;
                EasDeviceBudgetKey key  = budget.Owner as EasDeviceBudgetKey;
                if (this.activeBudgets.TryGetValue(key, out objB) && object.ReferenceEquals(budget, objB))
                {
                    this.activeBudgets.Remove(key);
                    this.UpdateIfNecessary(true);
                    flag = true;
                }
                if (flag && this.activeBudgets.Count == 0)
                {
                    EasDeviceBudgetAllocator easDeviceBudgetAllocator;
                    EasDeviceBudgetAllocator.allocators.TryRemove(this.UserSid, out easDeviceBudgetAllocator);
                }
            }
        }
Example #2
0
        // Token: 0x060017E0 RID: 6112 RVA: 0x0008D030 File Offset: 0x0008B230
        private void Update()
        {
            EasDeviceBudget easDeviceBudget = this.primary;
            bool            flag            = this.activeBudgets.Count == 1;

            foreach (KeyValuePair <EasDeviceBudgetKey, EasDeviceBudget> keyValuePair in this.activeBudgets)
            {
                EasDeviceBudget value = keyValuePair.Value;
                if (flag)
                {
                    easDeviceBudget = value;
                    break;
                }
                if (value != easDeviceBudget)
                {
                    if (easDeviceBudget == null)
                    {
                        easDeviceBudget = value;
                    }
                    else if (value.InteractiveCallCount > easDeviceBudget.InteractiveCallCount || (value.InteractiveCallCount == easDeviceBudget.InteractiveCallCount && value.CallCount > easDeviceBudget.CallCount))
                    {
                        easDeviceBudget = value;
                    }
                }
            }
            if (this.primary != easDeviceBudget)
            {
                this.primary = easDeviceBudget;
            }
            int   num  = this.activeBudgets.Count + 1;
            float num2 = 1f / (float)num;

            foreach (KeyValuePair <EasDeviceBudgetKey, EasDeviceBudget> keyValuePair2 in this.activeBudgets)
            {
                keyValuePair2.Value.UpdatePercentage((this.primary == keyValuePair2.Value) ? (num2 * 2f) : num2);
            }
            this.lastUpdate = TimeProvider.UtcNow;
        }
Example #3
0
        // Token: 0x060017DC RID: 6108 RVA: 0x0008CD78 File Offset: 0x0008AF78
        public void Add(EasDeviceBudget budget)
        {
            EasDeviceBudgetKey easDeviceBudgetKey = budget.Owner as EasDeviceBudgetKey;
            SecurityIdentifier sid = easDeviceBudgetKey.Sid;

            if (!sid.Equals(this.UserSid))
            {
                throw new InvalidOperationException(string.Format("[EasDeviceBudgetAllocator.Add] Attempted to add a budget for user {0} to allocator for user {1}. That is very naughty.", sid, this.UserSid));
            }
            bool flag = false;

            lock (this.instanceLock)
            {
                if (!this.activeBudgets.ContainsKey(easDeviceBudgetKey))
                {
                    this.activeBudgets[easDeviceBudgetKey] = budget;
                    flag = true;
                }
            }
            if (flag)
            {
                this.UpdateIfNecessary(true);
            }
        }
        // Token: 0x060017C7 RID: 6087 RVA: 0x0008C9C4 File Offset: 0x0008ABC4
        public static IStandardBudget Acquire(SecurityIdentifier sid, string deviceId, string deviceType, ADSessionSettings sessionSettings)
        {
            EasDeviceBudgetKey budgetKey = new EasDeviceBudgetKey(sid, deviceId, deviceType, sessionSettings);

            return(EasDeviceBudget.Acquire(budgetKey));
        }
        // Token: 0x060017C6 RID: 6086 RVA: 0x0008C9A4 File Offset: 0x0008ABA4
        public static IStandardBudget Acquire(EasDeviceBudgetKey budgetKey)
        {
            EasDeviceBudget innerBudget = EasDeviceBudgetCache.Singleton.Get(budgetKey);

            return(new EasDeviceBudgetWrapper(innerBudget));
        }