public new string GenerateProxy(string serviceUrl) { var proxy = _generator.GenerateProxy(serviceUrl); proxy += "\n\n" + "// Please don't use this code from the dark side"; return(proxy); }
/// <summary> /// Returns the JavaScript proxy for any hubs found in any assemblies loaded into the AppDomain /// </summary> /// <param name="signalRUrlPath">The service URL used by the connection. Defaults to "/signalr". When created dynamically this would generate at the running address, for example if you had an IIS app called "MyApp" it would generate "http://localhost:port/MyApp/signalr".</param> /// <param name="metaData">An array of lines to prepend into the file. This can be useful if you want to specify a path in your build system to a dependency such as jQuery</param> /// <returns>JavaScript proxy code</returns> public string Generate(string signalRUrlPath = "/signalr", params string[] metaData) { var generator = new DefaultJavaScriptProxyGenerator(new DefaultDependencyResolver()); var js = generator.GenerateProxy(signalRUrlPath, true); var jsToOutput = TrimComments(js); jsToOutput = PrependMetaData(jsToOutput, metaData); return(jsToOutput); }
public void MinifiesScriptUsingConfiguredMinifier() { // Arrange var hubManager = new Mock<IHubManager>(); var jsMinifier = new Mock<IJavaScriptMinifier>(); jsMinifier.Setup(m => m.Minify(It.IsAny<string>())) .Returns<string>(source => "it was minified"); var generator = new DefaultJavaScriptProxyGenerator(hubManager.Object, jsMinifier.Object); // Act var js = generator.GenerateProxy("http://localhost/testhub"); // Assert Assert.Equal("it was minified", js); }
public void MinifiesScriptUsingConfiguredMinifier() { // Arrange var hubManager = new Mock <IHubManager>(); var jsMinifier = new Mock <IJavaScriptMinifier>(); jsMinifier.Setup(m => m.Minify(It.IsAny <string>())) .Returns <string>(source => "it was minified"); var generator = new DefaultJavaScriptProxyGenerator(hubManager.Object, jsMinifier.Object); // Act var js = generator.GenerateProxy("http://localhost/testhub"); // Assert Assert.Equal("it was minified", js); }