protected internal void DeployAppConfig() { IOUtil.FindAndWriteResourceToFile(this.GetType().Assembly, "app.config", ExecutablePath + ".config"); Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ExecutablePath); #if !ClientSKUFramework if (AstoriaTestProperties.Host == Host.WebServiceHost) { BindingsSection bindingsSection = config.GetSection("system.serviceModel/bindings") as BindingsSection; WebHttpBindingCollectionElement webHttpBindingCollectionElement; WebHttpBindingElement webHttpBindingElement; foreach (BindingCollectionElement bindingCollectionElement in bindingsSection.BindingCollections) { // find WebHttpBinding element "higherMessageSize" and modify its settings if (bindingCollectionElement.BindingType.ToString().Equals("System.ServiceModel.WebHttpBinding")) { webHttpBindingCollectionElement = bindingCollectionElement as WebHttpBindingCollectionElement; webHttpBindingElement = webHttpBindingCollectionElement.Bindings["higherMessageSize"]; if (webHttpBindingElement != null) { // webHttpBinding -> binding -> security ->transport WebHttpSecurityElement webHttpSecurityElement = webHttpBindingElement.Security; switch (AstoriaTestProperties.HostAuthenicationMethod.ToLower()) { case "windows": webHttpSecurityElement.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows; webHttpSecurityElement.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.Windows; break; default: webHttpSecurityElement.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None; webHttpSecurityElement.Transport.ProxyCredentialType = System.ServiceModel.HttpProxyCredentialType.None; break; } } } } } #endif if (Database != null) { // fixup config files config.ConnectionStrings.ConnectionStrings.Clear(); config.ConnectionStrings.ConnectionStrings.Add(this.Workspace.GetConnectionStringSettingsForProvider(this, this.Database.DatabaseConnectionString)); } config.Save(); if (AstoriaTestProperties.WebServiceHostTargetFramework != null) { //Would rather do this through the API but unsure how string contents = File.ReadAllText(ExecutablePath + ".config"); int configurationPos = contents.IndexOf("<configuration>"); string startupStr = string.Format("<startup><supportedRuntime version=\"{0}\"/></startup>", AstoriaTestProperties.WebServiceHostTargetFramework); contents = contents.Insert(configurationPos + 16, startupStr); File.WriteAllText(ExecutablePath + ".config", contents); } }
/// <summary> /// Populates the source folder with the files that should be /// available on the service host. /// </summary> public override void PopulateHostSourceFolder() { base.PopulateHostSourceFolder(); Assembly resourceAssembly = this.GetType().Assembly; string codeFilePath = Path.Combine(WebServiceAppCodeDir, this.ObjectLayerOutputFileName); IOUtil.FindAndWriteResourceToFile(resourceAssembly, this.ObjectLayerResourceName, codeFilePath); }
public void CreateDataStreamProviderCode() { Assembly resourceAssembly = this.GetType().Assembly; string serviceSourceCodePath = Path.Combine(_w.WebServiceWorkspaceDir, "App_Code\\IDataStreamProviderImplementation.cs"); IOUtil.FindAndWriteResourceToFile(resourceAssembly, "SimpleDataStreamProvider.cs", serviceSourceCodePath); string sourceText = File.ReadAllText(serviceSourceCodePath); sourceText = sourceText.Replace("[[Usings]]", _w.BuildDataServiceClassUsings()); sourceText = sourceText.Replace("[[ContextTypeName]]", _w.ContextTypeName); sourceText = sourceText.Replace("[[ContextNamespace]]", _w.ContextNamespace); File.WriteAllText(serviceSourceCodePath, sourceText); }
public static void AddSilverlightHostFiles(Workspace workspace) { Assembly resourceAssembly = workspace.GetType().Assembly; string webserviceWorkspaceDir = workspace.DataService != null ? workspace.DataService.DestinationFolder : workspace.HostSourceFolder; string webServiceBinDir = Path.Combine(webserviceWorkspaceDir, "Bin"); string tempCLRBinDir = Path.Combine(webserviceWorkspaceDir, "tempCLR"); string tempSLBinDir = Path.Combine(webserviceWorkspaceDir, "tempSL"); string webServiceAppCodeDir = Path.Combine(webserviceWorkspaceDir, "App_Code"); string webServiceClientBinDir = Path.Combine(webserviceWorkspaceDir, "ClientBin"); IOUtil.EnsureDirectoryExists(webServiceClientBinDir); IOUtil.FindAndWriteResourceToFile(resourceAssembly, "AstoriaTestSilverlight.svc", Path.Combine(webserviceWorkspaceDir, "AstoriaTestSilverlight.svc")); IOUtil.FindAndWriteResourceToFile(resourceAssembly, "AstoriaTestSilverlightService.cs", Path.Combine(webServiceAppCodeDir, "AstoriaTestSilverlightService.cs")); if (AstoriaTestProperties.Client == ClientEnum.SILVERLIGHT) { File.Copy(Path.Combine(Environment.CurrentDirectory, "SilverlightAstoriaTestPage.html"), Path.Combine(webserviceWorkspaceDir, "SilverlightAstoriaTestPage.html")); //GenerateSilverlightXAP(resourceAssembly, webserviceWorkspaceDir, tempCLRBinDir, webServiceAppCodeDir, webServiceClientBinDir); File.Copy(Path.Combine(Environment.CurrentDirectory, "SilverlightAstoriaTest.xap"), Path.Combine(webServiceClientBinDir, "SilverlightAstoriaTest.xap")); } }
private static XElement GetCapXml(string templateFileName) { IOUtil.FindAndWriteResourceToFile(typeof(Workspace).Assembly, templateFileName, Path.Combine(Environment.CurrentDirectory, templateFileName)); return(XElement.Load(Path.Combine(Environment.CurrentDirectory, templateFileName))); }
private void CopyServiceFiles() { Assembly resourceAssembly = this.GetType().Assembly; #if !ClientSKUFramework IOUtil.EnsureDirectoryExists(DestinationFolder); IOUtil.EmptyDirectoryRecusively(DestinationFolder); #endif string serviceSource; if (AstoriaTestProperties.Host == Host.IDSH || AstoriaTestProperties.Host == Host.IDSH2) { serviceSource = "IDataServiceHostRunner"; } else { serviceSource = "TestServiceHost"; } string serviceSourceCodePath = Path.Combine(DestinationFolder, serviceName + ".cs"); IOUtil.FindAndWriteResourceToFile(resourceAssembly, serviceSource + ".cs", serviceSourceCodePath); string sourceText = File.ReadAllText(serviceSourceCodePath); sourceText = sourceText.Replace("//[[Usings]]", this.Workspace.BuildDataServiceClassUsings()); sourceText = sourceText.Replace("//[[ServiceCode]]", this.Workspace.BuildDataServiceClassCode()); File.WriteAllText(serviceSourceCodePath, sourceText); // copy additional files foreach (string file in this.Workspace.ServiceHostFiles()) { string newPath = file.Replace(Workspace.HostSourceFolder, DestinationFolder); IOUtil.EnsureDirectoryExists(Path.GetDirectoryName(newPath)); File.Copy(file, newPath); } var assembliesToCopy = new List <Assembly> { typeof(FullTrust.TrustedMethods).Assembly, // this is a special case for the fully-trusted-methods assembly, which must always be copied typeof(Microsoft.Spatial.ISpatial).Assembly, typeof(Microsoft.OData.Edm.IEdmModel).Assembly, typeof(Microsoft.OData.Core.ODataException).Assembly, #if !ClientSKUFramework typeof(Microsoft.OData.Service.DataService <>).Assembly, #endif typeof(Microsoft.OData.Client.DataServiceContext).Assembly, }; foreach (var assembly in assembliesToCopy) { File.Copy(assembly.Location, Path.Combine(DestinationFolder, Path.GetFileName(assembly.Location))); } // TODO: cannot get rid of precompiled library for the client SKU // File.Copy(resourceAssembly.Location, Path.Combine(hostFolder, Path.GetFileName(resourceAssembly.Location))); CopyServerWorkspaceFiles(DestinationFolder); // Copy win7 manifest file if test flag is set if (AstoriaTestProperties.WindowsCompatFlag == WindowsCompatFlag.Win7) { string serviceManifestPath = Path.Combine(DestinationFolder, serviceName + ".exe.manifest"); IOUtil.FindAndWriteResourceToFile(resourceAssembly, serviceSource + ".exe.manifest", serviceManifestPath); } }