MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d/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: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d.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);
}
}