private static string GenerateProxy(IHubManager hubManager, IJavaScriptMinifier javaScriptMinifier, bool includeDocComments) { string script = _templateFromResource.Value; var hubs = new StringBuilder(); var first = true; foreach (var descriptor in hubManager.GetHubs().OrderBy(h => h.Name)) { if (!first) { hubs.AppendLine(";"); hubs.AppendLine(); hubs.Append(" "); } GenerateType(hubManager, hubs, descriptor, includeDocComments); first = false; } if (hubs.Length > 0) { hubs.Append(";"); } script = script.Replace("/*hubs*/", hubs.ToString()); return(javaScriptMinifier.Minify(script)); }
public static IEnumerable <HubDescriptor> GetHubs(this IHubManager hubManager) { if (hubManager == null) { throw new ArgumentNullException("hubManager"); } return(hubManager.GetHubs(d => true)); }
private static IEnumerable<HubModel> GetHubs(IHubManager hubManager) { var hubDescriptors = hubManager.GetHubs(hd => true).ToList(); if (!hubDescriptors.Any()) return null; var hubData = hubDescriptors .Select(hubDescriptor => new HubModel { Name = hubDescriptor.Name, HubType = hubDescriptor.HubType, Methods = GetHubMethodInfo(hubManager, hubDescriptor) }) .ToList(); return hubData; }
public string GenerateProxy(string serviceUrl, bool includeDocComments) { string script; if (_scriptCache.TryGetValue(serviceUrl, out script)) { return(script); } var template = _template.Value; script = template.Replace("{serviceUrl}", serviceUrl); var hubs = new StringBuilder(); var first = true; foreach (var descriptor in _manager.GetHubs().OrderBy(h => h.Name)) { if (!first) { hubs.AppendLine(";"); hubs.AppendLine(); hubs.Append(" "); } GenerateType(hubs, descriptor, includeDocComments); first = false; } if (hubs.Length > 0) { hubs.Append(";"); } script = script.Replace("/*hubs*/", hubs.ToString()); if (!IsDebuggingEnabled) { script = _javaScriptMinifier.Minify(script); } _scriptCache.TryAdd(serviceUrl, script); return(script); }
private static IEnumerable <HubModel> GetHubs(IHubManager hubManager) { var hubDescriptors = hubManager.GetHubs(hd => true).ToList(); if (!hubDescriptors.Any()) { return(null); } var hubData = hubDescriptors .Select(hubDescriptor => new HubModel { Name = hubDescriptor.Name, HubType = hubDescriptor.HubType, Methods = GetHubMethodInfo(hubManager, hubDescriptor) }) .ToList(); return(hubData); }
public string GenerateProxy(string serviceUrl) { string script; if (_scriptCache.TryGetValue(serviceUrl, out script)) { return(script); } var template = _template.Value; script = template.Replace("{serviceUrl}", serviceUrl); var hubs = new StringBuilder(); var first = true; foreach (var descriptor in _manager.GetHubs()) { if (!first) { hubs.AppendLine(","); hubs.Append(" "); } this.GenerateType(hubs, descriptor); first = false; } script = script.Replace("/*hubs*/", hubs.ToString()); if (!IsDebuggingEnabled) { script = _javascriptMinifier.Minify(script); } _scriptCache.TryAdd(serviceUrl, script); return(script); }