Last active
April 14, 2016 18:33
-
-
Save guitarrapc/55c0ce117d5fbe2a3fe38168659a2250 to your computer and use it in GitHub Desktop.
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
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using System.Linq; | |
public static string ToJoinedString<T>(this IEnumerable<T> source, string separator = "") | |
{ | |
return string.Join(separator, source); | |
} | |
public static IEnumerable<TSource> Concat<TSource>(this IEnumerable<TSource> source, params TSource[] values) | |
{ | |
if (source == null) throw new ArgumentNullException("source"); | |
return source.ConcatCore(values); | |
} | |
private static IEnumerable<TSource> ConcatCore<TSource>(this IEnumerable<TSource> source, params TSource[] values) | |
{ | |
foreach (var item in source) yield return item; | |
foreach (var x in values) yield return x; | |
} |
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
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using System.Linq; | |
using Octokit; | |
using Octokit.Internal; | |
public static string NugetTest() | |
{ | |
var hoge = typeof(Octokit.GitHubClient).Assembly.FullName; | |
return hoge; | |
} |
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
{ | |
"frameworks": { | |
"net46":{ | |
"dependencies": { | |
"Octokit": "0.19.0" | |
} | |
} | |
} | |
} |
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
#r "Newtonsoft.Json" | |
#load "test.csx" | |
#load "..\EnumerableExtensions.csx" | |
#load "..\NugetSample.csx" | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using System.Linq; | |
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
log.Verbose($"Webhook was triggered!"); | |
string jsonContent = await req.Content.ReadAsStringAsync(); | |
dynamic data = JsonConvert.DeserializeObject(jsonContent); | |
if (data.first == null || data.last == null) { | |
return req.CreateResponse(HttpStatusCode.BadRequest, new { | |
error = "Please pass first/last properties in the input object" | |
}); | |
} | |
// Load .csx from same directory | |
var hoge = Test(); | |
log.Verbose(hoge); | |
// Load .csx from same directory + pass TraceWriter | |
Test2(log); | |
// Load .csx from parent directory | |
var concat = Enumerable.Range(1, 10).Select(x => x * x).ToArray().ToJoinedString(","); | |
log.Verbose(concat); | |
// Load NuGet .csx test | |
var fuga = NugetTest(); | |
log.Verbose(fuga); | |
return req.CreateResponse(HttpStatusCode.OK, new { | |
greeting = $"Hello {data.first} {data.last}!" | |
}); | |
} |
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
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
public static string Test() | |
{ | |
return "External function loaded!"; | |
} | |
public static void Test2(TraceWriter log) | |
{ | |
log.Verbose($"External function2 loaded!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment