Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (40 sloc) 1.33 KB
using System;
using System.Linq;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Script;
namespace SharpScript
{
[Route("/introspect/state")]
public class IntrospectState
{
public string Page { get; set; }
public string ProcessInfo { get; set; }
public string DriveInfo { get; set; }
}
public class StateScriptMethods : ScriptMethods
{
bool HasAccess(Process process)
{
try { return process.TotalProcessorTime >= TimeSpan.Zero; }
catch (Exception) { return false; }
}
public IEnumerable<Process> processes() => Process.GetProcesses().Where(HasAccess);
public Process processById(int processId) => Process.GetProcessById(processId);
public Process currentProcess() => Process.GetCurrentProcess();
public DriveInfo[] drives() => DriveInfo.GetDrives();
}
public class IntrospectStateServices : Service
{
public object Any(IntrospectState request)
{
var context = new ScriptContext {
ScanTypes = { typeof(StateScriptMethods) }, //Autowires (if needed)
RenderExpressionExceptions = true
}.Init();
return new PageResult(context.OneTimePage(request.Page));
}
}
}
You can’t perform that action at this time.