Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#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;
}
#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;
}
{
"frameworks": {
"net46":{
"dependencies": {
"Octokit": "0.19.0"
}
}
}
}
#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}!"
});
}
#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