All Downloads are FREE. Search and download functionalities are using the official Maven repository.

system.Environment Maven / Gradle / Ivy

/*
 *  MIT License
 *
 *  Copyright (c) 2024 MASES s.r.l.
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in all
 *  copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *  SOFTWARE.
 */

/**************************************************************************************
 * 
 *      This code was generated from a template using JCOReflector v. 1.15.0.0
 * 
 *      Manual changes to this file may cause unexpected behavior in your application.
 *      Manual changes to this file will be overwritten if the code is regenerated.
 * 
 *************************************************************************************/

package system;

import org.mases.jcobridge.*;
import org.mases.jcobridge.netreflection.*;
import java.util.ArrayList;

// Import section
import system.collections.IDictionary;
import system.collections.IDictionaryImplementation;
import system.EnvironmentVariableTarget;
import system.OperatingSystem;
import system.Version;


/**
 * The base .NET class managing System.Environment, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
 * 

* * .NET documentation at https://docs.microsoft.com/en-us/dotnet/api/System.Environment *

* * Powered by JCOBridge: more info at https://www.jcobridge.com * * @author MASES s.r.l https://masesgroup.com * @version 1.15.0.0 */ public class Environment extends NetObject { /** * Fully assembly qualified name: System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e */ public static final String assemblyFullName = "System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"; /** * Assembly name: System.Private.CoreLib */ public static final String assemblyShortName = "System.Private.CoreLib"; /** * Qualified class name: System.Environment */ public static final String className = "System.Environment"; static JCOBridge bridge = JCOBridgeInstance.getInstance(assemblyFullName); /** * The type managed from JCOBridge. See {@link JCType} */ public static JCType classType = createType(); static JCEnum enumInstance = null; JCObject classInstance = null; static JCType createType() { try { String classToCreate = className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); if (JCOReflector.getDebug()) JCOReflector.writeLog("Creating %s", classToCreate); JCType typeCreated = bridge.GetType(classToCreate); if (JCOReflector.getDebug()) JCOReflector.writeLog("Created: %s", (typeCreated != null) ? typeCreated.toString() : "Returned null value"); return typeCreated; } catch (JCException e) { JCOReflector.writeLog(e); return null; } } void addReference(String ref) throws Throwable { try { bridge.AddReference(ref); } catch (JCNativeException jcne) { throw translateException(jcne); } } /** * Internal constructor. Use with caution */ public Environment(java.lang.Object instance) throws Throwable { super(instance); if (instance instanceof JCObject) { classInstance = (JCObject) instance; } else throw new Exception("Cannot manage object, it is not a JCObject"); } public String getJCOAssemblyName() { return assemblyFullName; } public String getJCOClassName() { return className; } public String getJCOObjectName() { return className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName); } public java.lang.Object getJCOInstance() { return classInstance; } public void setJCOInstance(JCObject instance) { classInstance = instance; super.setJCOInstance(classInstance); } public JCType getJCOType() { return classType; } /** * Try to cast the {@link IJCOBridgeReflected} instance into {@link Environment}, a cast assert is made to check if types are compatible. * @param from {@link IJCOBridgeReflected} instance to be casted * @return {@link Environment} instance * @throws java.lang.Throwable in case of error during cast operation */ public static Environment cast(IJCOBridgeReflected from) throws Throwable { NetType.AssertCast(classType, from); return new Environment(from.getJCOInstance()); } // Constructors section public Environment() throws Throwable { } // Methods section public static IDictionary GetEnvironmentVariables() throws Throwable, system.PlatformNotSupportedException, system.OutOfMemoryException, system.IndexOutOfRangeException, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.FormatException, system.NotSupportedException, system.InvalidOperationException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { JCObject objGetEnvironmentVariables = (JCObject)classType.Invoke("GetEnvironmentVariables"); return new IDictionaryImplementation(objGetEnvironmentVariables); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static IDictionary GetEnvironmentVariables(EnvironmentVariableTarget target) throws Throwable, system.PlatformNotSupportedException, system.OutOfMemoryException, system.ArgumentOutOfRangeException, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.MissingMethodException, system.reflection.TargetInvocationException, system.ObjectDisposedException, system.security.SecurityException, system.ArgumentNullException, system.IndexOutOfRangeException, system.RankException, system.ArrayTypeMismatchException, system.UnauthorizedAccessException, system.io.IOException, system.FormatException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { JCObject objGetEnvironmentVariables = (JCObject)classType.Invoke("GetEnvironmentVariables", target == null ? null : target.getJCOInstance()); return new IDictionaryImplementation(objGetEnvironmentVariables); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String ExpandEnvironmentVariables(java.lang.String name) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.ArgumentNullException, system.IndexOutOfRangeException, system.FormatException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Invoke("ExpandEnvironmentVariables", name); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String GetEnvironmentVariable(java.lang.String variable, EnvironmentVariableTarget target) throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.MissingMethodException, system.reflection.TargetInvocationException, system.PlatformNotSupportedException, system.ObjectDisposedException, system.security.SecurityException, system.io.IOException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Invoke("GetEnvironmentVariable", variable, target == null ? null : target.getJCOInstance()); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String GetEnvironmentVariable(java.lang.String variable) throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.ArgumentNullException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Invoke("GetEnvironmentVariable", variable); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String[] GetCommandLineArgs() throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.IndexOutOfRangeException, system.ArgumentNullException, system.PlatformNotSupportedException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { ArrayList resultingArrayList = new ArrayList(); JCObject resultingObjects = (JCObject)classType.Invoke("GetCommandLineArgs"); for (java.lang.Object resultingObject : resultingObjects) { resultingArrayList.add(resultingObject); } java.lang.String[] resultingArray = new java.lang.String[resultingArrayList.size()]; for(int indexGetCommandLineArgs = 0; indexGetCommandLineArgs < resultingArrayList.size(); indexGetCommandLineArgs++ ) { resultingArray[indexGetCommandLineArgs] = (java.lang.String)resultingArrayList.get(indexGetCommandLineArgs); } return resultingArray; } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String[] GetLogicalDrives() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException, system.FormatException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { ArrayList resultingArrayList = new ArrayList(); JCObject resultingObjects = (JCObject)classType.Invoke("GetLogicalDrives"); for (java.lang.Object resultingObject : resultingObjects) { resultingArrayList.add(resultingObject); } java.lang.String[] resultingArray = new java.lang.String[resultingArrayList.size()]; for(int indexGetLogicalDrives = 0; indexGetLogicalDrives < resultingArrayList.size(); indexGetLogicalDrives++ ) { resultingArray[indexGetLogicalDrives] = (java.lang.String)resultingArrayList.get(indexGetLogicalDrives); } return resultingArray; } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void Exit(int exitCode) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Invoke("Exit", exitCode); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void FailFast(java.lang.String message, NetException exception) throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Invoke("FailFast", message, exception == null ? null : exception.getJCOInstance()); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void FailFast(java.lang.String message) throws Throwable, system.ArgumentException, system.NotSupportedException, system.InvalidOperationException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Invoke("FailFast", message); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void SetEnvironmentVariable(java.lang.String variable, java.lang.String value, EnvironmentVariableTarget target) throws Throwable, system.ArgumentNullException, system.ArgumentException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArrayTypeMismatchException, system.InvalidOperationException, system.FormatException, system.OutOfMemoryException, system.MissingMethodException, system.reflection.TargetInvocationException, system.ObjectDisposedException, system.security.SecurityException, system.UnauthorizedAccessException, system.io.IOException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Invoke("SetEnvironmentVariable", variable, value, target == null ? null : target.getJCOInstance()); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void SetEnvironmentVariable(java.lang.String variable, java.lang.String value) throws Throwable, system.ArgumentNullException, system.ArgumentException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.InvalidOperationException, system.FormatException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Invoke("SetEnvironmentVariable", variable, value); } catch (JCNativeException jcne) { throw translateException(jcne); } } // Properties section public static boolean getHasShutdownStarted() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Get("HasShutdownStarted"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static boolean getIs64BitOperatingSystem() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Get("Is64BitOperatingSystem"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static boolean getIs64BitProcess() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Get("Is64BitProcess"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static boolean getIsPrivilegedProcess() throws Throwable, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentException, system.MissingMethodException, system.reflection.TargetInvocationException, system.ObjectDisposedException, system.FormatException, system.InvalidOperationException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Get("IsPrivilegedProcess"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static boolean getUserInteractive() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (boolean)classType.Get("UserInteractive"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getCurrentManagedThreadId() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("CurrentManagedThreadId"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getExitCode() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("ExitCode"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void setExitCode(int ExitCode) throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Set("ExitCode", ExitCode); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getProcessId() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("ProcessId"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getProcessorCount() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("ProcessorCount"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getSystemPageSize() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("SystemPageSize"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static int getTickCount() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (int)classType.Get("TickCount"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static long getTickCount64() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (long)classType.Get("TickCount64"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static long getWorkingSet() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (long)classType.Get("WorkingSet"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static OperatingSystem getOSVersion() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.ObjectDisposedException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { JCObject val = (JCObject)classType.Get("OSVersion"); return new OperatingSystem(val); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getCommandLine() throws Throwable, system.NotSupportedException, system.ArgumentException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.IndexOutOfRangeException, system.RankException, system.ArrayTypeMismatchException, system.InvalidCastException, system.ApplicationException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("CommandLine"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getCurrentDirectory() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException, system.FormatException, system.OutOfMemoryException, system.globalization.CultureNotFoundException, system.NullReferenceException, system.runtime.interopservices.ExternalException, system.ArgumentNullException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("CurrentDirectory"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static void setCurrentDirectory(java.lang.String CurrentDirectory) throws Throwable, system.NotSupportedException, system.ArgumentException, system.ArgumentNullException, system.PlatformNotSupportedException, system.IndexOutOfRangeException, system.ArgumentOutOfRangeException, system.InvalidOperationException, system.FormatException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { classType.Set("CurrentDirectory", CurrentDirectory); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getMachineName() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("MachineName"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getNewLine() throws Throwable { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("NewLine"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getProcessPath() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException, system.FormatException, system.OutOfMemoryException, system.NullReferenceException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("ProcessPath"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getStackTrace() throws Throwable, system.PlatformNotSupportedException, system.ArgumentNullException, system.TypeLoadException, system.ArgumentException, system.io.FileLoadException, system.NotSupportedException, system.MissingMethodException, system.reflection.TargetInvocationException, system.NullReferenceException, system.globalization.CultureNotFoundException, system.ArgumentOutOfRangeException, system.ArrayTypeMismatchException, system.OutOfMemoryException, system.FormatException, system.RankException, system.IndexOutOfRangeException, system.InvalidOperationException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("StackTrace"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getSystemDirectory() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException, system.FormatException, system.OutOfMemoryException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("SystemDirectory"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getUserDomainName() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException, system.FormatException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("UserDomainName"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static java.lang.String getUserName() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.ArgumentNullException, system.InvalidOperationException, system.PlatformNotSupportedException, system.ArrayTypeMismatchException, system.NotSupportedException, system.ObjectDisposedException, system.RankException, system.IndexOutOfRangeException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { return (java.lang.String)classType.Get("UserName"); } catch (JCNativeException jcne) { throw translateException(jcne); } } public static Version getVersion() throws Throwable, system.ArgumentException, system.ArgumentOutOfRangeException, system.PlatformNotSupportedException, system.NotSupportedException, system.ObjectDisposedException, system.InvalidOperationException, system.RankException, system.ArrayTypeMismatchException, system.IndexOutOfRangeException, system.FormatException { if (classType == null) throw new UnsupportedOperationException("classType is null."); try { JCObject val = (JCObject)classType.Get("Version"); return new Version(val); } catch (JCNativeException jcne) { throw translateException(jcne); } } // Instance Events section }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy