get-help new-service -examples
C:\WINDOWS\system32\sc.exe create /?
var cookieContainer = new CookieContainer();
_handler = new HttpClientHandler {CookieContainer = cookieContainer};
_client = new HttpClient(_handler);
private void SaveCookie()
{
var cookies = _handler.CookieContainer.GetCookies(new Uri(BaseUrl));
var cookie = cookies["PHPSESSID"];
using (var writer = new StreamWriter(_cookieFile))
{
writer.Write(cookie.ToJson());
}
}
dynamic filesListCommand = new
{
Command = "FilesList",
Data = new { Files = new[] { "file1", "file2", "file3", "file4" } }
};
dynamic userInfoCommand = new
{
Command = "UserInfo",
Data = new { UserId = 1, UserName = "Roman" }
};
string filesListCommandJson = JsonConvert.SerializeObject(filesListCommand);
string userInfoCommandJson = JsonConvert.SerializeObject(userInfoCommand);
dynamic filesListCommandParsed = JObject.Parse(filesListCommandJson);
dynamic userInfoCommandJsonParsed = JObject.Parse(userInfoCommandJson);
string file1Value = filesListCommandParsed.Data.Files[0]; // file1
string romanValue = userInfoCommandJsonParsed.Data.UserName; // Roman
public class CommandResult
{
public string Command {get;set;}
}
public class CommandResult<T>:CommandResult
{
public T Data {get;set;}
}
public class FilesList
{
public string[] Files {get;set;}
}
public class UserInfo
{
...
}
public class MyAwesomeController:ApiController
{
public CommandResult<FilesList> GetFilesList(){
...
return new CommandResult<FilesList> (){
Command = "FilesList",
Data = new FilesList(){Files = new []{"file1","file2","file3","file4"}}
};
}
public CommandResult<UserInfo> GetUserInfo(){
...
}
}
public class MyAwesomeCommands
{
private CommandResult<FilesList> _getFilesList(){
...
return new CommandResult<FilesList> (){
Command = "FilesList",
Data = new FilesList(){Files = new []{"file1","file2","file3","file4"}}
};
}
public string GetFilesList(){
var data = getFilesList();
return JsonConvert.SerializeObject(data);
}
public string GetUserInfo(){
...
}
}
`gorm:"type:jsonb(PostgreSQL);"`