A Pen by Aran Mulholland on CodePen.
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
public class MyFunctions | |
{ | |
private readonly IOptions<ApplicationSettings> _applicationSettingsOptions; | |
private readonly IOptions<ConnectionStrings> _connectionStringsOptions; | |
public MyFunctions(IOptions<ApplicationSettings> applicationSettingsOptions, IOptions<ConnectionStrings> connectionStringsOptions) | |
{ | |
// the "Values" section of the configuration file | |
_applicationSettingsOptions = applicationSettingsOptions; | |
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
[assembly: FunctionsStartup(typeof(Startup))] | |
namespace MyFunctionsProject | |
{ | |
public class Startup : FunctionsStartup | |
{ | |
public override void Configure(IFunctionsHostBuilder builder) | |
{ | |
// this will bind to the "Values" section of the configuration | |
builder | |
.Services |
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
public class ApplicationSettings | |
{ | |
public string AzureWebJobsStorage { get; set; } | |
public string SuperApiKey { get; set; } | |
} | |
public class ConnectionStrings | |
{ | |
public string SqlConnectionString { get; set; } | |
} |
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
{ | |
"IsEncrypted": false, | |
"Values": { | |
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | |
"SuperApiKey": "VERY_SECRET_SECURE", | |
"FUNCTIONS_WORKER_RUNTIME": "dotnet" | |
}, | |
"ConnectionStrings": { | |
"SqlConnectionString": "MyConnectionString" | |
} |
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
public interface IApplicationSettings | |
{ | |
string Get(string key); | |
string Get(string key, string defaultValue); | |
} |
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
#Add the Ubuntu 12.04(precise) repositories | |
cat <<EOF >> /etc/apt/sources.list | |
deb http://archive.ubuntu.com/ubuntu precise main restricted universe | |
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe | |
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse | |
EOF | |
# Update the repos | |
apt-get update |
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
var events = require('events'); | |
function callSomething(){ | |
var eventEmitter = new events.EventEmitter(); | |
console.log("Method called"); | |
eventEmitter.emit("data", "Hello immediately (you will never see this message)"); |
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
- (void)respondToNotification:(NSNotification *)notification { | |
if (![NSThread isMainThread]) { | |
[self performSelectorOnMainThread:@selector(respondToNotification:) withObject:notification waitUntilDone:YES]; | |
return; | |
} | |
//Code here | |
} |
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
private static string RenderPartialViewToString(Controller controller, string pathToView, object viewModel, | |
ViewDataDictionary viewData = null) { | |
String result; | |
var viewEngine = ViewEngines.Engines.FindPartialView(controller.ControllerContext, pathToView); | |
using (var writer = new StringWriter()) { | |
var vd = viewData == null ? new ViewDataDictionary(viewModel) | |
: new ViewDataDictionary(viewData) { Model = viewModel }; | |
var viewContext = new ViewContext(controller.ControllerContext, | |
viewEngine.View, |
NewerOlder