-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
226 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using CommandLine; | ||
using CommandLine.Text; | ||
using System.Collections.Generic; | ||
|
||
namespace Unosquare.Labs.EmbedIO.Command | ||
{ | ||
internal class Options | ||
{ | ||
// TODO: Get a JSON file? | ||
//[ValueList(typeof (List<string>), MaximumElements = 1)] | ||
//public IList<string> Items { get; set; } | ||
|
||
[Option('p', "path", Required = true, HelpText = "WWW-root path.")] | ||
public string RootPath { get; set; } | ||
|
||
[OptionList('a', "api", Separator = ',', HelpText = "Specify assemblies to load, separated by a comma.")] | ||
public IList<string> ApiAssemblies { get; set; } | ||
|
||
// TODO: Add url | ||
|
||
[HelpOption] | ||
public string GetUsage() | ||
{ | ||
return HelpText.AutoBuild(this, | ||
(HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
Unosquare.Labs.EmbedIO.Command/Properties/Settings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## EmbedIO CLI | ||
|
||
Start any web folder or EmbedIO-enabled DLL from command line. | ||
|
||
### Run web folder (static content only) | ||
|
||
``` | ||
$ embediocli -p c:\wwwroot | ||
``` | ||
|
||
### Run web folder with WebAPI or WebSocket Assembly | ||
|
||
``` | ||
$ embediocli -p c:\wwwroot --api mywebapi.dll | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,13 @@ | |
public static class RestApiSample | ||
{ | ||
private const string RelativePath = "/api/"; | ||
public static List<Person> People { get; private set; } | ||
|
||
public static List<Person> People = new List<Person> | ||
{ | ||
new Person() {Key = 1, Name = "Mario Di Vece", Age = 31, EmailAddress = "[email protected]"}, | ||
new Person() {Key = 2, Name = "Geovanni Perez", Age = 32, EmailAddress = "[email protected]"}, | ||
new Person() {Key = 3, Name = "Luis Gonzalez", Age = 29, EmailAddress = "[email protected]"}, | ||
}; | ||
|
||
/// <summary> | ||
/// Here we add the WebApiModule to our Web Server and register our controller classes. | ||
|
@@ -23,13 +29,6 @@ public static class RestApiSample | |
/// <param name="server">The server.</param> | ||
public static void Setup(WebServer server) | ||
{ | ||
People = new List<Person>() | ||
{ | ||
new Person() {Key = 1, Name = "Mario Di Vece", Age = 31, EmailAddress = "[email protected]"}, | ||
new Person() {Key = 2, Name = "Geovanni Perez", Age = 32, EmailAddress = "[email protected]"}, | ||
new Person() {Key = 3, Name = "Luis Gonzalez", Age = 29, EmailAddress = "[email protected]"}, | ||
}; | ||
|
||
foreach (var person in People) | ||
{ | ||
person.PhotoUrl = GetGravatarUrl(person.EmailAddress); | ||
|
@@ -41,22 +40,23 @@ public static void Setup(WebServer server) | |
|
||
private static string GetGravatarUrl(string emailAddress) | ||
{ | ||
return string.Format("http://www.gravatar.com/avatar/{0}.png?s=100", HashMD5(emailAddress)); | ||
return string.Format("http://www.gravatar.com/avatar/{0}.png?s=100", HashMd5(emailAddress)); | ||
} | ||
|
||
private static string HashMD5(string input) | ||
private static string HashMd5(string input) | ||
{ | ||
// step 1, calculate MD5 hash from input | ||
MD5 md5 = System.Security.Cryptography.MD5.Create(); | ||
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input); | ||
MD5 md5 = MD5.Create(); | ||
byte[] inputBytes = Encoding.ASCII.GetBytes(input); | ||
byte[] hash = md5.ComputeHash(inputBytes); | ||
|
||
// step 2, convert byte array to hex string | ||
StringBuilder sb = new StringBuilder(); | ||
var sb = new StringBuilder(); | ||
for (int i = 0; i < hash.Length; i++) | ||
{ | ||
sb.Append(hash[i].ToString("x2")); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.