コード例 #1
0
 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)));
 }
コード例 #2
0
        private void CopyServiceFiles()
        {
            Assembly resourceAssembly = this.GetType().Assembly;

            IOUtil.EnsureDirectoryExists(DestinationFolder);
            IOUtil.EmptyDirectoryRecusively(DestinationFolder);

            string serviceSourceCodePath = Path.Combine(DestinationFolder, _serviceName + ".cs");

            StringBuilder serviceSource = new StringBuilder();

            serviceSource.AppendLine(this.Workspace.BuildDataServiceClassUsings());
            serviceSource.AppendLine("namespace CustomTestServiceHost");
            serviceSource.AppendLine("{");
            serviceSource.AppendLine(this.Workspace.BuildDataServiceClassCode());
            serviceSource.AppendLine("}");

            File.WriteAllText(serviceSourceCodePath, serviceSource.ToString());

            this.Workspace.PopulateHostSourceFolder();

            // copy additional files
            foreach (string file in this.Workspace.ServiceHostFiles())
            {
                File.Copy(file, Path.Combine(DestinationFolder, Path.GetFileName(file)));

                if (file.Contains("Edm.ObjectLayer"))
                {
                    string copiedFile = Path.Combine(DestinationFolder, Path.GetFileName(file));
                    string fileText   = File.ReadAllText(copiedFile);

                    string pathAndName = Path.Combine(DestinationFolder, this.Workspace.Name);

                    System.Data.EntityClient.EntityConnectionStringBuilder connBuilder = new System.Data.EntityClient.EntityConnectionStringBuilder();
                    connBuilder.ProviderConnectionString = this.Workspace.Database.DatabaseConnectionString;
                    connBuilder.Metadata = pathAndName + ".csdl|" + pathAndName + ".ssdl|" + pathAndName + ".msl";
                    connBuilder.Provider = "System.Data.SqlClient";

                    string connString = connBuilder.ToString();
                    connString = connString.Replace(@"\", @"\\");
                    connString = connString.Replace("\"", "\\\"");

                    string modifiedText = fileText.Replace("name=" + this.Workspace.ContextTypeName, connString);

                    File.WriteAllText(copiedFile, modifiedText);
                }
            }

#if false // pulled from GAC - not local filesystem
            // Copy Microsoft.OData.Service.dll and test framework
            if (!AstoriaTestProperties.SetupRunOnWebServer)
            {
                if (AstoriaTestProperties.Host != Host.Debug)
                {
                    File.Copy(Path.Combine(Path.GetDirectoryName(resourceAssembly.Location), DataFxAssemblyRef.File.DataServices), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServices));
                }
                else
                {
                    File.Copy(Path.Combine(TestUtil.GreenBitsReferenceAssembliesDirectory, DataFxAssemblyRef.File.DataServices), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServices));
                }
                if (AstoriaTestProperties.Host != Host.Debug)
                {
                    File.Copy(Path.Combine(Path.GetDirectoryName(resourceAssembly.Location), DataFxAssemblyRef.File.DataServicesClient), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServicesClient));
                }
                else
                {
                    File.Copy(Path.Combine(TestUtil.GreenBitsReferenceAssembliesDirectory, DataFxAssemblyRef.File.DataServicesClient), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServicesClient));
                }
            }
#endif

            // TODO: cannot get rid of framework DLL for client SKU
            // File.Copy(resourceAssembly.Location, Path.Combine(hostFolder, Path.GetFileName(resourceAssembly.Location)));
            CopyServerWorkspaceFiles(DestinationFolder);
        }
コード例 #3
0
        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);
            }
        }