protected void SendCsProxyCode(IRequest request, IResponse response) { string appName = AppConf.AppNameFromUri(request.Url, BamConf.AppConfigs); string defaultBaseAddress = ServiceProxySystem.GetBaseAddress(request.Url); string nameSpace = request.QueryString["namespace"] ?? "ServiceProxyClients"; string contractNameSpace = "{0}.Contracts"._Format(nameSpace); Incubator combined = new Incubator(); combined.CopyFrom(CommonServiceProvider); if (AppServiceProviders.ContainsKey(appName)) { Incubator appProviders = AppServiceProviders[appName]; combined.CopyFrom(appProviders, true); } string[] classNames = request.QueryString["classes"] == null ? combined.ClassNames : request.QueryString["classes"].DelimitSplit(",", ";"); StringBuilder csharpCode = ServiceProxySystem.GenerateCSharpProxyCode(defaultBaseAddress, classNames, nameSpace, contractNameSpace, combined, Logger, request.UserHostAddress.StartsWith("127.0.0.1")); response.Headers.Add("Content-Disposition", "attachment;filename=" + nameSpace + ".cs"); response.Headers.Add("Content-Type", "text/plain"); byte[] data = Encoding.UTF8.GetBytes(csharpCode.ToString()); response.OutputStream.Write(data, 0, data.Length); }
private bool SendProxyCode(IHttpContext context) { bool result = false; IRequest request = context.Request; string path = request.Url.AbsolutePath.ToLowerInvariant(); string appName = ApplicationNameResolver.ResolveApplicationName(context); bool includeLocalMethods = request.UserHostAddress.StartsWith("127.0.0.1"); string[] split = path.DelimitSplit("/", "."); if (split.Length >= 2) { string fileName = Path.GetFileName(path); if (_clientProxyGenerators.ContainsKey(fileName)) { Incubator combined = new Incubator(); combined.CopyFrom(CommonServiceProvider); if (AppServiceProviders.ContainsKey(appName)) { Incubator appProviders = AppServiceProviders[appName]; combined.CopyFrom(appProviders, true); } _clientProxyGenerators[fileName].SendProxyCode(combined, context); result = true; } } return(result); }
private void GetServiceProxies(string appName, out Incubator proxiedClasses, out List <ProxyAlias> aliases) { proxiedClasses = new Incubator(); aliases = new List <ProxyAlias>(GetProxyAliases(ServiceProxySystem.Incubator)); proxiedClasses.CopyFrom(ServiceProxySystem.Incubator, true); aliases.AddRange(GetProxyAliases(CommonServiceProvider)); proxiedClasses.CopyFrom(CommonServiceProvider, true); if (AppServiceProviders.ContainsKey(appName)) { Incubator appIncubator = AppServiceProviders[appName]; aliases.AddRange(GetProxyAliases(appIncubator)); proxiedClasses.CopyFrom(appIncubator, true); } }
public void CoreServiceRegistryCopyTest() { ServiceRegistry reg = CoreServiceRegistryContainer.Create(); Incubator copy = new Incubator(); copy.CopyFrom(reg); IUserResolver userResolver = copy.Get <IUserResolver>(); Expect.IsNotNull(userResolver); }