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
//http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api | |
//Install-Package Microsoft.AspNet.WebApi.Cors | |
public static class WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
// Web API configuration and services | |
config.EnableCors(new EnableCorsAttribute("*", "*", "GET,POST,PUT,DELETE")); | |
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
/// <reference path="../references.ts" /> | |
module Common.Framework { | |
"use strict"; | |
export interface IControllerScope<T> extends ng.IScope { | |
vm: T; | |
} | |
export class BaseCtrl { | |
public static $inject = ["$scope"]; |
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 static class XmlSerializationUtil | |
{ | |
public static string Serialize<T>(this T toSerialize) | |
{ | |
XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); | |
StringWriter textWriter = new StringWriter(); | |
xmlSerializer.Serialize(textWriter, toSerialize); | |
return textWriter.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
public static class XslUtil | |
{ | |
public static string Transform(this string xml, string transformXslFile) | |
{ | |
XslTransform xslt = new XslTransform(); | |
xslt.Load(transformXslFile); | |
XPathDocument xpath = new XPathDocument(XmlReader.Create(new StringReader(xml))); | |
XmlReader xmlReader = xslt.Transform(xpath, null); | |
if (xmlReader != null) |
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
module App { | |
"use strict"; | |
//Method name should be exactly "response" - http://docs.angularjs.org/api/ng/service/$http | |
export interface IInterceptor { | |
request: Function; | |
requestError: Function; | |
response: Function; | |
responseError: Function; | |
} |
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
export class ClientContainerCtrl { | |
public static $inject = ["$scope", "$http", "$state", "ApiConfig", "popup"]; | |
constructor(public $scope: ng-IScope, public $http: ng.IHttpService | |
, public $state: ng.ui.IStateService, public ApiConfig: IApiConfig, public popup: Common.Services.ModalService | |
) { | |
super($scope, $http); | |
this.init(); | |
} |
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
module CommonServices { | |
export class DataService<T> { | |
public data: T; | |
private observerCallbacks = []; // Observer pattern implementation | |
public registerCallback = (callback) => { | |
this.observerCallbacks.push(callback); | |
}; | |
public setData = (instance: T) => { | |
this.data = instance; |
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
myApp.provider("Localization", { | |
loadResource: ["Localization", (Localization) => | |
Localization.loadResource(this.resourceName === undefined || this.resourceName === null ? this.controller : this.resourceName) | |
], | |
$get: ["$http", ($http: angular.IHttpService) => { | |
return { | |
loadResource: (resourceName?: string) => $http.get("<localization api>") | |
}; | |
}] |
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
/// <reference path="../../_references.ts" /> | |
module Common.Services { | |
"use strict"; | |
export class ModalService implements Common.Framework.IModalContainer { | |
public static $inject = ["$modal"]; | |
public static Factory($modal: ng.ui.bootstrap.IModalService) { | |
return new ModalService($modal); |
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 static class Extensions | |
{ | |
public static string GetEnumDescription(this Enum value) | |
{ | |
if (value == null) return string.Empty; | |
FieldInfo fi = value.GetType().GetField(value.ToString()); | |
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); | |
return (attributes != null && attributes.Length > 0) ? attributes[0].Description : value.ToString(); | |
} |
OlderNewer