Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,169 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
using System.Collections.Generic;
namespace System
{
internal static partial class AppContextDefaultValues
{
public static void PopulateDefaultValues()
{
string platformIdentifier, profile;
int version;
ParseTargetFrameworkName(out platformIdentifier, out profile, out version);
// Call into each library to populate their default switches
PopulateDefaultValuesPartial(platformIdentifier, profile, version);
}
/// <summary>
/// We have this separate method for getting the parsed elements out of the TargetFrameworkName so we can
/// more easily support this on other platforms.
/// </summary>
private static void ParseTargetFrameworkName(out string identifier, out string profile, out int version)
{
string targetFrameworkMoniker = AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName;
// If we don't have a TFM then we should default to the 4.0 behavior where all quirks are turned on.
if (!TryParseFrameworkName(targetFrameworkMoniker, out identifier, out version, out profile))
{
#if FEATURE_CORECLR
if (CompatibilitySwitches.UseLatestBehaviorWhenTFMNotSpecified)
{
// If we want to use the latest behavior it is enough to set the value of the switch to string.Empty.
// When the get to the caller of this method (PopulateDefaultValuesPartial) we are going to use the
// identifier we just set to decide which switches to turn on. By having an empty string as the
// identifier we are simply saying -- don't turn on any switches, and we are going to get the latest
// behavior for all the switches
identifier = string.Empty;
}
else
#endif
{
identifier = ".NETFramework";
version = 40000;
profile = string.Empty;
}
}
}
// This code was a constructor copied from the FrameworkName class, which is located in System.dll.
// Parses strings in the following format: "<identifier>, Version=[v|V]<version>, Profile=<profile>"
// - The identifier and version is required, profile is optional
// - Only three components are allowed.
// - The version string must be in the System.Version format; an optional "v" or "V" prefix is allowed
private static bool TryParseFrameworkName(String frameworkName, out String identifier, out int version, out String profile)
{
// For parsing a target Framework moniker, from the FrameworkName class
const char c_componentSeparator = ',';
const char c_keyValueSeparator = '=';
const char c_versionValuePrefix = 'v';
const String c_versionKey = "Version";
const String c_profileKey = "Profile";
identifier = profile = string.Empty;
version = 0;
if (frameworkName == null || frameworkName.Length == 0)
{
return false;
}
String[] components = frameworkName.Split(c_componentSeparator);
version = 0;
// Identifer and Version are required, Profile is optional.
if (components.Length < 2 || components.Length > 3)
{
return false;
}
//
// 1) Parse the "Identifier", which must come first. Trim any whitespace
//
identifier = components[0].Trim();
if (identifier.Length == 0)
{
return false;
}
bool versionFound = false;
profile = null;
//
// The required "Version" and optional "Profile" component can be in any order
//
for (int i = 1; i < components.Length; i++)
{
// Get the key/value pair separated by '='
string[] keyValuePair = components[i].Split(c_keyValueSeparator);
if (keyValuePair.Length != 2)
{
return false;
}
// Get the key and value, trimming any whitespace
string key = keyValuePair[0].Trim();
string value = keyValuePair[1].Trim();
//
// 2) Parse the required "Version" key value
//
if (key.Equals(c_versionKey, StringComparison.OrdinalIgnoreCase))
{
versionFound = true;
// Allow the version to include a 'v' or 'V' prefix...
if (value.Length > 0 && (value[0] == c_versionValuePrefix || value[0] == 'V'))
{
value = value.Substring(1);
}
Version realVersion = new Version(value);
// The version class will represent some unset values as -1 internally (instead of 0).
version = realVersion.Major * 10000;
if (realVersion.Minor > 0)
version += realVersion.Minor * 100;
if (realVersion.Build > 0)
version += realVersion.Build;
}
//
// 3) Parse the optional "Profile" key value
//
else if (key.Equals(c_profileKey, StringComparison.OrdinalIgnoreCase))
{
if (!String.IsNullOrEmpty(value))
{
profile = value;
}
}
else
{
return false;
}
}
if (!versionFound)
{
return false;
}
return true;
}
// This is a partial method. Platforms (such as Desktop) can provide an implementation of it that will read override value
// from whatever mechanism is available on that platform. If no implementation is provided, the compiler is going to remove the calls
// to it from the code
static partial void TryGetSwitchOverridePartial(string switchName, ref bool overrideFound, ref bool overrideValue);
/// This is a partial method. This method is responsible for populating the default values based on a TFM.
/// It is partial because each library should define this method in their code to contain their defaults.
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int version);
}
}

