}
namespace Microsoft.VisualBasic.ApplicationServices
{
+ public partial class ApplicationBase
+ {
+ public ApplicationBase() { }
+ public void ChangeCulture(string cultureName) { throw null; }
+ public void ChangeUICulture(string cultureName) { throw null; }
+ public System.Globalization.CultureInfo Culture { get { throw null; } }
+ public System.Globalization.CultureInfo UICulture { get { throw null; } }
+ public string GetEnvironmentVariable(string name) { throw null; }
+ }
public partial class StartupEventArgs : System.ComponentModel.CancelEventArgs
{
public StartupEventArgs(System.Collections.ObjectModel.ReadOnlyCollection<string> args) { }
public UnhandledExceptionEventArgs(bool exitApplication, System.Exception exception) : base (default(System.Exception)) { }
public bool ExitApplication { get { throw null; } set { } }
}
+ public partial class User
+ {
+ public User() { }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ public System.Security.Principal.IPrincipal CurrentPrincipal { get { throw null; } set { } }
+ protected virtual System.Security.Principal.IPrincipal InternalPrincipal { get { throw null; } set { } }
+ public bool IsAuthenticated { get { throw null; } }
+ public bool IsInRole(string role) { throw null; }
+ public string Name { get { throw null; } }
+ }
}
namespace Microsoft.VisualBasic.CompilerServices
{
internal ProjectData() { }
public static void ClearProjectError() { }
public static System.Exception CreateProjectError(int hr) { throw null; }
+ public static void EndApp() { }
public static void SetProjectError(System.Exception ex) { }
public static void SetProjectError(System.Exception ex, int lErl) { }
}
}
namespace Microsoft.VisualBasic.Devices
{
+ public partial class Audio
+ {
+ public Audio() { }
+ }
+ public partial class Clock
+ {
+ public Clock() { }
+ public System.DateTime GmtTime { get { throw null; } }
+ public System.DateTime LocalTime { get { throw null; } }
+ public int TickCount { get { throw null; } }
+ }
+ public partial class Computer : ServerComputer
+ {
+ public Computer() { }
+ public Audio Audio { get { throw null; } }
+ public Microsoft.VisualBasic.MyServices.ClipboardProxy Clipboard { get { throw null; } }
+ public Keyboard Keyboard { get { throw null; } }
+ public Mouse Mouse { get { throw null; } }
+ public Ports Ports { get { throw null; } }
+ }
+ public partial class ComputerInfo
+ {
+ public ComputerInfo() { }
+ public System.Globalization.CultureInfo InstalledUICulture { get { throw null; } }
+ public string OSPlatform { get { throw null; } }
+ public string OSVersion { get { throw null; } }
+ }
+ public partial class Keyboard
+ {
+ public Keyboard() { }
+ }
+ public partial class Mouse
+ {
+ public Mouse() { }
+ }
+ public partial class Network
+ {
+ public Network() { }
+ }
public partial class NetworkAvailableEventArgs : System.EventArgs
{
public NetworkAvailableEventArgs(bool networkAvailable) { }
public bool IsNetworkAvailable { get { throw null; } }
}
+ public partial class Ports
+ {
+ public Ports() { }
+ }
+ public partial class ServerComputer
+ {
+ public ServerComputer() { }
+ public Clock Clock { get { throw null; } }
+ public Microsoft.VisualBasic.MyServices.FileSystemProxy FileSystem { get { throw null; } }
+ public ComputerInfo Info { get { throw null; } }
+ public string Name { get { throw null; } }
+ public Network Network { get { throw null; } }
+ public Microsoft.VisualBasic.MyServices.RegistryProxy Registry { get { throw null; } }
+ }
}
namespace Microsoft.VisualBasic.FileIO
{
OnlyErrorDialogs = 2,
}
}
+namespace Microsoft.VisualBasic.MyServices
+{
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public partial class ClipboardProxy
+ {
+ internal ClipboardProxy() { }
+ }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public partial class FileSystemProxy
+ {
+ internal FileSystemProxy() { }
+ public SpecialDirectoriesProxy SpecialDirectories { get { throw null; } }
+ }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public partial class RegistryProxy
+ {
+ internal RegistryProxy() { }
+ }
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
+ public partial class SpecialDirectoriesProxy
+ {
+ internal SpecialDirectoriesProxy() { }
+ public string AllUsersApplicationData { get { throw null; } }
+ public string CurrentUserApplicationData { get { throw null; } }
+ public string Desktop { get { throw null; } }
+ public string MyDocuments { get { throw null; } }
+ public string MyMusic { get { throw null; } }
+ public string MyPictures { get { throw null; } }
+ public string Programs { get { throw null; } }
+ public string ProgramFiles { get { throw null; } }
+ public string Temp { get { throw null; } }
+ }
+}
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
<ProjectReference Include="..\..\System.Runtime.InteropServices\ref\System.Runtime.InteropServices.csproj" />
+ <ProjectReference Include="..\..\System.Security.Principal\ref\System.Security.Principal.csproj" />
<ProjectReference Include="..\..\System.Threading.Thread\ref\System.Threading.Thread.csproj" />
</ItemGroup>
</Project>
<Compile Include="Microsoft\VisualBasic\FileIO\FileSystem.Unix.vb" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Microsoft\VisualBasic\ApplicationServices\ApplicationBase.vb" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupEventArgs.vb" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupNextInstanceEventArgs.vb" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\UnhandledExceptionEventArgs.vb" />
+ <Compile Include="Microsoft\VisualBasic\ApplicationServices\User.vb" />
<Compile Include="Microsoft\VisualBasic\CallType.vb" />
<Compile Include="Microsoft\VisualBasic\Collection.vb" />
<Compile Include="Microsoft\VisualBasic\ComClassAttribute.vb" />
<Compile Include="Microsoft\VisualBasic\ControlChars.vb" />
<Compile Include="Microsoft\VisualBasic\Conversion.vb" />
<Compile Include="Microsoft\VisualBasic\DateAndTime.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Audio.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Clock.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Computer.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ComputerInfo.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Keyboard.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Mouse.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Network.vb" />
<Compile Include="Microsoft\VisualBasic\Devices\NetworkAvailableEventArgs.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\Ports.vb" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ServerComputer.vb" />
<Compile Include="Microsoft\VisualBasic\ErrObject.vb" />
<Compile Include="Microsoft\VisualBasic\FileIO\FileSystem.vb" />
<Compile Include="Microsoft\VisualBasic\FileIO\MalformedLineException.vb" />
<Compile Include="Microsoft\VisualBasic\FileIO\SpecialDirectories.vb" />
<Compile Include="Microsoft\VisualBasic\FileIO\TextFieldParser.vb" />
+ <Compile Include="Microsoft\VisualBasic\FileSystem.vb" />
<Compile Include="Microsoft\VisualBasic\Globals.vb" />
<Compile Include="Microsoft\VisualBasic\Helpers\ForEachEnum.vb" />
<Compile Include="Microsoft\VisualBasic\HideModuleNameAttribute.vb" />
<Compile Include="Microsoft\VisualBasic\Information.vb" />
<Compile Include="Microsoft\VisualBasic\Interaction.vb" />
<Compile Include="Microsoft\VisualBasic\MyGroupCollectionAttribute.vb" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\ClipboardProxy.vb" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\FileSystemProxy.vb" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\RegistryProxy.vb" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\SpecialDirectoriesProxy.vb" />
<Compile Include="Microsoft\VisualBasic\Strings.vb" />
<Compile Include="Microsoft\VisualBasic\VariantType.vb" />
<Compile Include="Microsoft\VisualBasic\VBFixedArrayAttribute.vb" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
+ <Reference Include="System.Security.Principal" />
<Reference Include="System.Text.RegularExpressions" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Tasks" />
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports ExUtils = Microsoft.VisualBasic.CompilerServices.ExceptionUtils
+
+Namespace Microsoft.VisualBasic.ApplicationServices
+
+ '''**************************************************************************
+ ''' ;ApplicationBase
+ ''' <summary>
+ ''' Abstract class that defines the application Startup/Shutdown model for VB
+ ''' Windows Applications such as console, winforms, dll, service.
+ ''' </summary>
+ Public Class ApplicationBase
+
+ '= PUBLIC =============================================================
+
+ Public Sub New()
+ End Sub
+
+ '''**************************************************************************
+ ''' ;GetEnvironmentVariable
+ ''' <summary>
+ ''' Return the value of the specified environment variable.
+ ''' </summary>
+ ''' <param name="Name">A String containing the name of the environment variable.</param>
+ ''' <returns>A string containing the value of the environment variable.</returns>
+ ''' <exception cref="System.ArgumentNullException">if Name is Nothing. (Framework)</exception>
+ ''' <exception cref="System.Security.SecurityException">if caller does not have EnvironmentPermission.Read. (Framework)</exception>
+ ''' <exception cref="System.ArgumentException">if the specified environment variable does not exist. (Ours)</exception>
+ Public Function GetEnvironmentVariable(ByVal name As String) As String
+
+ ' Framework returns Null if not found.
+ Dim VariableValue As String = System.Environment.GetEnvironmentVariable(name)
+
+ ' Since the explicity requested a specific environment variable and we couldn't find it, throw
+ If VariableValue Is Nothing Then
+ Throw ExUtils.GetArgumentExceptionWithArgName("name", SR.EnvVarNotFound_Name, name)
+ End If
+
+ Return VariableValue
+ End Function
+
+ '**********************************************************************
+ ';Culture
+ '
+ 'Summary:
+ ' Get the information about the current culture used by the current thread.
+ 'Returns:
+ ' The CultureInfo object that represents the culture used by the current thread.
+ '**********************************************************************
+ Public ReadOnly Property Culture() As System.Globalization.CultureInfo
+ Get
+ Return System.Threading.Thread.CurrentThread.CurrentCulture
+ End Get
+ End Property
+
+ '**********************************************************************
+ ';UICulture
+ '
+ 'Summary:
+ ' Get the information about the current culture used by the Resource
+ ' Manager to look up culture-specific resource at run time.
+ 'Returns:
+ ' The CultureInfo object that represents the culture used by the
+ ' Resource Manager to look up culture-specific resources at run time.
+ '**********************************************************************
+ Public ReadOnly Property UICulture() As System.Globalization.CultureInfo
+ Get
+ Return System.Threading.Thread.CurrentThread.CurrentUICulture
+ End Get
+ End Property
+
+ '**********************************************************************
+ ';ChangeCulture
+ '
+ 'Summary:
+ ' Change the culture currently in used by the current thread.
+ 'Params:
+ ' CultureName: name of the culture as a String. For a list of possible
+ ' names, see http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationCultureInfoClassTopic.asp
+ 'Remarks:
+ ' CultureInfo constructor will throw exceptions if CultureName is Nothing
+ ' or an invalid CultureInfo ID. We are not catching those exceptions.
+ '**********************************************************************
+ Public Sub ChangeCulture(ByVal cultureName As String)
+ System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(cultureName)
+ End Sub
+
+ '**********************************************************************
+ ';ChangeUICulture
+ '
+ 'Summary:
+ ' Change the culture currently used by the Resource Manager to look
+ ' up culture-specific resource at runtime.
+ 'Params:
+ ' CultureName: name of the culture as a String. For a list of possible
+ ' names, see http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationCultureInfoClassTopic.asp
+ 'Remarks:
+ ' CultureInfo constructor will throw exceptions if CultureName is Nothing
+ ' or an invalid CultureInfo ID. We are not catching those exceptions.
+ '**********************************************************************
+ Public Sub ChangeUICulture(ByVal cultureName As String)
+ System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(cultureName)
+ End Sub
+
+ '= FRIEND =============================================================
+
+ '= PROTECTED ==========================================================
+
+ '= PRIVATE ==========================================================
+
+ End Class 'ApplicationBase
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Imports System.ComponentModel
+Imports System.Security.Principal
+
+Namespace Microsoft.VisualBasic.ApplicationServices
+
+ '''************************************************************************
+ ''';User
+ ''' <summary>
+ ''' Class abstracting the computer user
+ ''' </summary>
+ Public Class User
+
+ '==PUBLIC**************************************************************
+
+ '''********************************************************************
+ ''';New
+ ''' <summary>
+ ''' Creates an instance of User
+ ''' </summary>
+ Public Sub New()
+ End Sub
+
+ '''********************************************************************
+ ''';Name
+ ''' <summary>
+ ''' The name of the current user
+ ''' </summary>
+ Public ReadOnly Property Name() As String
+ Get
+ Return InternalPrincipal.Identity.Name
+ End Get
+ End Property
+
+ '''********************************************************************
+ ''';CurrentPrincipal
+ ''' <summary>
+ ''' The current IPrincipal which represents the current user
+ ''' </summary>
+ ''' <value>An IPrincipal representing the current user</value>
+ <EditorBrowsable(EditorBrowsableState.Advanced)> Public Property CurrentPrincipal() As IPrincipal
+ Get
+ Return InternalPrincipal
+ End Get
+ Set(ByVal value As IPrincipal)
+ InternalPrincipal = value
+ End Set
+ End Property
+
+ '''********************************************************************
+ ''';IsAuthenticated
+ ''' <summary>
+ ''' Indicates whether or not the current user has been authenticated.
+ ''' </summary>
+ Public ReadOnly Property IsAuthenticated() As Boolean
+ Get
+ Return InternalPrincipal.Identity.IsAuthenticated
+ End Get
+ End Property
+
+ '''********************************************************************
+ ''';IsInRole
+ ''' <summary>
+ ''' Indicates whether or not the current user is a member of the passed in role
+ ''' </summary>
+ ''' <param name="role">The name of the role</param>
+ ''' <returns>True if the user is a member of the role otherwise False</returns>
+ Public Function IsInRole(ByVal role As String) As Boolean
+ Return InternalPrincipal.IsInRole(role)
+ End Function
+
+ '==PROTECTED***********************************************************
+
+ ''';InternalPrincipal
+ ''' <summary>
+ ''' The principal representing the current user.
+ ''' </summary>
+ ''' <value>An IPrincipal representing the current user</value>
+ ''' <remarks>
+ ''' This should be overriden by derived classes that don't get the current
+ ''' user from the current thread
+ ''' </remarks>
+ Protected Overridable Property InternalPrincipal() As IPrincipal
+ Get
+ Return System.Threading.Thread.CurrentPrincipal
+ End Get
+ Set(ByVal value As IPrincipal)
+ System.Threading.Thread.CurrentPrincipal = value
+ End Set
+ End Property
+
+ End Class 'User
+
+End Namespace
+
' See the LICENSE file in the project root for more information.
Imports System
+Imports Microsoft.VisualBasic.FileIO
Namespace Global.Microsoft.VisualBasic.CompilerServices
<Global.System.Diagnostics.DebuggerNonUserCode()>
Public Shared Sub ClearProjectError()
Err.Clear()
End Sub
+
+ Public Shared Sub EndApp()
+ FileSystem.CloseAllFiles(System.Reflection.Assembly.GetCallingAssembly())
+ System.Environment.Exit(0) 'System.Environment.Exit will cause finalizers to be run at shutdown
+ End Sub
End Class
End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic
+
+ Namespace Devices
+
+ '''**************************************************************************
+ ''';Audio
+ ''' <summary>
+ ''' An object that makes it easy to play wav files
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Class Audio
+
+ '* PUBLIC **************************************************************
+
+ '''**********************************************************************
+ ''';New
+ ''' <summary>
+ ''' Creates a new Audio object
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Sub New()
+ End Sub
+
+ End Class 'Audio
+ End Namespace
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''**************************************************************************
+ ''' ;Clock
+ ''' <summary>
+ ''' A wrapper object that acts as a discovery mechanism to quickly find out
+ ''' the current local time of the machine and the GMT time.
+ ''' </summary>
+ Public Class Clock
+
+ '* PUBLIC *************************************************************
+
+ '''**************************************************************************
+ ''' ;LocalTime
+ ''' <summary>
+ ''' Gets a DateTime that is the current local date and time on this computer.
+ ''' </summary>
+ ''' <value>A DateTime whose value is the current date and time.</value>
+ Public ReadOnly Property LocalTime() As DateTime
+ Get
+ Return DateTime.Now
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;GmtTime
+ ''' <summary>
+ ''' Gets a DateTime that is the current local date and time on this
+ ''' computer expressed as GMT time.
+ ''' </summary>
+ ''' <value>A DateTime whose value is the current date and time expressed as GMT time.</value>
+ Public ReadOnly Property GmtTime() As DateTime
+ Get
+ Return DateTime.UtcNow
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;TickCount
+ ''' <summary>
+ ''' This property wraps the Environment.TickCount property to get the
+ ''' number of milliseconds elapsed since the system started.
+ ''' </summary>
+ ''' <value>An Integer containing the amount of time in milliseconds.</value>
+ Public ReadOnly Property TickCount() As Integer
+ Get
+ Return System.Environment.TickCount
+ End Get
+ End Property
+
+ '* FRIEND *************************************************************
+
+ '* PRIVATE ************************************************************
+
+ End Class 'Clock
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports Microsoft.VisualBasic.MyServices
+Imports System.ComponentModel
+Imports System.Security.Permissions
+Imports Microsoft.VisualBasic
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''**************************************************************************
+ ''' ;Computer
+ ''' <summary>
+ ''' A RAD object representing the 'computer' that serves as a discovery
+ ''' mechanism for finding principle abstractions in the system that you can
+ ''' code against such as the file system, the clipboard, performance
+ ''' counters, etc. It also provides functionality you would expect to see
+ ''' associated with the computer such as playing sound, timers, access to
+ ''' environment variables, etc. This class represent a general computer
+ ''' available from a Windows Application, Web app, Dll library, etc.
+ ''' </summary>
+ Public Class Computer : Inherits ServerComputer
+
+ '= PUBLIC =============================================================
+
+ 'NOTE: The .Net design guidelines state that access to Instance members does not have to be thread-safe. Access to Shared members does have to be thread-safe.
+ 'Since My.Computer creates the instance of Computer in a thread-safe way, access to the Computer will necessarily be thread-safe.
+ 'There is nothing to prevent a user from passing our computer object across threads or creating their own instance and then getting into trouble.
+ ' But that is completely consistent with the rest of the FX design. It is MY.* that is thread safe and leads to best practice access to these objects.
+ ' If you dim them up yourself, you are responsible for managing the threading.
+
+ '''**************************************************************************
+ ''' ;Audio
+ ''' <summary>
+ ''' Get an Audio object which can play sound files or resources.
+ ''' </summary>
+ ''' <value>A sound object.</value>
+ Public ReadOnly Property Audio() As Audio
+ Get
+ If m_Audio IsNot Nothing Then Return m_Audio
+ m_Audio = New Audio()
+ Return m_Audio
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Clipboard
+ ''' <summary>
+ ''' A thin wrapper for System.Windows.Forms.Clipboard
+ ''' </summary>
+ ''' <value>An object representing the clipboard</value>
+ Public ReadOnly Property Clipboard() As ClipboardProxy
+ Get
+ If m_Clipboard Is Nothing Then
+ m_Clipboard = New ClipboardProxy()
+ End If
+
+ Return m_Clipboard
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Ports
+ ''' <summary>
+ ''' Gets a port object which gives access to the ports on the local machine
+ ''' </summary>
+ ''' <value>A collection of serial ports on the machine.</value>
+ Public ReadOnly Property Ports() As Ports
+ Get
+ If m_Ports Is Nothing Then
+ m_Ports = New Ports()
+ End If
+
+ Return m_Ports
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Mouse
+ ''' <summary>
+ ''' This property returns the Mouse object containing information about
+ ''' the physical mouse installed to the machine.
+ ''' </summary>
+ ''' <value>An instance of the Mouse class.</value>
+ Public ReadOnly Property Mouse() As Mouse
+ Get
+ If m_Mouse IsNot Nothing Then Return m_Mouse
+ m_Mouse = New Mouse
+ Return m_Mouse
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Keyboard
+ ''' <summary>
+ ''' This property returns the Keyboard object representing some
+ ''' keyboard properties and a send keys method
+ ''' </summary>
+ ''' <value>An instance of the Keyboard class.</value>
+ Public ReadOnly Property Keyboard() As Keyboard
+ Get
+ If m_KeyboardInstance IsNot Nothing Then Return m_KeyboardInstance
+ m_KeyboardInstance = New Keyboard
+ Return m_KeyboardInstance
+ End Get
+ End Property
+
+ '= FRIENDS ============================================================
+
+ '= PROTECTED ==========================================================
+
+ '= PRIVATE ============================================================
+
+ Private m_Audio As Audio 'Lazy initialized cache for the Audio class.
+ Private m_Ports As Ports 'Lazy initialized cache for the Ports class
+ Private Shared m_Clipboard As ClipboardProxy 'Lazy initialized cacche for the clipboard class. (proxies can be shared - they have no state)
+ Private Shared m_Mouse As Mouse 'Lazy initialized cache for the Mouse class. SHARED because Mouse behaves as a readonly singleton class
+ Private Shared m_KeyboardInstance As Keyboard 'Lazy initialized cache for the Keyboard class. SHARED because Keyboard behaves as a readonly singleton class
+
+ End Class 'Computer
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System
+Imports System.Diagnostics
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''*************************************************************************
+ ''' ;ComputerInfo
+ ''' <summary>
+ ''' Provides configuration information about the current computer and the current process.
+ ''' </summary>
+ <DebuggerTypeProxy(GetType(ComputerInfo.ComputerInfoDebugView))>
+ Public Class ComputerInfo
+
+ ' Keep the debugger proxy current as you change this class - see the nested ComputerInfoDebugView below.
+
+ '= PUBLIC =============================================================
+
+ '''******************************************************************************
+ ''' ;New
+ ''' <summary>
+ ''' Default ctor
+ ''' </summary>
+ Sub New()
+ End Sub
+
+ '''******************************************************************************
+ ''' ;InstalledUICulture
+ ''' <summary>
+ ''' Gets the current UICulture installed on the machine.
+ ''' </summary>
+ ''' <value>A CultureInfo object represents the UI culture installed on the machine.</value>
+ Public ReadOnly Property InstalledUICulture() As Globalization.CultureInfo
+ Get
+ Return Globalization.CultureInfo.InstalledUICulture
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;OSPlatform
+ ''' <summary>
+ ''' Gets the platform OS name.
+ ''' </summary>
+ ''' <value>A string containing a Platform ID like "Win32NT", "Win32S", "Win32Windows". See PlatformID enum.</value>
+ ''' <exception cref="System.ExecutionEngineException">If cannot obtain the OS Version information.</exception>
+ Public ReadOnly Property OSPlatform() As String
+ Get
+ Return Environment.OSVersion.Platform.ToString
+ End Get
+ End Property
+
+ '''******************************************************************************
+ ''' ;OSVersion
+ ''' <summary>
+ ''' Get the current version number of the operating system.
+ ''' </summary>
+ ''' <value>A string contains the current version number of the operating system.</value>
+ ''' <exception cref="System.ExecutionEngineException">If cannot obtain the OS Version information.</exception>
+ Public ReadOnly Property OSVersion() As String
+ Get
+ Return Environment.OSVersion.Version.ToString
+ End Get
+ End Property
+
+ '= FRIEND =============================================================
+
+ '''******************************************************************************
+ ''' ;ComputerInfoDebugView
+ ''' <summary>
+ ''' Debugger proxy for the ComputerInfo class. The problem is that OSFullName can time out the debugger
+ ''' so we offer a view that doesn't have that field.
+ ''' </summary>
+ ''' <remarks></remarks>
+ Friend NotInheritable Class ComputerInfoDebugView
+ Public Sub New(ByVal RealClass As ComputerInfo)
+ m_InstanceBeingWatched = RealClass
+ End Sub
+
+ <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+ Public ReadOnly Property InstalledUICulture() As Globalization.CultureInfo
+ Get
+ Return m_InstanceBeingWatched.InstalledUICulture
+ End Get
+ End Property
+
+ <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+ Public ReadOnly Property OSPlatform() As String
+ Get
+ Return m_InstanceBeingWatched.OSPlatform
+ End Get
+ End Property
+
+ <DebuggerBrowsable(DebuggerBrowsableState.RootHidden)>
+ Public ReadOnly Property OSVersion() As String
+ Get
+ Return m_InstanceBeingWatched.OSVersion
+ End Get
+ End Property
+
+ <DebuggerBrowsable(DebuggerBrowsableState.Never)> Private m_InstanceBeingWatched As ComputerInfo
+ End Class
+
+ End Class
+
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '*****************************************************************************
+ ';Keyboard
+ '
+ 'Remarks: A class representing a computer keyboard. Enables discovery of key
+ ' state information for the most common scenarios and enables SendKeys
+ '*****************************************************************************
+ Public Class Keyboard
+
+ End Class
+
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''**************************************************************************
+ ''' ;Mouse
+ ''' <summary>
+ ''' A wrapper object that acts as a discovery mechanism for finding
+ ''' information about the mouse on your computer such as whether the mouse
+ ''' exists, the number of buttons, wheelscrolls details.
+ '''
+ ''' This class is a Singleton Class. See Common.Computer for details.
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Class Mouse
+
+ End Class 'Mouse
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''**************************************************************************
+ ''';Network
+ ''' <summary>
+ ''' An object that allows easy access to some simple network properties and functionality.
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Class Network
+
+ '* PUBLIC *************************************************************
+
+ '''**********************************************************************
+ ''';New - Constructor
+ ''' <summary>
+ ''' Creates class and hooks up events
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Sub New()
+ End Sub
+
+ End Class
+
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''*************************************************************************
+ ''';Ports
+ ''' <summary>
+ ''' Gives access to Ports on the local machine
+ ''' </summary>
+ ''' <remarks>Only serial ports are supported at present, but this class may expand in the future</remarks>
+ Public Class Ports
+
+ '==PUBLIC**************************************************************
+
+ '''*********************************************************************
+ ''';New
+ ''' <summary>
+ ''' Constructor
+ ''' </summary>
+ ''' <remarks></remarks>
+ Public Sub New()
+ End Sub
+
+ End Class
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports System.ComponentModel
+Imports System.Security.Permissions
+Imports Microsoft.VisualBasic
+Imports Microsoft.VisualBasic.MyServices
+
+Namespace Microsoft.VisualBasic.Devices
+
+ '''**************************************************************************
+ ''' ;ServerComputer
+ ''' <summary>
+ ''' A RAD object representing the server 'computer' for the web/Windows Services
+ ''' that serves as a discovery mechanism for finding principle abstractions in
+ ''' the system that you can code against
+ ''' </summary>
+ Public Class ServerComputer
+
+ '= PUBLIC =============================================================
+
+ 'NOTE: The .Net design guidelines state that access to Instance members does not have to be thread-safe. Access to Shared members does have to be thread-safe.
+ 'Since My.Computer creates the instance of Computer in a thread-safe way, access to the Computer will necessarily be thread-safe.
+ 'There is nothing to prevent a user from passing our computer object across threads or creating their own instance and then getting into trouble.
+ 'But that is completely consistent with the rest of the FX design. It is MY.* that is thread safe and leads to best practice access to these objects.
+ 'If you dim them up yourself, you are responsible for managing the threading.
+
+ '''**************************************************************************
+ ''' ;Clock
+ ''' <summary>
+ ''' Returns the Clock object which contains the LocalTime and GMTTime.
+ ''' </summary>
+ Public ReadOnly Property Clock() As Clock
+ Get
+ If m_Clock IsNot Nothing Then Return m_Clock
+ m_Clock = New Clock
+ Return m_Clock
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;FileSystem
+ ''' <summary>
+ ''' Gets the object representing the file system of the computer.
+ ''' </summary>
+ ''' <value>A System.IO.FileSystem object.</value>
+ ''' <remarks>The instance returned by this property is lazy initialized and cached.</remarks>
+ Public ReadOnly Property FileSystem() As FileSystemProxy
+ Get
+ If m_FileIO Is Nothing Then
+ m_FileIO = New FileSystemProxy
+ End If
+ Return m_FileIO
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Info
+ ''' <summary>
+ ''' Gets the object representing information about the computer's state
+ ''' </summary>
+ ''' <value>A Microsoft.VisualBasic.MyServices.ComputerInfo object.</value>
+ ''' <remarks>The instance returned by this property is lazy initialized and cached.</remarks>
+ Public ReadOnly Property Info() As ComputerInfo
+ Get
+ If m_ComputerInfo Is Nothing Then
+ m_ComputerInfo = New ComputerInfo
+ End If
+ Return m_ComputerInfo
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Network
+ ''' <summary>
+ ''' This property returns the Network object containing information about
+ ''' the network the machine is part of.
+ ''' </summary>
+ ''' <value>An instance of the Network.Network class.</value>
+ Public ReadOnly Property Network() As Network
+ Get
+ If m_Network IsNot Nothing Then Return m_Network
+ m_Network = New Network
+ Return m_Network
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Name
+ ''' <summary>
+ ''' This property wraps the System.Environment.MachineName property
+ ''' in the .NET framework to return the name of the computer.
+ ''' </summary>
+ ''' <value>A string containing the name of the computer.</value>
+ Public ReadOnly Property Name() As String
+ Get
+ Return System.Environment.MachineName
+ End Get
+ End Property
+
+ '''**************************************************************************
+ ''' ;Registry
+ ''' <summary>
+ ''' Get the Registry object, which can be used to read, set and
+ ''' enumerate keys and values in the system registry.
+ ''' </summary>
+ ''' <value>An instance of the RegistryProxy object</value>
+ ''' <remarks></remarks>
+ Public ReadOnly Property Registry() As RegistryProxy
+ Get
+ If m_RegistryInstance IsNot Nothing Then Return m_RegistryInstance
+ m_RegistryInstance = New RegistryProxy
+ Return m_RegistryInstance
+ End Get
+ End Property
+
+ '= FRIENDS ============================================================
+
+ '= PROTECTED ==========================================================
+
+ '= PRIVATE ============================================================
+
+ Private m_ComputerInfo As ComputerInfo 'Lazy initialized cache for ComputerInfo
+ Private m_FileIO As FileSystemProxy 'Lazy initialized cache for the FileSystem.
+ Private m_Network As Network 'Lazy initialized cache for the Network class.
+ Private m_RegistryInstance As RegistryProxy 'Lazy initialized cache for the Registry class
+ Private Shared m_Clock As Clock 'Lazy initialized cache for the Clock class. SHARED because Clock behaves as a readonly singleton class
+
+ End Class 'MyServerComputer
+End Namespace
Get
' NOTE: Don't cache the collection since it may change without us knowing.
' The performance hit will be small since it's a small collection.
- ' CONSIDER: : Create a read-only collection from an array?
Dim DriveInfoCollection As New ObjectModel.Collection(Of System.IO.DriveInfo)
For Each DriveInfo As System.IO.DriveInfo In IO.DriveInfo.GetDrives()
DriveInfoCollection.Add(DriveInfo)
End Sub
''' <summary>
- ''' Validates that the value being passed as an AudioPlayMode enum is a legal value
+ ''' Validates that the value being passed as an FieldType is a legal value
''' </summary>
''' <param name="value"></param>
''' <remarks></remarks>
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System
+
+Namespace Microsoft.VisualBasic
+
+ Friend Module FileSystem
+
+ Friend Sub CloseAllFiles(ByVal assem As System.Reflection.Assembly)
+ ' CloseAllFiles(ProjectData.GetProjectData().GetAssemblyData(assem))
+ End Sub
+
+ End Module
+End Namespace
+
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Explicit On
+Option Strict On
+
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+ '''*****************************************************************************
+ ''';ClipboardProxy
+ ''' <summary>
+ ''' A class that wraps System.Windows.Forms.Clipboard so that
+ ''' a clipboard can be instanced.
+ ''' </summary>
+ <EditorBrowsable(EditorBrowsableState.Never)>
+ Public Class ClipboardProxy
+
+ '==PUBLIC*******************************************************************
+
+ '''*************************************************************************
+ ''';New
+ ''' <summary>
+ ''' Only Allows instantiation of the class
+ ''' </summary>
+ Friend Sub New()
+ End Sub
+
+ End Class
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Option Strict On
+Option Explicit On
+
+Imports System
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+ '''******************************************************************************
+ ''' ;FileSystemProxy
+ ''' <summary>
+ ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.FileSystem to expose the type through My.
+ ''' </summary>
+ <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+ Public Class FileSystemProxy
+
+ '= PUBLIC =============================================================
+
+ Public ReadOnly Property SpecialDirectories() As MyServices.SpecialDirectoriesProxy
+ Get
+ If m_SpecialDirectoriesProxy Is Nothing Then
+ m_SpecialDirectoriesProxy = New SpecialDirectoriesProxy
+ End If
+ Return m_SpecialDirectoriesProxy
+ End Get
+ End Property
+
+ '= FRIEND =============================================================
+
+ '''******************************************************************************
+ ''' ;New
+ ''' <summary>
+ ''' Proxy class can only created by internal classes.
+ ''' </summary>
+ Friend Sub New()
+ End Sub
+
+ Private m_SpecialDirectoriesProxy As SpecialDirectoriesProxy = Nothing
+ End Class
+End Namespace
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System.ComponentModel
+
+Namespace Microsoft.VisualBasic.MyServices
+
+ '''*************************************************************************
+ ''' ;RegistryProxy
+ ''' <summary>
+ ''' An extremely thin wrapper around Microsoft.Win32.Registry to expose the type through My.
+ ''' </summary>
+ <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+ Public Class RegistryProxy
+
+ '= FRIEND =============================================================
+
+ '''*************************************************************************
+ ''' ;New
+ ''' <summary>
+ ''' Proxy class can only created by internal classes.
+ ''' </summary>
+ Friend Sub New()
+ End Sub
+
+ End Class
+End Namespace
+
--- /dev/null
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System.ComponentModel
+Imports Microsoft.VisualBasic.FileIO
+
+Namespace Microsoft.VisualBasic.MyServices
+
+ '''*************************************************************************
+ ''' ;SpecialDirectoriesProxy
+ ''' <summary>
+ ''' An extremely thin wrapper around Microsoft.VisualBasic.FileIO.SpecialDirectories to expose the type through My.
+ ''' </summary>
+ <System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)>
+ Public Class SpecialDirectoriesProxy
+
+ '= PUBLIC =============================================================
+
+ Public ReadOnly Property MyDocuments() As String
+ Get
+ Return SpecialDirectories.MyDocuments
+ End Get
+ End Property
+
+ Public ReadOnly Property MyMusic() As String
+ Get
+ Return SpecialDirectories.MyMusic
+ End Get
+ End Property
+
+ Public ReadOnly Property MyPictures() As String
+ Get
+ Return SpecialDirectories.MyPictures
+ End Get
+ End Property
+
+ Public ReadOnly Property Desktop() As String
+ Get
+ Return SpecialDirectories.Desktop
+ End Get
+ End Property
+
+ Public ReadOnly Property Programs() As String
+ Get
+ Return SpecialDirectories.Programs
+ End Get
+ End Property
+
+ Public ReadOnly Property ProgramFiles() As String
+ Get
+ Return SpecialDirectories.ProgramFiles
+ End Get
+ End Property
+
+ Public ReadOnly Property Temp() As String
+ Get
+ Return SpecialDirectories.Temp
+ End Get
+ End Property
+
+ Public ReadOnly Property CurrentUserApplicationData() As String
+ Get
+ Return SpecialDirectories.CurrentUserApplicationData
+ End Get
+ End Property
+
+ Public ReadOnly Property AllUsersApplicationData() As String
+ Get
+ Return SpecialDirectories.AllUsersApplicationData
+ End Get
+ End Property
+
+ '= FRIEND =============================================================
+
+ '''*************************************************************************
+ ''' ;New
+ ''' <summary>
+ ''' Proxy class can only created by internal classes.
+ ''' </summary>
+ Friend Sub New()
+ End Sub
+
+ End Class
+
+End Namespace
<BuildConfigurations>
netcoreapp;
uap;
+ netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>
\ No newline at end of file
[Fact]
public void FilterDefaultMessage()
{
- ProjectData.SetProjectError(new System.IO.FileNotFoundException("Description"));
- Assert.Equal("Description", Information.Err().Description);
+ string message = "Description";
+ ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+ Assert.Equal(message, Information.Err().Description);
- ProjectData.SetProjectError(new System.IO.FileNotFoundException(""));
- Assert.Equal("ID53", Information.Err().Description);
+ message = "";
+ ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+ Assert.NotEqual(message, Information.Err().Description);
- ProjectData.SetProjectError(new System.IO.FileNotFoundException("Exception from HRESULT: 0x80"));
- Assert.Equal("ID53", Information.Err().Description);
+ message = "Exception from HRESULT: 0x80";
+ ProjectData.SetProjectError(new System.IO.FileNotFoundException(message));
+ Assert.NotEqual(message, Information.Err().Description);
}
}
}
<Compile Include="LateBindingTests.cs" />
<Compile Include="LikeOperatorTests.cs" />
<Compile Include="LongTypeTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\ApplicationServices\ApplicationBaseTests.cs" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupEventArgsTests.cs" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\StartupNextInstanceEventArgsTests.cs" />
<Compile Include="Microsoft\VisualBasic\ApplicationServices\UnhandledExceptionEventArgsTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\ApplicationServices\UserTests.cs" />
<Compile Include="Microsoft\VisualBasic\ComClassAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\CompilerServices\DesignerGeneratedAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\CompilerServices\OptionCompareAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\CompilerServices\OptionTextAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\CompilerServices\StandardModuleAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\CompilerServices\StructUtilsTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ClockTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ComputerInfoTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ComputerTests.cs" />
<Compile Include="Microsoft\VisualBasic\Devices\NetworkAvailableEventArgsTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\Devices\ServerComputerTests.cs" />
<Compile Include="Microsoft\VisualBasic\HideModuleNameAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\MyGroupCollectionAttributeTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\FileSystemProxyTests.cs" />
+ <Compile Include="Microsoft\VisualBasic\MyServices\SpecialDirectoriesProxyTests.cs" />
<Compile Include="Microsoft\VisualBasic\VBFixedArrayAttributeTests.cs" />
<Compile Include="Microsoft\VisualBasic\VBFixedStringAttributeTests.cs" />
<Compile Include="ObjectTypeTests.cs" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.ApplicationServices.Tests
+{
+ public class ApplicationBaseTests
+ {
+ [Fact]
+ public void Culture()
+ {
+ var app = new ApplicationBase();
+ var culture = app.Culture;
+ Assert.Equal(System.Threading.Thread.CurrentThread.CurrentCulture, culture);
+ try
+ {
+ app.ChangeCulture("en-US");
+ Assert.Equal(System.Threading.Thread.CurrentThread.CurrentCulture, app.Culture);
+ Assert.Equal("en-US", app.Culture.Name);
+ }
+ finally
+ {
+ System.Threading.Thread.CurrentThread.CurrentCulture = culture;
+ }
+ }
+
+ [Fact]
+ public void UICulture()
+ {
+ var app = new ApplicationBase();
+ var culture = app.UICulture;
+ Assert.Equal(System.Threading.Thread.CurrentThread.CurrentUICulture, culture);
+ try
+ {
+ app.ChangeUICulture("en-US");
+ Assert.Equal(System.Threading.Thread.CurrentThread.CurrentUICulture, app.UICulture);
+ Assert.Equal("en-US", app.UICulture.Name);
+ }
+ finally
+ {
+ System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
+ }
+ }
+
+ [Fact]
+ public void GetEnvironmentVariable()
+ {
+ var app = new ApplicationBase();
+ var variables = System.Environment.GetEnvironmentVariables().Keys;
+ foreach (string variable in variables)
+ {
+ Assert.Equal(System.Environment.GetEnvironmentVariable(variable), app.GetEnvironmentVariable(variable));
+ break;
+ }
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.ApplicationServices.Tests
+{
+ public class UserTests
+ {
+ [Fact]
+ public void Properties()
+ {
+ var user = new User();
+ Assert.Equal(System.Threading.Thread.CurrentPrincipal, user.CurrentPrincipal);
+ if (user.CurrentPrincipal != null)
+ {
+ Assert.Equal(System.Threading.Thread.CurrentPrincipal.Identity.Name, user.Name);
+ Assert.Equal(System.Threading.Thread.CurrentPrincipal.Identity.IsAuthenticated, user.IsAuthenticated);
+ Assert.Equal(System.Threading.Thread.CurrentPrincipal.IsInRole("Guest"), user.IsInRole("Guest"));
+ }
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+ public class ClockTests
+ {
+ [Fact]
+ public void LocalTime()
+ {
+ var clock = new Clock();
+
+ var before = clock.LocalTime;
+ System.Threading.Thread.Sleep(10);
+
+ var now = DateTime.Now;
+ System.Threading.Thread.Sleep(10);
+
+ var after = clock.LocalTime;
+
+ Assert.True(before <= now);
+ Assert.True(now <= after);
+ }
+
+ [Fact]
+ public void GmtTime()
+ {
+ var clock = new Clock();
+
+ var before = clock.GmtTime;
+ System.Threading.Thread.Sleep(10);
+
+ var now = DateTime.UtcNow;
+ System.Threading.Thread.Sleep(10);
+
+ var after = clock.GmtTime;
+
+ Assert.True(before <= now);
+ Assert.True(now <= after);
+ }
+
+ [Fact]
+ public void TickCount()
+ {
+ var clock = new Clock();
+
+ var before = clock.TickCount;
+ System.Threading.Thread.Sleep(10);
+
+ var after = clock.TickCount;
+ Assert.True(before <= after);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+ public class ComputerInfoTests
+ {
+ [Fact]
+ public void Properties()
+ {
+ var info = new ComputerInfo();
+ Assert.Equal(System.Globalization.CultureInfo.InstalledUICulture, info.InstalledUICulture);
+ Assert.Equal(System.Environment.OSVersion.Platform.ToString(), info.OSPlatform);
+ Assert.Equal(System.Environment.OSVersion.Version.ToString(), info.OSVersion);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+ public class ComputerTests
+ {
+ [Fact]
+ public void Properties()
+ {
+ var computer = new Computer();
+
+ var audio = computer.Audio;
+ Assert.NotNull(audio);
+ Assert.Same(audio, computer.Audio);
+
+ var clipboard = computer.Clipboard;
+ Assert.NotNull(clipboard);
+ Assert.Same(clipboard, computer.Clipboard);
+
+ var keyboard = computer.Keyboard;
+ Assert.NotNull(keyboard);
+ Assert.Same(keyboard, computer.Keyboard);
+
+ var mouse = computer.Mouse;
+ Assert.NotNull(mouse);
+ Assert.Same(mouse, computer.Mouse);
+
+ var ports = computer.Ports;
+ Assert.NotNull(ports);
+ Assert.Same(ports, computer.Ports);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Xunit;
+
+namespace Microsoft.VisualBasic.Devices.Tests
+{
+ public class ServerComputerTests
+ {
+ [Fact]
+ public void Properties()
+ {
+ var computer = new ServerComputer();
+
+ Assert.Equal(System.Environment.MachineName, computer.Name);
+
+ var clock = computer.Clock;
+ Assert.NotNull(clock);
+ Assert.Same(clock, computer.Clock);
+
+ var fileSystem = computer.FileSystem;
+ Assert.NotNull(fileSystem);
+ Assert.Same(fileSystem, computer.FileSystem);
+
+ var info = computer.Info;
+ Assert.NotNull(info);
+ Assert.Same(info, computer.Info);
+
+ var network = computer.Network;
+ Assert.NotNull(network);
+ Assert.Same(network, computer.Network);
+
+ var registry = computer.Registry;
+ Assert.NotNull(registry);
+ Assert.Same(registry, computer.Registry);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.VisualBasic.Devices;
+using Xunit;
+
+namespace Microsoft.VisualBasic.MyServices.Tests
+{
+ public class FileSystemProxyTests
+ {
+ [Fact]
+ public void SpecialDirectories()
+ {
+ FileSystemProxy fileSystem = new ServerComputer().FileSystem;
+ var specialDirectories = fileSystem.SpecialDirectories;
+ Assert.NotNull(specialDirectories);
+ Assert.Same(specialDirectories, fileSystem.SpecialDirectories);
+ }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using Microsoft.VisualBasic.Devices;
+using Xunit;
+
+namespace Microsoft.VisualBasic.MyServices.Tests
+{
+ public class SpecialDirectoriesProxyTests
+ {
+ [Fact]
+ public void Properties()
+ {
+ SpecialDirectoriesProxy specialDirectories = new ServerComputer().FileSystem.SpecialDirectories;
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.AllUsersApplicationData, () => specialDirectories.AllUsersApplicationData);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.CurrentUserApplicationData, () => specialDirectories.CurrentUserApplicationData);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Desktop, () => specialDirectories.Desktop);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyDocuments, () => specialDirectories.MyDocuments);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyMusic, () => specialDirectories.MyMusic);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.MyPictures, () => specialDirectories.MyPictures);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Programs, () => specialDirectories.Programs);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.ProgramFiles, () => specialDirectories.ProgramFiles);
+ VerifySpecialDirectory(() => Microsoft.VisualBasic.FileIO.SpecialDirectories.Temp, () => specialDirectories.Temp);
+ }
+
+ private static void VerifySpecialDirectory(Func<string> getExpected, Func<string> getActual)
+ {
+ string expected;
+ try
+ {
+ expected = getExpected();
+ }
+ catch (Exception)
+ {
+ return;
+ }
+ string actual = getActual();
+ Assert.Equal(expected, actual);
+ }
+ }
+}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.VisualBasic.CompilerServices;
+using Microsoft.DotNet.RemoteExecutor;
using System;
using Xunit;
Assert.Null(Information.Err().GetException());
Assert.Equal(0, Information.Err().Erl);
}
+
+ [Fact]
+ public void EndApp()
+ {
+ RemoteExecutor.Invoke(new Action(() =>
+ {
+ ProjectData.EndApp();
+ throw new Exception(); // Shouldn't reach here.
+ }),
+ new RemoteInvokeOptions() { ExpectedExitCode = 0 }).Dispose();
+ }
}
}