MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07/Microsoft/InfoCards/UIAgentMonitor.cs

77 lines
2.8 KiB
C#
Raw Normal View History

2022-08-18 11:28:56 +00:00
// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.UIAgentMonitor
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 516D8B44-4448-4D2C-8B8E-FFBB3FFE472B
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07.exe
using Microsoft.InfoCards.Diagnostics;
using System;
using System.Collections.Generic;
namespace Microsoft.InfoCards
{
internal class UIAgentMonitor
{
private static UIAgentMonitor s_singleton = (UIAgentMonitor) null;
private static object s_syncRoot = new object();
private Dictionary<string, UIAgentMonitorHandle> m_currentCallingUsers;
private Dictionary<int, UIAgentMonitorHandle> m_currentTSSessions;
private UIAgentMonitor()
{
this.m_currentCallingUsers = new Dictionary<string, UIAgentMonitorHandle>();
this.m_currentTSSessions = new Dictionary<int, UIAgentMonitorHandle>();
}
public static UIAgentMonitor Instance()
{
if (UIAgentMonitor.s_singleton == null)
{
lock (UIAgentMonitor.s_syncRoot)
{
if (UIAgentMonitor.s_singleton == null)
UIAgentMonitor.s_singleton = new UIAgentMonitor();
}
}
return UIAgentMonitor.s_singleton;
}
public void AddNewClient(UIAgentMonitorHandle handle)
{
lock (UIAgentMonitor.s_syncRoot)
{
string userName = handle.UserName;
int tsSessionId = handle.TsSessionId;
if (this.m_currentCallingUsers.ContainsKey(userName))
throw InfoCardTrace.ThrowHelperError((Exception) new ServiceBusyException(SR.GetString("ServiceInUseOnAnotherSession")));
if (this.m_currentTSSessions.ContainsKey(tsSessionId))
throw InfoCardTrace.ThrowHelperError((Exception) new ServiceBusyException(SR.GetString("ServiceInUseOnAnotherSession")));
this.m_currentCallingUsers.Add(userName, handle);
try
{
this.m_currentTSSessions.Add(tsSessionId, handle);
}
catch (Exception ex)
{
this.m_currentCallingUsers.Remove(userName);
throw;
}
}
}
public void RemoveClient(UIAgentMonitorHandle handle)
{
lock (UIAgentMonitor.s_syncRoot)
{
string userName = handle.UserName;
int tsSessionId = handle.TsSessionId;
if (!string.IsNullOrEmpty(userName) && this.m_currentCallingUsers.ContainsKey(userName) && handle == this.m_currentCallingUsers[userName])
this.m_currentCallingUsers.Remove(userName);
if (!this.m_currentTSSessions.ContainsKey(tsSessionId) || handle != this.m_currentTSSessions[tsSessionId])
return;
this.m_currentTSSessions.Remove(tsSessionId);
}
}
}
}