View File

@@ -0,0 +1,128 @@
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// NOTE: This file should not be included in mscorlib. This should only be included in FX libraries that need to provide switches
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
namespace System
{
internal static partial class LocalAppContext
{
private delegate bool TryGetSwitchDelegate(string switchName, out bool value);
private static TryGetSwitchDelegate TryGetSwitchFromCentralAppContext;
private static bool s_canForwardCalls;
private static Dictionary<string, bool> s_switchMap = new Dictionary<string, bool>();
private static readonly object s_syncLock = new object();
private static bool DisableCaching { get; set; }
static LocalAppContext()
{
// Try to setup the callback into the central AppContext
s_canForwardCalls = SetupDelegate();
// Populate the default values of the local app context
AppContextDefaultValues.PopulateDefaultValues();
// Cache the value of the switch that help with testing
DisableCaching = IsSwitchEnabled(@"TestSwitch.LocalAppContext.DisableCaching");
}
public static bool IsSwitchEnabled(string switchName)
{
if (s_canForwardCalls)
{
bool isEnabledCentrally;
if (TryGetSwitchFromCentralAppContext(switchName, out isEnabledCentrally))
{
// we found the switch, so return whatever value it has
return isEnabledCentrally;
}
// if we could not get the value from the central authority, try the local storage.
}
return IsSwitchEnabledLocal(switchName);
}
private static bool IsSwitchEnabledLocal(string switchName)
{
// read the value from the set of local defaults
bool isEnabled, isPresent;
lock (s_switchMap)
{
isPresent = s_switchMap.TryGetValue(switchName, out isEnabled);
}
// If the value is in the set of local switches, reutrn the value
if (isPresent)
{
return isEnabled;
}
// if we could not find the switch name, we should return 'false'
// This will preserve the concept of switches been 'off' unless explicitly set to 'on'
return false;
}
private static bool SetupDelegate()
{
Type appContextType = typeof(object).Assembly.GetType("System.AppContext");
if (appContextType == null)
return false;
MethodInfo method = appContextType.GetMethod(
"TryGetSwitch", // the method name
BindingFlags.Static | BindingFlags.Public, // binding flags
null, // use the default binder
new Type[] { typeof(string), typeof(bool).MakeByRefType() },
null); // parameterModifiers - this is ignored by the default binder
if (method == null)
return false;
// Create delegate if we found the method.
TryGetSwitchFromCentralAppContext = (TryGetSwitchDelegate)Delegate.CreateDelegate(typeof(TryGetSwitchDelegate), method);
return true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool GetCachedSwitchValue(string switchName, ref int switchValue)
{
if (switchValue < 0) return false;
if (switchValue > 0) return true;
return GetCachedSwitchValueInternal(switchName, ref switchValue);
}
private static bool GetCachedSwitchValueInternal(string switchName, ref int switchValue)
{
if (LocalAppContext.DisableCaching)
{
return LocalAppContext.IsSwitchEnabled(switchName);
}
bool isEnabled = LocalAppContext.IsSwitchEnabled(switchName);
switchValue = isEnabled ? 1 /*true*/ : -1 /*false*/;
return isEnabled;
}
/// <summary>
/// This method is going to be called from the AppContextDefaultValues class when setting up the
/// default values for the switches. !!!! This method is called during the static constructor so it does not
/// take a lock !!!! If you are planning to use this outside of that, please ensure proper locking.
/// </summary>
internal static void DefineSwitchDefault(string switchName, bool initialValue)
{
s_switchMap[switchName] = initialValue;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
305950b3e8b64f3257c6299779689441be22e9d5

View File

@@ -0,0 +1 @@
f4bd62377998386538d7b683a4e60bba2f40aba0

View File

@@ -0,0 +1 @@
437a870ba3569fb200699ee22055002ab97cfd16

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// <copyright file="PowerModeChangedEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.PowerModeChanged'/> event.</para>
/// </devdoc>
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")]
[HostProtection(MayLeakOnAbort = true)]
public class PowerModeChangedEventArgs : EventArgs
{
private readonly PowerModes mode;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='Microsoft.Win32.PowerModeChangedEventArgs'/> class.</para>
/// </devdoc>
public PowerModeChangedEventArgs(PowerModes mode) {
this.mode = mode;
}
/// <devdoc>
/// <para>Gets the power mode.</para>
/// </devdoc>
public PowerModes Mode {
get {
return mode;
}
}
}
}

View File

@@ -0,0 +1,20 @@
//------------------------------------------------------------------------------
// <copyright file="PowerModeChangedEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Represents the method that will handle the <see cref='Microsoft.Win32.SystemEvents.PowerModeChanged'/> event.</para>
/// </devdoc>
[HostProtection(MayLeakOnAbort = true)]
public delegate void PowerModeChangedEventHandler(object sender, PowerModeChangedEventArgs e);
}

View File

@@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <copyright file="PowerModes.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System.Diagnostics;
using System;
/// <devdoc>
/// <para> Specifies how the system
/// power mode changes.</para>
/// </devdoc>
public enum PowerModes {
/// <devdoc>
/// <para> The system is about to resume.</para>
/// </devdoc>
Resume = 1,
/// <devdoc>
/// The power mode status has changed. This may
/// indicate a weak or charging battery, a transition
/// from AC power from battery, or other change in the
/// status of the system power supply.
/// </devdoc>
StatusChange = 2,
/// <devdoc>
/// The system is about to be suspended.
/// </devdoc>
Suspend = 3,
}
}

View File

@@ -0,0 +1,243 @@
//------------------------------------------------------------------------------
// <copyright file="SafeNativeMethods.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Win32 {
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System;
using System.Security;
#if !SILVERLIGHT || FEATURE_NETCORE
using System.Diagnostics.CodeAnalysis;
using System.Security.Permissions;
using System.Collections;
using System.IO;
using System.Text;
using System.Threading;
using Microsoft.Win32.SafeHandles;
using System.Runtime.ConstrainedExecution;
using System.Diagnostics;
#endif // !SILVERLIGHT || FEATURE_NETCORE
#if !SILVERLIGHT
[HostProtection(MayLeakOnAbort = true)]
[SuppressUnmanagedCodeSecurity]
#endif // !SILVERLIGHT
internal static class SafeNativeMethods {
#if FEATURE_PAL && !FEATURE_NETCORE
[DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CFStringCreateWithCharacters(
IntPtr alloc, // CFAllocatorRef
[MarshalAs(UnmanagedType.LPWStr)]
string chars,
int numChars);
[DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", CallingConvention = CallingConvention.Cdecl)]
public static extern void CFRelease(IntPtr cf);
[DllImport("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", CallingConvention = CallingConvention.Cdecl)]
public static extern int CFUserNotificationDisplayAlert(double timeout, uint flags, IntPtr iconUrl, IntPtr soundUrl, IntPtr localizationUrl, IntPtr alertHeader, IntPtr alertMessage, IntPtr defaultButtonTitle, IntPtr alternateButtonTitle, IntPtr otherButtonTitle, ref uint responseFlags);
#endif // SILVERLIGHT && !FEATURE_NETCORE
public const int
MB_RIGHT = 0x00080000,
MB_RTLREADING = 0x00100000;
#if !FEATURE_PAL && !FEATURE_CORESYSTEM
[DllImport(ExternDll.Gdi32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetTextMetrics(IntPtr hDC, [In, Out] NativeMethods.TEXTMETRIC tm);
[DllImport(ExternDll.Gdi32, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
public static extern IntPtr GetStockObject(int nIndex);
#endif
[DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Auto, BestFitMapping = true)]
[ResourceExposure(ResourceScope.None)]
public static extern void OutputDebugString(String message);
[DllImport(ExternDll.User32, CharSet = System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="MessageBoxW", ExactSpelling=true)]
private static extern int MessageBoxSystem(IntPtr hWnd, string text, string caption, int type);
[SecurityCritical]
public static int MessageBox(IntPtr hWnd, string text, string caption, int type) {
try {
return MessageBoxSystem(hWnd, text, caption, type);
} catch (DllNotFoundException) {
return 0;
} catch (EntryPointNotFoundException) {
return 0;
}
}
#if !SILVERLIGHT || FEATURE_NETCORE
public const int
FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
FORMAT_MESSAGE_FROM_STRING = 0x00000400,
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000;
public const int ERROR_INSUFFICIENT_BUFFER = 0x7A;
#if FEATURE_NETCORE
[SecurityCritical]
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
[DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true, BestFitMapping=true)]
[SuppressMessage("Microsoft.Security", "CA2101:SpecifyMarshalingForPInvokeStringArguments")]
[ResourceExposure(ResourceScope.None)]
public static unsafe extern int FormatMessage(int dwFlags, IntPtr lpSource_mustBeNull, uint dwMessageId,
int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments);
#if FEATURE_NETCORE
[SecurityCritical]
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
[DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true, BestFitMapping = true)]
[SuppressMessage("Microsoft.Security", "CA2101:SpecifyMarshalingForPInvokeStringArguments")]
[ResourceExposure(ResourceScope.None)]
public static unsafe extern int FormatMessage(int dwFlags, SafeLibraryHandle lpSource, uint dwMessageId,
int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments);
#if FEATURE_NETCORE
[SecurityCritical]
[System.Security.SuppressUnmanagedCodeSecurity]
#else
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[ResourceExposure(ResourceScope.None)]
#endif
[DllImport(ExternDll.Kernel32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto, SetLastError=true)]
public static extern bool CloseHandle(IntPtr handle);
#endif // !SILVERLIGHT || FEATURE_NETCORE
#if !SILVERLIGHT || FEATURE_NETCORE
#if FEATURE_NETCORE
[SecurityCritical]
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
[DllImport(ExternDll.Kernel32)]
[ResourceExposure(ResourceScope.None)]
public static extern bool QueryPerformanceCounter(out long value);
#if FEATURE_NETCORE
[SecurityCritical]
[System.Security.SuppressUnmanagedCodeSecurity]
#endif
[DllImport(ExternDll.Kernel32)]
[ResourceExposure(ResourceScope.None)]
public static extern bool QueryPerformanceFrequency(out long value);
#endif // !SILVERLIGHT || FEATURE_NETCORE
#if !SILVERLIGHT
#if !FEATURE_PAL
public const int
FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF,
FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
[DllImport(ExternDll.User32, CharSet=System.Runtime.InteropServices.CharSet.Auto, BestFitMapping=false)]
[ResourceExposure(ResourceScope.Machine)]
public static extern int RegisterWindowMessage(string msg);
#if DEBUG
// Used only from debug code to assert we're on the right thread
// for calling certain Windows methods.
[DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
public static extern int GetCurrentThreadId();
[DllImport(ExternDll.User32, ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.Process)]
public static extern int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);
#endif
// file src\Services\Monitoring\system\Diagnosticts\SafeNativeMethods.cs
[DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
[ResourceExposure(ResourceScope.Process)]
public static extern IntPtr LoadLibrary(string libFilename);
[DllImport(ExternDll.Kernel32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)]
[ResourceExposure(ResourceScope.Process)]
public static extern bool FreeLibrary(HandleRef hModule);
[DllImport(ExternDll.Kernel32, CharSet=CharSet.Auto, BestFitMapping=false)]
[ResourceExposure(ResourceScope.None)]
public static extern bool GetComputerName(StringBuilder lpBuffer, int[] nSize);
public static unsafe int InterlockedCompareExchange(IntPtr pDestination, int exchange, int compare)
{
return Interlocked.CompareExchange(ref *(int *)pDestination.ToPointer(), exchange, compare);
}
[DllImport(ExternDll.PerfCounter, CharSet=System.Runtime.InteropServices.CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
public static unsafe extern int FormatFromRawValue(
uint dwCounterType,
uint dwFormat,
ref long pTimeBase,
NativeMethods.PDH_RAW_COUNTER pRawValue1,
NativeMethods.PDH_RAW_COUNTER pRawValue2,
NativeMethods.PDH_FMT_COUNTERVALUE pFmtValue
);
#endif // !FEATURE_PAL
[DllImport(ExternDll.Kernel32, SetLastError = true)]
[ResourceExposure(ResourceScope.None)]
public static extern bool IsWow64Process(SafeProcessHandle hProcess, ref bool Wow64Process);
[StructLayout(LayoutKind.Sequential)]
internal class PROCESS_INFORMATION {
// The handles in PROCESS_INFORMATION are initialized in unmanaged functions.
// We can't use SafeHandle here because Interop doesn't support [out] SafeHandles in structures/classes yet.
public IntPtr hProcess = IntPtr.Zero;
public IntPtr hThread = IntPtr.Zero;
public int dwProcessId = 0;
public int dwThreadId = 0;
// Note this class makes no attempt to free the handles
// Use InitialSetHandle to copy to handles into SafeHandles
}
/* The following code has been removed to prevent FXCOP violations.
The code is left here incase it needs to be resurrected.
// From file src\services\timers\system\timers\safenativemethods.cs
public delegate void TimerAPCProc(IntPtr argToCompletionRoutine, int timerLowValue, int timerHighValue);
*/
#endif // !SILVERLIGHT
#if !SILVERLIGHT || FEATURE_NETCORE
#if FEATURE_NETCORE
[SecurityCritical]
#endif
[DllImport(ExternDll.Kernel32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
[ResourceExposure(ResourceScope.Machine)]
internal static extern SafeWaitHandle CreateSemaphore(NativeMethods.SECURITY_ATTRIBUTES lpSecurityAttributes, int initialCount, int maximumCount, String name);
#if FEATURE_NETCORE
[SecurityCritical]
#endif
[DllImport(ExternDll.Kernel32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
[ResourceExposure(ResourceScope.Machine)]
internal static extern SafeWaitHandle OpenSemaphore(/* DWORD */ int desiredAccess, bool inheritHandle, String name);
#if FEATURE_NETCORE
[SecurityCritical]
#else
[ResourceExposure(ResourceScope.Machine)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
#endif
[DllImport(ExternDll.Kernel32, SetLastError=true)]
internal static extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount);
#endif //!SILVERLIGHT || FEATURE_NETCORE
}
}

View File

@@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
// <copyright file="SessionEndReasons.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System.Diagnostics;
using System;
/// <devdoc>
/// <para> Specifies how the current
/// logon session is ending.</para>
/// </devdoc>
public enum SessionEndReasons {
/// <devdoc>
/// The user is logging off. The system may continue
/// running but the user who started this application
/// is logging off.
/// </devdoc>
Logoff = 1,
/// <devdoc>
/// The system is shutting down.
/// </devdoc>
SystemShutdown = 2,
}
}

View File

@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="SessionEndedEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.SessionEnded'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")]
public class SessionEndedEventArgs : EventArgs {
private readonly SessionEndReasons reason;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='Microsoft.Win32.SessionEndedEventArgs'/> class.</para>
/// </devdoc>
public SessionEndedEventArgs(SessionEndReasons reason) {
this.reason = reason;
}
/// <devdoc>
/// <para>Gets how the session ended.</para>
/// </devdoc>
public SessionEndReasons Reason {
get {
return reason;
}
}
}
}

View File

@@ -0,0 +1,21 @@
//------------------------------------------------------------------------------
// <copyright file="SessionEndedEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Represents the method that will handle the <see cref='Microsoft.Win32.SystemEvents.SessionEnded'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
public delegate void SessionEndedEventHandler(object sender, SessionEndedEventArgs e);
}

View File

@@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// <copyright file="SessionEndingEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.SessionEnding'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")]
public class SessionEndingEventArgs : EventArgs {
private bool cancel;
private readonly SessionEndReasons reason;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='Microsoft.Win32.SessionEndingEventArgs'/> class.</para>
/// </devdoc>
public SessionEndingEventArgs(SessionEndReasons reason) {
this.reason = reason;
}
/// <devdoc>
/// <para>Gets or sets a value indicating whether to cancel the user request to end the session.</para>
/// </devdoc>
public bool Cancel {
get {
return cancel;
}
set {
cancel = value;
}
}
/// <devdoc>
/// <para>Gets how the session is ending.</para>
/// </devdoc>
public SessionEndReasons Reason {
get {
return reason;
}
}
}
}

View File

@@ -0,0 +1,20 @@
//------------------------------------------------------------------------------
// <copyright file="SessionEndingEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Represents the method that will handle the <see cref='Microsoft.Win32.SystemEvents.SessionEnding'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
public delegate void SessionEndingEventHandler(object sender, SessionEndingEventArgs e);
}

View File

@@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// <copyright file="SessionSwitchEventArgs.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Provides data for the <see cref='Microsoft.Win32.SystemEvents.SessionSwitch'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")]
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.LinkDemand, Name="FullTrust")]
public class SessionSwitchEventArgs : EventArgs {
private readonly SessionSwitchReason reason;
/// <devdoc>
/// <para>Initializes a new instance of the <see cref='Microsoft.Win32.SessionSwitchEventArgs'/> class.</para>
/// </devdoc>
public SessionSwitchEventArgs(SessionSwitchReason reason) {
this.reason = reason;
}
/// <devdoc>
/// <para>Gets the reason for the session switch.</para>
/// </devdoc>
public SessionSwitchReason Reason {
get {
return reason;
}
}
}
}

