This file contains hidden or 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
| if (routeData.Pipeline.Any()) | |
| { | |
| IAppBuilder branch = builder.New(); | |
| foreach (var middleware in routeData.Pipeline) | |
| { | |
| branch.Use(middleware); | |
| } | |
| branch.Use(typeof(RedirectMiddleware), this.next); |
This file contains hidden or 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
| ʃ.Route(ʅ => ʅ / "Hello" * Pipeline.Action<FirstComponent>() / ( | |
| ʅ / "World" * Pipeline.Action<SecondComponent>() | |
| | ʅ / "Foobar" * Pipeline.Action<ThirdComponent>())); |
This file contains hidden or 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 MyMiddleware | |
| { | |
| public Func<IDictionary<string, object>, Task> GetAppFunc(Func<IDictionary<string, object>, Task> next) | |
| { | |
| return (env) => { | |
| // do stuff | |
| await next(env); | |
| // do more stuff | |
| } | |
| } |
This file contains hidden or 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 getObjProperties = function (obj) { | |
| var objProperties = []; | |
| var val = ko.utils.unwrapObservable(obj); | |
| if (val !== null && typeof val === 'object') { | |
| for (var i in val) { | |
| if (val.hasOwnProperty(i)) objProperties.push({ "name": i, "value": val[i] }); | |
| } | |
| } |
This file contains hidden or 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 viewModel = { | |
| Name: ko.observable("Pete"), | |
| Age: ko.observable(29), | |
| Occupation: ko.observable("Developer") | |
| }; | |
| applyChangeTracking(viewModel); | |
| viewModel.Occupation("Unemployed"); |
This file contains hidden or 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 traverseObservables = function (obj, action) { | |
| ko.utils.arrayForEach(getObjProperties(obj), function (observable) { | |
| if (observable && observable.value && !observable.value.nodeType && ko.isObservable(observable.value)) { | |
| action(observable); | |
| } | |
| }); | |
| }; | |
| ko.extenders.trackChange = function (target, track) { | |
| if (track) { |
This file contains hidden or 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 viewModel = { | |
| Name: ko.observable("Pete"), | |
| Age: ko.observable(29), | |
| Skills: { | |
| Tdd: ko.observable(true), | |
| Knockout: ko.observable(true), | |
| ChangeTracking: ko.observable(false), | |
| }, | |
| Occupation: ko.observable("Developer") | |
| }; |
This file contains hidden or 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
| ko.extenders.trackChange = function (target, track) { | |
| if (track) { | |
| // ... | |
| // ... | |
| if (!target.getChanges) { | |
| target.getChanges = function (newObject) { | |
| var obj = target(); | |
| if ((typeof obj == "object") && (obj !== null)) { | |
| if (target.hasValueChanged()) { |
This file contains hidden or 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
| if ((typeof obj == "object") && (obj !== null)) { | |
| if (target.hasValueChanged()) { | |
| return ko.mapping.toJS(obj); | |
| } | |
| return getChangesFromModel(obj); | |
| } |
This file contains hidden or 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 viewModel = { | |
| Name: ko.observable("Pete"), | |
| Age: ko.observable(29), | |
| Skills: ko.observable({ | |
| Tdd: ko.observable(true), | |
| Knockout: ko.observable(true), | |
| ChangeTracking: ko.observable(false), | |
| Languages: ko.observable({ | |
| Csharp: ko.observable(false), | |
| Javascript: ko.observable(false) |