MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed/Microsoft/InfoCards/HandleDictionary`1.cs
2022-08-18 06:28:56 -05:00

54 lines
1.7 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.HandleDictionary`1
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 1D4D5564-A025-490C-AF1D-DF4FBB709D1F
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-f8f9f26e940480624825f6bddbea86e70fc4aa746c4dd8efa7d98dcb477000ed.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.Collections.Generic;
namespace Microsoft.InfoCards
{
internal class HandleDictionary<TVal>
{
private const int m_MaxSessionCount = 1073741823;
private Dictionary<int, TVal> m_internalDictionary;
private Random m_random;
public int MaxSize => 1073741823;
public TVal this[int Key]
{
get => this.m_internalDictionary[Key];
set
{
if (!this.ContainsHandle(Key))
throw InfoCardTrace.ThrowHelperError((Exception) new KeyNotFoundException());
this.m_internalDictionary[Key] = value;
}
}
public HandleDictionary()
{
this.m_internalDictionary = new Dictionary<int, TVal>();
this.m_random = new Random();
}
public int GetNewHandle()
{
if (this.m_internalDictionary.Count >= 1073741823)
throw InfoCardTrace.ThrowHelperError((Exception) new MaxSessionCountExceededException());
int key = this.m_random.Next();
while (this.m_internalDictionary.ContainsKey(key) || key == 0)
key = this.m_random.Next();
this.m_internalDictionary[key] = default (TVal);
return key;
}
public bool Remove(int key) => this.m_internalDictionary.Remove(key);
public bool ContainsHandle(int key) => this.m_internalDictionary.ContainsKey(key);
}
}