View File

@@ -0,0 +1,20 @@
//------------------------------------------------------------------------------
// <copyright file="SessionSwitchEventHandler.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System;
using System.Diagnostics;
using System.Security.Permissions;
/// <devdoc>
/// <para>Represents the method that will handle the <see cref='Microsoft.Win32.SystemEvents.SessionSwitch'/> event.</para>
/// </devdoc>
[HostProtectionAttribute(MayLeakOnAbort = true)]
public delegate void SessionSwitchEventHandler(object sender, SessionSwitchEventArgs e);
}

View File

@@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// <copyright file="SessionSwitchReason.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
*/
namespace Microsoft.Win32 {
using System.Diagnostics;
using System;
/// <devdoc>
/// <para> Specifies the reason for the session switch</para>
/// </devdoc>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")]
public enum SessionSwitchReason {
/// <devdoc>
/// A session was connected to the console session.
/// </devdoc>
ConsoleConnect = NativeMethods.WTS_CONSOLE_CONNECT,
/// <devdoc>
/// A session was disconnected from the console session.
/// </devdoc>
ConsoleDisconnect = NativeMethods.WTS_CONSOLE_DISCONNECT,
/// <devdoc>
/// A session was connected to the remote session.
/// </devdoc>
RemoteConnect = NativeMethods.WTS_REMOTE_CONNECT,
/// <devdoc>
/// A session was disconnected from the remote session.
/// </devdoc>
RemoteDisconnect = NativeMethods.WTS_REMOTE_DISCONNECT,
/// <devdoc>
/// A user has logged on to the session.
/// </devdoc>
SessionLogon = NativeMethods.WTS_SESSION_LOGON,
/// <devdoc>
/// A user has logged off the session.
/// </devdoc>
SessionLogoff = NativeMethods.WTS_SESSION_LOGOFF,
/// <devdoc>
/// A session has been locked.
/// </devdoc>
SessionLock = NativeMethods.WTS_SESSION_LOCK,
/// <devdoc>
/// A session has been unlocked.
/// </devdoc>
SessionUnlock = NativeMethods.WTS_SESSION_UNLOCK,
/// <devdoc>
/// A session has changed its remote controlled status.
/// </devdoc>
SessionRemoteControl = NativeMethods.WTS_SESSION_REMOTE_CONTROL
}
}

Some files were not shown because too many files have changed in this diff Show More