public ProjectDirectory CreateDirectory(string name) { //valid name? if (!Helpers.ValidFilename(name)) { throw new Exception("Invalid directory name \"" + name + "\""); } //already exists? ProjectDirectory buffer = GetDirectory(name); if (FileExists(name)) { return null; } if (buffer != null) { return buffer; } Monitor.Enter(p_SyncLock); //create it buffer = new ProjectDirectory(name, Project); buffer.AssignNewID(); buffer.p_ParentID = InstanceID; //create the physical directory to associate with this directory if (!Directory.Exists(buffer.PhysicalLocation)) { Directory.CreateDirectory(buffer.PhysicalLocation); } //add to the directory children Array.Resize(ref p_ChildDirectories, p_ChildDirectories.Length + 1); p_ChildDirectories[p_ChildDirectories.Length - 1] = buffer.InstanceID; Project.RegisterEntity(buffer, true); Monitor.Exit(p_SyncLock); Project.Save(); return buffer; }
protected override Task <int> ExecuteCoreAsync() { // Loading all of the extensions should succeed as the dependency checker will have already // loaded them. var extensions = new RazorExtension[ExtensionNames.Values.Count]; for (var i = 0; i < ExtensionNames.Values.Count; i++) { extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); } var version = RazorLanguageVersion.Parse(Version.Value()); var configuration = new RazorConfiguration(version, Configuration.Value(), extensions); var result = ExecuteCore( configuration: configuration, projectDirectory: ProjectDirectory.Value(), outputFilePath: TagHelperManifest.Value(), assemblies: Assemblies.Values.ToArray()); return(Task.FromResult(result)); }
public Project(string filename) { p_Filename = filename; //perform restore (if needed) Helpers.Restore(filename); //open the file FileStream fileStream = new FileStream(filename, FileMode.Open); //read the header p_Header = new header(); p_Header.load(fileStream, this); //read the project name p_ProjectName = Helpers.ReadString255(fileStream); //read the build directory p_BuildDirectory = Helpers.ReadString(fileStream); //read the directories int directoryLength = Helpers.DecodeInt32(fileStream); p_Directories = new ProjectEntity[directoryLength]; for (int c = 0; c < directoryLength; c++) { p_Directories[c] = new ProjectDirectory(null, this); p_Directories[c].Load(fileStream); } //read the files int fileLength = Helpers.DecodeInt32(fileStream); p_Files = new ProjectEntity[fileLength]; for (int c = 0; c < fileLength; c++) { p_Files[c] = new ProjectFile(null, this); p_Files[c].Load(fileStream); } //clean up fileStream.Close(); }
public void IndexDirectory(ProjectDirectory dir, TreeNode node) { if (node.Tag == null) { node.Tag = dir; } node.Nodes.Clear(); //get sub directory and files ProjectDirectory[] dirs = dir.GetDirectories(); ProjectFile[] files = dir.GetFiles(); //recursively invoke this function for every sub-directory for (int c = 0; c < dirs.Length; c++) { //add the tree node for the sub directory TreeNode n = node.Nodes.Add(dirs[c].Name); n.ImageKey = "folder"; n.SelectedImageKey = "folder"; //index the child directory IndexDirectory(dirs[c], n); } for (int c = 0; c < files.Length; c++) { //get the type for the image key to apply //to this file. string type = files[c].FileType.ToString(); //add the node TreeNode n = node.Nodes.Add(files[c].Name); n.ImageKey = type; n.SelectedImageKey = type; n.Tag = files[c]; } }
private void copyFileEntry(string path, ProjectDirectory dir) { //is the path a file? if (File.Exists(path)) { //create the file entry in the directory FileInfo f = new FileInfo(path); ProjectFile file = dir.CreateFile(f.Name); //copy over the contents of the file //over to the one in the project. File.Copy(f.FullName, file.PhysicalLocation, true); return; } //must be a directory, otherwise the path is invalid if (!Directory.Exists(path)) { return; } //create the directory instance in the project dir = dir.CreateDirectory(new DirectoryInfo(path).Name); //enumerate over all the child directories in the directory foreach (DirectoryInfo d in new DirectoryInfo(path).GetDirectories()) { //copy all of the sub-files in this directory //by recursively invoking this function copyFileEntry(d.FullName, dir); } //copy all files in the directory foreach (FileInfo f in new DirectoryInfo(path).GetFiles()) { //create the file entry in the directory ProjectFile file = dir.CreateFile(f.Name); //copy over the contents of the file //over to the one in the project. File.Copy(f.FullName, file.PhysicalLocation, true); } }
public InitializeCommand(string path) { directory = new ProjectDirectory(path); }
private void DeleteProjectDirectory() { ProjectDirectory.Delete(recursive: true); }
private void importProjectFromDirectory(ProjectDirectory vDir, DirectoryInfo pDir) { //add the directories foreach (DirectoryInfo d in pDir.GetDirectories()) { importProjectFromDirectory( vDir.CreateDirectory(d.Name), d); } //add the files foreach (FileInfo f in pDir.GetFiles()) { ProjectFile vFile = vDir.CreateFile(f.Name); File.Copy(f.FullName, vFile.PhysicalLocation, true); } }
public static void Main() { Console.WriteLine("Start P06_Virtuoso"); string path = ProjectDirectory.GetProjectDirectory(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); AdapterVirtuosoSimple engine = new AdapterVirtuosoSimple("HOST=localhost:1550;UID=dba;PWD=dba;Charset=UTF-8;Connection Timeout=500", "g"); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == "virtuoso_load") { engine.PrepareToLoad(); Polar.Data.Phototeka generator = new Polar.Data.Phototeka(npersons, 777777); sw.Restart(); engine.Load(generator.Generate1of3()); engine.Load(generator.Generate2of3()); engine.Load(generator.Generate3of3()); sw.Stop(); Console.WriteLine("Load ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. probe.ndx = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso_SelectById") { rnd = new Random(777777777); long sum = 0; sw.Restart(); //var rcommand = engine.RunStart(); for (int i = 0; i < probe.nte; i++) { string sid = "person" + rnd.Next(0, (int)probe.siz - 1); var v = engine.Query("sparql select * { <" + sid + "> ?p ?o }") .First(po => po[0].ToString() == "age") .ToArray(); // .First(po => (string)po[0] == "age"); string s = v[1].ToString(); sum += Int32.Parse(s); } //engine.RunStop(rcommand); sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso_SearchByName") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { var intId = rnd.Next(0, (int)probe.siz - 1); string namePrefix = "Pupkin" + intId / 10; //sum += (int)engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)).Count(); var enumerable = engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)); //foreach (var objectse in enumerable) //{ // foreach (var o in objectse) // { // Console.WriteLine(o); // } // Console.WriteLine(); //} sum += (int)enumerable.Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { string persId = "person" + rnd.Next(0, (int)probe.siz - 1); sum += engine.Query( "sparql select ?phname {?refl <reflected> <" + persId + "> . ?refl <in_doc> ?ph . ?ph <name> ?phname}") //"sparql select ?refl {?refl <reflected> <"+persId+"> . }") .Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { } } res.Close(); }
public CodebaseAlert(string alertTypeName, CodebaseAlertPriority priority, ProjectDirectory projectDirectory) { Priority = priority; AlertTypeName = alertTypeName; Project = projectDirectory; }
private bool SetProjectDirectory(Project project, ProjectDirectory directory, string value) { if (!File.Exists(appwrapperPath)) return false; System.Diagnostics.Process appwrapper = new System.Diagnostics.Process(); appwrapper.StartInfo.FileName = appwrapperPath; appwrapper.StartInfo.Arguments = "Autotests:set" + directory.ToString() + ':' + value; appwrapper.Start(); System.Threading.Thread.Sleep(500); return true; }
public void NServiceBusDockerContainer() { var targetDirectory = ProjectDirectory.GetSandboxPath(nameof(NServiceBusDockerContainer)); VerifyAndBuild("nsbdockercontainer", targetDirectory); }
public void NServiceBusWindowsService() { var targetDirectory = ProjectDirectory.GetSandboxPath(nameof(NServiceBusWindowsService)); VerifyAndBuild("nsbwinservice", targetDirectory); }
protected override void configurePlan(string directory, TemplatePlan plan) { var current = plan.Steps.OfType <ProjectPlan>().LastOrDefault(); ProjectDirectory.PlanForDirectory(directory).Each(x => current.Add(x)); }
public static void Main() { Console.WriteLine("Start P13_NametableTry"); string path = ProjectDirectory.GetProjectDirectory(); string dpath = path + "../Databases/p13nametabletry"; if (!Directory.Exists(dpath)) { Directory.CreateDirectory(dpath); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; int[] testingcodes = null; NametableTry nametable = new NametableTry(dpath + "/"); //Stan3TabsInt tabs = new Stan3TabsInt(dpath + "/"); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); if (probe.sol == "LoadAll") { // Загрузка int siz = (int)probe.siz; nametable.Clear(); sw.Restart(); nametable.BuildTable( Enumerable.Range(0, siz).Select(i => new XElement("pair", new XAttribute("id", i), new XElement("name", i.ToString())))); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; sw.Restart(); nametable.BuildIndexes(); sw.Stop(); probe.ndx = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("Загрузка OK"); } else if (probe.sol == "Code2String") { rnd = new Random(777777777); int nte = (int)probe.nte; // выберем nte случайных кодов из таблицы имён if (testingcodes == null) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)probe.siz - 1)) .ToArray(); } nametable.Warmup(); sw.Restart(); long sum = 0L; //nametable.Clear(); foreach (var code in testingcodes) { sum += nametable.GetNameByCode(code).Length; } sw.Stop(); probe.sum = sum; probe.tim = sw.ElapsedMilliseconds; probe.tsk = "int2str"; res.WriteLine(probe.ToCSV()); Console.WriteLine("Code2String OK"); } else if (probe.sol == "String2Code") { int nte = (int)probe.nte; //rnd = new Random(777777777); rnd = new Random(111111111); // выберем nte случайных строк из таблицы имён if (testingcodes == null) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)probe.siz - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); } string[] keys = testingcodes .Select(i => i.ToString()) .ToArray(); nametable.Warmup(); long sum = 0L; sw.Restart(); int cnt = 0; foreach (var key in keys) { int code = nametable.GetPersonsByName(key); sum += code; cnt++; } sw.Stop(); probe.sum = sum; probe.tsk = "str2int"; probe.tim = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("String2Code OK cnt={0}", cnt); } } res.Close(); }
static void Main(string[] args) { string path = ProjectDirectory.GetProjectDirectory(); Console.WriteLine("Start TestGenerator"); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); AdapterVirtuoso engine = new AdapterVirtuoso("HOST=localhost:1550;UID=dba;PWD=dba;Charset=UTF-8;Connection Timeout=500", "g"); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == "virtuoso7_load") { sw.Restart(); Reload(engine, npersons); sw.Stop(); Console.WriteLine("Load ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. probe.ndx = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_SelectById") { rnd = new Random(777777777); long sum = 0; sw.Restart(); for (int i = 0; i < probe.nte; i++) { string sid = "person"+ rnd.Next(0, (int)probe.siz - 1); var v = engine.Query("sparql select * { <" + sid + "> ?p ?o }"); sum +=(int) v.First(paramValues => paramValues[0].ToString() == "age")[1]; } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_SearchByName") { Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <person>}").First()[0].ToString()); Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <photo_doc>}").First()[0].ToString()); Console.WriteLine((string)engine.Query("sparql select Count(?p) { ?p a <reflection>}").First()[0].ToString()); rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { var intId = rnd.Next(0, (int)probe.siz - 1); string namePrefix = "Pupkin" + intId / 10; //sum += (int)engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)).Count(); var enumerable = engine.Query(string.Format("sparql select ?s {{ ?s <name> ?o . Filter(strStarts(str(?o), \"{0}\")) }}", namePrefix)); //foreach (var objectse in enumerable) //{ // foreach (var o in objectse) // { // if (o is SqlRdfBox) // string oname = (string)engine.Query("sparql select ?name { <" + o + "> <name> ?name}").First()[0].ToString(); // if (!o.ToString().StartsWith(namePrefix)) // Console.WriteLine("ERROR!"); // } //} sum += (int)enumerable.Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "virtuoso7_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { string persId = "person"+ rnd.Next(0, (int)probe.siz - 1); sum += engine.Query(string.Format("sparql select ?phname {{?refl <reflected> <{0}> . ?refl <in_doc> ?ph . ?ph <name> ?phname}}", persId)) .Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { } } res.Close(); }
public static string DisplayPath(this ProjectDirectory directory, DirectoryInfo sourceDirectory) { //TODO -relativeise this return(directory.Directory.FullName); }
public void PublishProjectWithReferences_DifferentBuildAndPublish_LibraryInitializers() { var testAsset = "RazorAppWithPackageAndP2PReference"; ProjectDirectory = CreateAspNetSdkTestAsset(testAsset); var restore = new RestoreCommand(Log, Path.Combine(ProjectDirectory.TestRoot, "AppWithPackageAndP2PReference")); restore.Execute().Should().Pass(); CreateFile("console.log('Hello world AnotherClassLib publish')", "AnotherClassLib", "wwwroot", "AnotherClassLib.lib.module.js"); CreateFile("console.log('Hello world AnotherClassLib')", "AnotherClassLib", "wwwroot", "AnotherClassLib.lib.module.build.js"); ProjectDirectory.WithProjectChanges((project, document) => { if (project.EndsWith("AnotherClassLib.csproj")) { document.Root.Add(new XElement("ItemGroup", new XElement("Content", new XAttribute("Update", "wwwroot\\AnotherClassLib.lib.module.build.js"), new XAttribute("CopyToPublishDirectory", "Never"), new XAttribute("TargetPath", "wwwroot\\AnotherClassLib.lib.module.js")))); } }); var publish = new PublishCommand(Log, Path.Combine(ProjectDirectory.TestRoot, "AppWithPackageAndP2PReference")); publish.WithWorkingDirectory(ProjectDirectory.Path); publish.Execute("/bl").Should().Pass(); var intermediateOutputPath = publish.GetIntermediateDirectory(DefaultTfm, "Debug").ToString(); var outputPath = publish.GetOutputDirectory(DefaultTfm, "Debug").ToString(); var path = Path.Combine(intermediateOutputPath, "staticwebassets.build.json");; var buildManifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)); var initializers = buildManifest.Assets.Where(a => a.RelativePath == "AnotherClassLib.lib.module.js"); initializers.Should().HaveCount(1); initializers.Should().Contain(a => a.IsBuildOnly()); AssertManifest( buildManifest, LoadBuildManifest()); var finalPath = Path.Combine(intermediateOutputPath, "staticwebassets.publish.json"); AssertManifest( StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(finalPath)), LoadPublishManifest()); AssertBuildAssets( StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(finalPath)), outputPath, intermediateOutputPath); var modulesManifest = new FileInfo(Path.Combine(outputPath, "wwwroot", "AppWithPackageAndP2PReference.modules.json")); modulesManifest.Should().Exist(); modulesManifest.Should().Contain("_content/AnotherClassLib/AnotherClassLib.lib.module.js"); modulesManifest.Should().NotContain("_content/ClassLibrary/AnotherClassLib.lib.module.js"); var moduleFile = new FileInfo(Path.Combine(outputPath, "wwwroot", "_content", "AnotherClassLib", "AnotherClassLib.lib.module.js")); moduleFile.Should().Exist(); moduleFile.Should().Contain("console.log('Hello world AnotherClassLib publish')"); }
public void StaticWebAssets_HostedApp_ReferencingNetStandardLibrary_Works() { // Arrange var testAppName = "BlazorHosted"; ProjectDirectory = CreateAspNetSdkTestAsset(testAppName); ProjectDirectory.WithProjectChanges((project, document) => { if (Path.GetFileNameWithoutExtension(project) == "blazorwasm") { document.Descendants("TargetFramework").Single().ReplaceNodes("net5"); } if (Path.GetFileNameWithoutExtension(project) == "RazorClassLibrary") { document.Descendants("TargetFramework").Single().ReplaceNodes("netstandard2.1"); document.Descendants("PropertyGroup").First().Add(new XElement("RazorLangVersion", "3.0")); } if (Path.GetFileNameWithoutExtension(project) == "classlibrarywithsatelliteassemblies") { document.Descendants("TargetFramework").Single().ReplaceNodes("netstandard2.1"); document.Descendants("PropertyGroup").First().Add(new XElement("RazorLangVersion", "3.0")); } }); var build = new BuildCommand(ProjectDirectory, "blazorhosted"); build.WithWorkingDirectory(ProjectDirectory.TestRoot); var buildResult = build.Execute("/bl"); buildResult.Should().Pass(); var outputPath = build.GetOutputDirectory(DefaultTfm).ToString(); var intermediateOutputPath = build.GetIntermediateDirectory(DefaultTfm, "Debug").ToString(); // GenerateStaticWebAssetsManifest should generate the manifest file. var path = Path.Combine(intermediateOutputPath, "staticwebassets.build.json"); new FileInfo(path).Should().Exist(); var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)); // We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above. // Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond). // This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM. // To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version. var numFilesUpdated = 0; foreach (var f in manifest.Assets) { if (Regex.Match(f.RelativePath, DotNet5JSRegexPattern).Success) { f.Identity = Regex.Replace(f.Identity, DotNet5JSRegexPattern, DotNet5JSTemplate); f.RelativePath = Regex.Replace(f.RelativePath, DotNet5JSRegexPattern, DotNet5JSTemplate); f.OriginalItemSpec = Regex.Replace(f.OriginalItemSpec, DotNet5JSRegexPattern, DotNet5JSTemplate); numFilesUpdated++; } } Assert.Equal(2, numFilesUpdated); AssertManifest(manifest, LoadBuildManifest()); // GenerateStaticWebAssetsManifest should copy the file to the output folder. var finalPath = Path.Combine(outputPath, "blazorhosted.staticwebassets.runtime.json"); new FileInfo(finalPath).Should().Exist(); AssertBuildAssets( StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)), outputPath, intermediateOutputPath); }
public void ScAdapterService() { var targetDirectory = ProjectDirectory.GetSandboxPath(nameof(ScAdapterService)); VerifyAndBuild("scadapterwinservice", targetDirectory); }
public static void Main() { Console.WriteLine("Start P05_Phototeka3TabsInt"); string path = ProjectDirectory.GetProjectDirectory(); if (!Directory.Exists(path + "../Databases/P05_Phototeka3TabsInt")) { Directory.CreateDirectory(path + "../Databases/P05_Phototeka3TabsInt"); } TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd = new Random(777777777); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); string dbpath = path + "../Databases/P05_Phototeka3TabsInt/"; Stan3TabsInt tabs = new Stan3TabsInt(dbpath); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == "Stan3TabsInt_load") { sw.Restart(); Polar.Data.Phototeka generator = new Polar.Data.Phototeka(npersons, 777777); //var n = generator.Generate1of3().Count(); //tabs.Build( // generator.Generate1of3()); tabs.Clear(); var query_p = generator.Generate1of3(); tabs.BuildPersons(query_p); var query_ph = generator.Generate2of3(); tabs.BuildPhoto_docs(query_ph); var query_r = generator.Generate3of3(); tabs.BuildReflections(query_r); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; Console.WriteLine("Load ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. sw.Restart(); tabs.BuildIndexes(); sw.Stop(); probe.ndx = sw.ElapsedMilliseconds; Console.WriteLine("BuildIndexes ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. res.WriteLine(probe.ToCSV()); } else if (probe.sol == "Stan3TabsInt_SelectById") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); var p = tabs.GetPersonByCode(id); sum += (int)p[2]; } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 46 (1000) res.WriteLine(probe.ToCSV()); } else if (probe.sol == "Stan3TabsInt_SearchByName") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); string namePrefix = "Pupkin" + id / 10; var ob = tabs.GetPersonsByName(namePrefix).ToArray(); sum += ob.Length; sum = sum + 1 - 1; //sum += (int)simpleTripleStore.GetSubjects("a", "person").Select(personId => simpleTripleStore.GetObject(personId, "name").FirstOrDefault()).Count(name => name.StartsWith(namePrefix)); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "Stan3TabsInt_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); //var qu = tabs.GetReflectionsByReflected(id); sum += tabs.GetReflectionsByReflected(id).Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { int cnt = 0; bool toload = false; toload = true; if (toload) { sw.Restart(); Phototeka generator = new Phototeka(npersons, 2378459); tabs.Build( generator.Generate1of3() .Concat(generator.Generate2of3() .Concat(generator.Generate3of3()))); sw.Stop(); Console.WriteLine("Load ok. duration={0}", sw.ElapsedMilliseconds); } sw.Restart(); for (int i = 0; i < 10000; i++) { int code = rnd.Next(npersons - 1); object[] v = tabs.GetPersonByCode(code); } sw.Stop(); Console.WriteLine("10000 persons ok. duration={0}", sw.ElapsedMilliseconds); sw.Restart(); for (int i = 0; i < 10000; i++) { int code = rnd.Next(2 * npersons - 1); object[] v = tabs.GetPhoto_docByCode(code); if (i == 200) { Console.WriteLine("photo_doc record: {0} {1}", v[0], v[1]); } } sw.Stop(); Console.WriteLine("10000 photo_docs ok. duration={0}", sw.ElapsedMilliseconds); sw.Restart(); for (int i = 0; i < 10000; i++) { int code = rnd.Next(2 * npersons - 1); cnt = tabs.GetReflectionsByReflected(code).Count(); } sw.Stop(); Console.WriteLine("10000 portraits ok. duration={0}", sw.ElapsedMilliseconds); } } res.Close(); }
public void Build_SatelliteAssembliesAreCopiedToBuildOutput() { // Arrange var testAppName = "BlazorWasmWithLibrary"; ProjectDirectory = CreateAspNetSdkTestAsset(testAppName); ProjectDirectory.WithProjectChanges((path, project) => { if (path.Contains("blazorwasm")) { var ns = project.Root.Name.Namespace; var propertyGroup = new XElement(ns + "PropertyGroup"); propertyGroup.Add(new XElement("DefineConstants", @"$(DefineConstants);REFERENCE_classlibrarywithsatelliteassemblies")); var itemGroup = new XElement(ns + "ItemGroup"); itemGroup.Add(new XElement("ProjectReference", new XAttribute("Include", @"..\classlibrarywithsatelliteassemblies\classlibrarywithsatelliteassemblies.csproj"))); project.Root.Add(propertyGroup); project.Root.Add(itemGroup); } }); var resxfileInProject = Path.Combine(ProjectDirectory.TestRoot, "blazorwasm", "Resources.ja.resx.txt"); File.Move(resxfileInProject, Path.Combine(ProjectDirectory.TestRoot, "blazorwasm", "Resource.ja.resx")); var buildCommand = new BuildCommand(ProjectDirectory, "blazorwasm"); buildCommand.WithWorkingDirectory(ProjectDirectory.TestRoot); buildCommand.Execute("/bl").Should().Pass(); var outputPath = buildCommand.GetOutputDirectory(DefaultTfm).ToString(); var intermediateOutputPath = buildCommand.GetIntermediateDirectory(DefaultTfm).ToString(); // GenerateStaticWebAssetsManifest should generate the manifest file. var path = Path.Combine(intermediateOutputPath, "staticwebassets.build.json"); new FileInfo(path).Should().Exist(); var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)); AssertManifest(manifest, LoadBuildManifest()); // GenerateStaticWebAssetsManifest should copy the file to the output folder. var finalPath = Path.Combine(outputPath, "blazorwasm.staticwebassets.runtime.json"); new FileInfo(finalPath).Should().Exist(); AssertBuildAssets( StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)), outputPath, intermediateOutputPath); new FileInfo(Path.Combine(outputPath, "wwwroot", "_framework", "blazorwasm.dll")).Should().Exist(); new FileInfo(Path.Combine(outputPath, "wwwroot", "_framework", "classlibrarywithsatelliteassemblies.dll")).Should().Exist(); new FileInfo(Path.Combine(outputPath, "wwwroot", "_framework", "Microsoft.CodeAnalysis.CSharp.dll")).Should().Exist(); new FileInfo(Path.Combine(outputPath, "wwwroot", "_framework", "fr", "Microsoft.CodeAnalysis.CSharp.resources.dll")).Should().Exist(); var bootJsonPath = new FileInfo(Path.Combine(outputPath, "wwwroot", "_framework", "blazor.boot.json")); bootJsonPath.Should().Contain("\"Microsoft.CodeAnalysis.CSharp.dll\""); bootJsonPath.Should().Contain("\"fr\\/Microsoft.CodeAnalysis.CSharp.resources.dll\""); }
private static void Main(string[] args) { string path = ProjectDirectory.GetProjectDirectory(); if (!Directory.Exists(path + "../Databases/simple triple store")) { Directory.CreateDirectory(path + "../Databases/simple triple store"); } Console.WriteLine("Start TestGenerator"); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); SimpleTripleStore.SimpleTripleStore simpleTripleStore = new SimpleTripleStore.SimpleTripleStore(path + "../Databases/simple triple store/", 1000 * 1000); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == "simpleTripleStore_load") { // Directory.Delete(path + "../Databases/simple triple store", true); sw.Restart(); Polar.Data.Phototeka generator = new Polar.Data.Phototeka(npersons, 777777); simpleTripleStore.Build(generator.GenerateRDF()); sw.Stop(); Console.WriteLine("Load ok. Duration={0}", sw.ElapsedMilliseconds); // 10000: 14.9 сек. probe.ndx = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); } else if (probe.sol == "simpleTripleStore_SelectById") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); sum += Convert.ToInt32(simpleTripleStore.GetDirects(id).FirstOrDefault(tuple => tuple.Item1 == "age").Item2); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "simpleTripleStore_SearchByName") { rnd = new Random(777777777); sw.Restart(); WordIndex index = new WordIndex(); for (int i = 0; i < probe.siz; i++) { var w = simpleTripleStore.GetObject(i, "name").First(); index.Insert(w, i); } Console.WriteLine("build words trigrams index " + sw.ElapsedMilliseconds); Console.WriteLine("RAM used {0} mb.", GC.GetTotalMemory(false) / 1024 / 1024); sw.Restart(); long sum = 0, sum2 = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); string namePrefix = "Pupkin" + id / 10; sum += (int)index.FindBySubWord(namePrefix).Count(); } Console.WriteLine(sum); Console.WriteLine(sum2); sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "simpleTripleStore_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int persId = rnd.Next(0, (int)probe.siz - 1); sum += simpleTripleStore.GetSubjects("reflected", persId.ToString()) .Select(refid => simpleTripleStore.GetObject(refid, "in_doc").First()) .Select(int.Parse) .Select(photoId => simpleTripleStore.GetDirects(photoId)) .Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { } } res.Close(); }
static void Main(string[] args) { Console.WriteLine("Start P11_PlatformPreperties2"); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); string path = ProjectDirectory.GetProjectDirectory(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; Dictionary <string, int> str2Int = new Dictionary <string, int>(); List <string> int2Str = new List <string>(); int[] testingcodes = null; foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); if (probe.sol == "LoadAll") { // Загрузка sw.Restart(); int siz = (int)probe.siz; for (int i = 0; i < siz; i++) { string s = i.ToString(); str2Int.Add(s, i); int2Str.Add(s.ToString()); } sw.Stop(); probe.lod = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("Загрузка OK"); } else if (probe.sol == "TestCompositions") { int nte = (int)probe.nte; foreach (var key in str2Int.Keys.Take(nte)) { if (key == int2Str[str2Int[key]]) { continue; } throw new Exception(key + " " + str2Int[key] + " " + int2Str[str2Int[key]]); } foreach (var code in str2Int.Values.Take(nte)) { if (code == str2Int[int2Str[code]]) { continue; } throw new Exception(code + " " + int2Str[code] + " " + str2Int[int2Str[code]]); } res.WriteLine(probe.ToCSV()); Console.WriteLine("TestCompositions OK"); } else if (probe.sol == "GetStringTime") { rnd = new Random(777777777); int nte = (int)probe.nte; // выберем nte случайных кодов из таблицы имён if (testingcodes == null) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next(str2Int.Values.Count - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); } long sum = 0L; sw.Restart(); foreach (int key in testingcodes) { string s = int2Str[key]; sum += s.Length; } //sum += testingcodes.Select(k => int2Str[k].Length).Aggregate((sm, v) => sm + v); sw.Stop(); probe.sum = sum; probe.tim = sw.ElapsedMilliseconds; probe.tsk = "int2str"; res.WriteLine(probe.ToCSV()); Console.WriteLine("GetStringTime OK"); } else if (probe.sol == "GetCodeTime") { int nte = (int)probe.nte; rnd = new Random(777777777); // выберем nte случайных строк из таблицы имён if (testingcodes == null || nte != testingcodes.Length) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next(str2Int.Values.Count - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); } string[] keys = testingcodes .Select(i => i.ToString()) .ToArray(); long sum = 0L; sw.Restart(); foreach (string key in keys) { sum += str2Int[key]; } sw.Stop(); probe.sum = sum; probe.tsk = "str2int"; probe.tim = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("GetCodeTime OK"); } } res.Close(); }
static void Main(string[] args) { string path = ProjectDirectory.GetProjectDirectory(); Console.WriteLine(path); if (!Directory.Exists(path + "../Databases/name table universal")) { Directory.CreateDirectory(path + "../Databases/name table universal"); } NametableLinearBuffered nameTable = new NametableLinearBuffered(path + "../Databases/name table universal"); Console.WriteLine("Start P15_LinearBuffered_NameTable"); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); if (probe.sol == "LoadAll") { // Загрузка sw.Restart(); int siz = (int)probe.siz; nameTable.Expand(siz, Enumerable.Range(0, siz).Select(i => i.ToString())); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("Загрузка OK"); } else if (probe.sol == "TestCompositions") { int siz = (int)probe.siz; foreach (var key in nameTable.Keys.Take(siz)) { if (key == nameTable.GetString(nameTable.GetCode(key))) { continue; } throw new Exception(key + " code:" + nameTable.GetCode(key) + " key:" + nameTable.GetString(nameTable.GetCode(key))); } foreach (var code in nameTable.Codes.Take(siz)) { if (code == nameTable.GetCode(nameTable.GetString(code))) { continue; } throw new Exception(code + " key:" + nameTable.GetString(code) + " code:" + nameTable.GetCode(nameTable.GetString(code))); } res.WriteLine(probe.ToCSV()); Console.WriteLine("TestCompositions OK"); } else if (probe.sol == "String2CodeTime") { rnd = new Random(777777776); int nte = (int)probe.nte; // выберем nte случайных кодов из таблицы имён int[] codes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)nameTable.Count)) //.Select(i => nameTable.Codes.ElementAt(i)) .ToArray(); sw.Restart(); long sum = 0L; foreach (var code in codes) { sum += nameTable.GetString(code).Length; } sw.Stop(); probe.sum = sum; probe.tim = sw.ElapsedMilliseconds; probe.tsk = "int2str"; res.WriteLine(probe.ToCSV()); Console.WriteLine("String2CodeTime OK"); } else if (probe.sol == "Code2StringTime") { int nte = (int)probe.nte; rnd = new Random(777777777); // выберем nte случайных строк из таблицы имён var testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)nameTable.Count - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); long sum = 0L; sw.Restart(); foreach (var code in testingcodes) { sum += nameTable.GetString(code).Length; } sw.Stop(); probe.sum = sum; probe.tsk = "str2int"; probe.tim = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("Code2StringTime OK"); } else if (probe.sol == "InseartPortion") { int nte = (int)probe.nte; int existingCount = Math.Min(nte / 2, (int)nameTable.Count); string[] newKeys = Enumerable.Range((int)nameTable.Count - existingCount, nte) .Select(i => i.ToString()) .ToArray(); long sum = 0L; sw.Restart(); var portionCoded = nameTable.InsertPortion(newKeys); Console.WriteLine(nameTable.GetCode("1000001")); Console.WriteLine(nameTable.GetString(1000001)); sw.Stop(); if (portionCoded.Keys.Distinct().Count() < nte) { throw new Exception("portion count " + portionCoded.Keys.Distinct().Count()); } if (portionCoded.Values.Distinct().Count() < nte) { throw new Exception("portion count" + portionCoded.Values.Distinct().Count()); } foreach (var newKey in newKeys.Where(newKey => newKey != nameTable.GetString(nameTable.GetCode(newKey)))) { throw new Exception("key " + newKey + " code " + nameTable.GetCode(newKey) + " getkey " + nameTable.GetString(nameTable.GetCode(newKey))); } foreach (var newKey in newKeys.Where(newKey => portionCoded[newKey] != nameTable.GetCode(newKey))) { throw new Exception("key " + newKey + " code " + nameTable.GetCode(newKey) + " getkey " + nameTable.GetString(nameTable.GetCode(newKey))); } foreach (var newKey in portionCoded.Keys.Where(newKey => newKey != nameTable.GetString(nameTable.GetCode(newKey)))) { throw new Exception("key " + newKey + " code " + nameTable.GetCode(newKey) + " getkey " + nameTable.GetString(nameTable.GetCode(newKey))); } foreach (var newKey in portionCoded.Values.Where(newcode => newcode != nameTable.GetCode(nameTable.GetString(newcode)))) { throw new Exception("code " + newKey + " key " + nameTable.GetString(newKey) + " getcode " + nameTable.GetCode(nameTable.GetString(newKey))); } sum = nameTable.Count; probe.sum = sum; probe.tsk = "InseartPortion"; probe.tim = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("InseartPortion OK"); } } res.Close(); }
public static void Main() { Console.WriteLine("Start TestGenerator"); string path = ProjectDirectory.GetProjectDirectory(); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; //MySQL db = new MySQL("server=localhost;uid=root;port=3306;password=fetnaggi;"); //SQLite db = new SQLite("Data Source=" + path + "../databases/test.db3"); SQLdatabase db = new SQLdatabase(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\Users\Marchuk\Documents\TestPhototeka.mdf;Integrated Security=True;Connect Timeout=30"); string dbname = db.GetType().Name; foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); int npersons = (int)probe.siz; if (probe.sol == dbname + "_load") { db.PrepareToLoad(); sw.Restart(); Polar.Data.Phototeka generator = new Polar.Data.Phototeka(npersons, 777777); db.LoadElementFlow(generator.Generate1of3()); db.LoadElementFlow(generator.Generate2of3()); db.LoadElementFlow(generator.Generate3of3()); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; sw.Restart(); db.MakeIndexes(); sw.Stop(); probe.ndx = sw.ElapsedMilliseconds; Console.WriteLine("Load ok."); // 10000: 14.9 сек. res.WriteLine(probe.ToCSV()); } else if (probe.sol == dbname + "_SelectById") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); sum += (int)(db.GetById(id, "person")[2]); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SelectById ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == dbname + "_SearchByName") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); sum += db.SearchByName("Pupkin" + id / 10, "person").Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("SearchByName ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == dbname + "_GetRelationByPerson") { rnd = new Random(777777777); sw.Restart(); long sum = 0; for (int i = 0; i < probe.nte; i++) { int id = rnd.Next(0, (int)probe.siz - 1); sum += db.GetPhotosOfPersonUsingRelation(id).Count(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = sum; Console.WriteLine("GetRelationByPerson ok. Duration={0}", sw.ElapsedMilliseconds); // 7 res.WriteLine(probe.ToCSV()); } else if (probe.sol == "unused") { } } res.Close(); }
public BranchCommand(string path) { directory = new ProjectDirectory(path); }
public IEnumerable <string> GetCodeItems(OptionPreference preferLongNames = OptionPreference.Short) { // --verbose: Show more output if ((Flags & DockerComposeCommonFlags.Verbose) != 0) { yield return("--verbose"); } // --no-ansi: Do not print ANSI control characters if ((Flags & DockerComposeCommonFlags.NoAnsi) != 0) { yield return("--no-ansi"); } // -v, --version: Print version and exit if ((Flags & DockerComposeCommonFlags.Version) != 0) { yield return(preferLongNames == OptionPreference.Long ? "--version" : "-v"); } // --tls: Use TLS; implied by --tlsverify if ((Flags & DockerComposeCommonFlags.Tls) != 0) { yield return("--tls"); } // --tlsverify: Use TLS and verify the remote if ((Flags & DockerComposeCommonFlags.Tlsverify) != 0) { yield return("--tlsverify"); } // --skip-hostname-check: Don't check the daemon's hostname against the name specified in the client certificate if ((Flags & DockerComposeCommonFlags.SkipHostnameCheck) != 0) { yield return("--skip-hostname-check"); } // --compatibility: If set, Compose will attempt to convert deploy keys in v3 files to their non-Swarm equivalent if ((Flags & DockerComposeCommonFlags.Compatibility) != 0) { yield return("--compatibility"); } // -f, --file =FILE: Specify an alternate compose file (default: docker-compose.yml) if (!string.IsNullOrEmpty(File)) { yield return("--file"); yield return(File.ShellQuote()); } // -p, --project-name =NAME: Specify an alternate project name (default: directory name) if (!string.IsNullOrEmpty(ProjectName)) { yield return("--project-name"); yield return(ProjectName.ShellQuote()); } // --log-level =LEVEL: Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) if (!(LogLevel is null)) { yield return("--log-level"); yield return(LogLevel.Value.ToLinuxValue()); } // -H, --host =HOST: Daemon socket to connect to if (!string.IsNullOrEmpty(Host)) { yield return("--host"); yield return(Host.ShellQuote()); } // --tlscacert =CA_PATH: Trust certs signed only by this CA if (!string.IsNullOrEmpty(Tlscacert)) { yield return("--tlscacert"); yield return(Tlscacert.ShellQuote()); } // --tlscert =CLIENT_CERT_PATH: Path to TLS certificate file if (!string.IsNullOrEmpty(Tlscert)) { yield return("--tlscert"); yield return(Tlscert.ShellQuote()); } // --tlskey =TLS_KEY_PATH: Path to TLS key file if (!string.IsNullOrEmpty(Tlskey)) { yield return("--tlskey"); yield return(Tlskey.ShellQuote()); } // --project-directory =PATH: Specify an alternate working directory (default: the path of the Compose file) if (!string.IsNullOrEmpty(ProjectDirectory)) { yield return("--project-directory"); yield return(ProjectDirectory.ShellQuote()); } }
static void Main(string[] args) { string path = ProjectDirectory.GetProjectDirectory(); if (!Directory.Exists(path + "../Databases/name table universal")) { Directory.CreateDirectory(path + "../Databases/name table universal"); } NameTableUniversal nameTable = new NameTableUniversal(path + "../Databases/name table universal"); Console.WriteLine("Start P14_Universal_NameTable"); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd; int[] testingcodes = null; foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); if (probe.sol == "LoadAll") { // Загрузка sw.Restart(); int siz = (int)probe.siz; nameTable.Expand(siz, Enumerable.Range(0, siz).Select(i => i.ToString())); nameTable.BuildIndexes(); nameTable.BuildScale(); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("Загрузка OK"); } else if (probe.sol == "TestCompositions") { int siz = (int)probe.siz; foreach (var key in nameTable.Keys.Take(siz)) { if (key == nameTable.GetString(nameTable.GetCode(key))) { continue; } throw new Exception(key + " code:" + nameTable.GetCode(key) + " key:" + nameTable.GetString(nameTable.GetCode(key))); } foreach (var code in nameTable.Codes.Take(siz)) { if (code == nameTable.GetCode(nameTable.GetString(code))) { continue; } throw new Exception(code + " key:" + nameTable.GetString(code) + " code:" + nameTable.GetCode(nameTable.GetString(code))); } res.WriteLine(probe.ToCSV()); Console.WriteLine("TestCompositions OK"); } else if (probe.sol == "Code2StringTime") { rnd = new Random(777777777); int nte = (int)probe.nte; // выберем nte случайных кодов из таблицы имён if (testingcodes == null) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)nameTable.Count - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); } sw.Restart(); long sum = 0L; foreach (var code in testingcodes) { sum += nameTable.GetString(code).Length; } sw.Stop(); probe.sum = sum; probe.tim = sw.ElapsedMilliseconds; probe.tsk = "int2str"; res.WriteLine(probe.ToCSV()); Console.WriteLine("Code2StringTime OK"); } else if (probe.sol == "String2CodeTime") { int nte = (int)probe.nte; rnd = new Random(777777776); // выберем nte случайных строк из таблицы имён if (testingcodes == null) { testingcodes = Enumerable.Range(0, nte) .Select(i => rnd.Next((int)nameTable.Count - 1)) //.Select(i => str2Int.Values.ElementAt(i)) .ToArray(); } string[] keys = testingcodes .Select(i => i.ToString()) .ToArray(); long sum = 0L; sw.Restart(); foreach (var key in keys) { sum += nameTable.GetCode(key); } sw.Stop(); probe.sum = sum; probe.tsk = "str2int"; probe.tim = sw.ElapsedMilliseconds; res.WriteLine(probe.ToCSV()); Console.WriteLine("String2CodeTime OK"); } } res.Close(); }
/// <param name="path">The path of the DirectoryStructure</param> public CommitCommand(string path) { directory = new ProjectDirectory(path); }
public static void Main() { Console.WriteLine("Start P01_PlatformPreperties"); System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); string path = ProjectDirectory.GetProjectDirectory(); TextWriter res = new StreamWriter(new FileStream(path + "res.txt", FileMode.Append, FileAccess.Write)); XElement xcnf = XElement.Load(path + "tests.xml"); XElement xcommon = XElement.Load(path + "../common.xml"); xcommon.Add(xcnf); Random rnd = new Random(); foreach (XElement xprobe in xcnf.Elements()) { ProbeFrame probe = new ProbeFrame(xprobe.AncestorsAndSelf().Attributes()); // измеряются задачи: FlowIO, DirectRand if (probe.sol == "Arr") { // Загрузка sw.Restart(); int siz = (int)probe.siz; long[] arr = Enumerable.Range(0, siz) //.Select(i => (long)(siz-i-1)) //.Select(i => (long)(i)) .Select(i => (long)rnd.Next(siz + siz)) .ToArray(); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; Console.WriteLine("Загрузка OK"); // Сортировка sw.Restart(); Array.Sort(arr); sw.Stop(); probe.ndx = sw.ElapsedMilliseconds; Console.WriteLine("Сортировка OK {0} ms siz={1}", sw.ElapsedMilliseconds, arr.Length); long ssum = 0; sw.Restart(); for (long ii = 0; ii < probe.siz; ii++) { ssum += arr[ii]; } sw.Stop(); probe.scn = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Сканирование OK"); ssum = 0; rnd = new Random(777777777); int[] indexes = Enumerable.Range(0, probe.nte) .Select(i => rnd.Next((int)probe.siz - 1)) .ToArray(); sw.Restart(); for (long ii = 0; ii < probe.nte; ii++) { ssum += arr[indexes[ii]]; } sw.Stop(); probe.tim = sw.ElapsedMilliseconds - probe.scn * probe.nte / probe.siz; probe.sum = ssum; Console.WriteLine("Доступ OK"); res.WriteLine(probe.ToCSV()); } else if (probe.sol == "MStream") { Console.WriteLine("=== MStream"); Stream stream = new MemoryStream(); BinaryWriter bw = new BinaryWriter(stream); BinaryReader br = new BinaryReader(stream); // Загрузка sw.Restart(); int siz = (int)probe.siz; for (int i = 0; i < siz; i++) { bw.Write((long)i); } sw.Stop(); probe.lod = sw.ElapsedMilliseconds; Console.WriteLine("Загрузка OK"); // Сканирование long ssum = 0; sw.Restart(); stream.Position = 0L; for (long ii = 0; ii < probe.siz; ii++) { ssum += br.ReadInt64(); } sw.Stop(); probe.scn = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Сканирование OK"); // Доступ ssum = 0; rnd = new Random(777777777); int[] indexes = Enumerable.Range(0, probe.nte) .Select(i => rnd.Next((int)probe.siz - 1)) .ToArray(); sw.Restart(); for (long ii = 0; ii < probe.nte; ii++) { long off = indexes[ii] * sizeof(long); stream.Position = off; ssum += br.ReadInt64(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Доступ OK"); res.WriteLine(probe.ToCSV()); } else if (probe.sol == "File") { Console.WriteLine("=== File"); Stream stream = new FileStream(path + "../Databases/doublearr.bin", FileMode.Create, FileAccess.ReadWrite); BinaryWriter bw = new BinaryWriter(stream); BinaryReader br = new BinaryReader(stream); // Загрузка sw.Restart(); int siz = (int)probe.siz; for (int i = 0; i < siz; i++) { bw.Write((long)i); if ((i + 1) % 1000000 == 0) { Console.Write("" + (i + 1) / 1000000 + "m "); } } Console.WriteLine(); stream.Flush(); sw.Stop(); probe.lod = sw.ElapsedMilliseconds; Console.WriteLine("Загрузка OK"); // Сканирование long ssum = 0; sw.Restart(); stream.Position = 0L; for (long ii = 0; ii < probe.siz; ii++) { ssum += br.ReadInt64(); } sw.Stop(); probe.scn = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Сканирование OK"); // Доступ ssum = 0; rnd = new Random(777777777); long[] indexes = Enumerable.Range(0, probe.nte) .Select(i => (long)rnd.Next((int)probe.siz - 1)) .ToArray(); sw.Restart(); for (long ii = 0; ii < probe.nte; ii++) { long off = indexes[ii] * (long)sizeof(long); stream.Position = off; ssum += br.ReadInt64(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Доступ OK"); res.WriteLine(probe.ToCSV()); } else if (probe.sol == "ColdScanFile") { Console.WriteLine("=== ColdScanFile (запускается после формировани файла и перезагрузки)"); Stream stream = new FileStream(path + "../Databases/doublearr.bin", FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(stream); // Сканирование long ssum = 0; sw.Restart(); stream.Position = 0L; for (long ii = 0; ii < probe.siz; ii++) { ssum += br.ReadInt64(); } sw.Stop(); probe.scn = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Сканирование OK"); res.WriteLine(probe.ToCSV()); } else if (probe.sol == "ColdRandFile") { Console.WriteLine("=== ColdRandFile (запускается после формировани файла и перезагрузки)"); Stream stream = new FileStream(path + "../Databases/doublearr.bin", FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(stream); // long ssum = 0; // Доступ ssum = 0; rnd = new Random(777777777); int[] indexes = Enumerable.Range(0, probe.nte) .Select(i => rnd.Next((int)probe.siz - 1)) .ToArray(); sw.Restart(); for (long ii = 0; ii < probe.nte; ii++) { long off = indexes[ii] * sizeof(long); stream.Position = off; ssum += br.ReadInt64(); } sw.Stop(); probe.tim = sw.ElapsedMilliseconds; probe.sum = ssum; Console.WriteLine("Доступ OK"); res.WriteLine(probe.ToCSV()); } } res.Close(); }
public ProjectDirectory[] GetDirectories() { lock (p_SyncLock) { ProjectDirectory[] buffer = new ProjectDirectory[p_ChildDirectories.Length]; for (int c = 0; c < buffer.Length; c++) { buffer[c] = Project.ResolveDirectory(p_ChildDirectories[c]); } return buffer; } }
protected override bool ValidateArguments() { if (Sources.Values.Count == 0) { Error.WriteLine($"{Sources.ValueName} should have at least one value."); return(false); } if (Outputs.Values.Count != Sources.Values.Count) { Error.WriteLine($"{Sources.ValueName} has {Sources.Values.Count}, but {Outputs.ValueName} has {Outputs.Values.Count}."); } if (RelativePaths.Values.Count != Sources.Values.Count) { Error.WriteLine($"{Sources.ValueName} has {Sources.Values.Count}, but {RelativePaths.ValueName} has {RelativePaths.Values.Count}."); } if (string.IsNullOrEmpty(ProjectDirectory.Value())) { ProjectDirectory.Values.Add(Environment.CurrentDirectory); } if (string.IsNullOrEmpty(Version.Value())) { Error.WriteLine($"{Version.ValueName} must be specified."); return(false); } else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) { Error.WriteLine($"{Version.ValueName} is not a valid language version."); return(false); } if (string.IsNullOrEmpty(Configuration.Value())) { Error.WriteLine($"{Configuration.ValueName} must be specified."); return(false); } if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) { Error.WriteLine($"{ExtensionNames.ValueName} and {ExtensionFilePaths.ValueName} should have the same number of values."); } foreach (var filePath in ExtensionFilePaths.Values) { if (!Path.IsPathRooted(filePath)) { Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); return(false); } } if (!Parent.Checker.Check(ExtensionFilePaths.Values)) { Error.WriteLine($"Extensions could not be loaded. See output for details."); return(false); } return(true); }
public static ProjectMatchResult Match(ProjectDirectory project, string query) { if (string.IsNullOrEmpty(query)) { return new ProjectMatchResult { Project = project, Success = true } } ; var matches = new List <MatchGroup>(); var part = MatchGroupPart.Shortcut; var partIndex = 0; var success = true; foreach (var c in query.ToLowerInvariant()) { if (part == MatchGroupPart.Shortcut) { if (SearchFromIndex(project.RootShortcut, c, partIndex) is var index && index != -1) { matches.Add(new MatchGroup { Part = part, Index = index, Value = project.RootShortcut.Substring(index, 1) }); partIndex = index + 1; if (project.RootShortcut.Length >= partIndex) { continue; } } if (c == ' ') { continue; } part = MatchGroupPart.ProjectName; partIndex = 0; } if (part == MatchGroupPart.ProjectName) { if (SearchFromIndex(project.Name, c, partIndex) is var index && index != -1) { matches.Add(new MatchGroup { Part = part, Index = index, Value = project.Name.Substring(index, 1) }); partIndex = index + 1; continue; } if (c == ' ') { continue; } success = false; break; } } return(new ProjectMatchResult { Project = project, MatchGroups = matches .GroupContinuously((a, b) => a.Part == b.Part && (a.Index + 1) == b.Index) .Select(g => new MatchGroup { Part = g.First().Part, Index = g.First().Index, Length = g.Count(), }) .ToList(), Success = success }); int SearchFromIndex(string text, char c, int index) => text.ToLowerInvariant().IndexOf(c, index); }
public void StaticWebAssets_BackCompatibilityPublish_Hosted_Works() { // Arrange var testAppName = "BlazorHosted"; ProjectDirectory = CreateAspNetSdkTestAsset(testAppName); ProjectDirectory.WithProjectChanges((project, document) => { if (Path.GetFileNameWithoutExtension(project) == "blazorwasm") { document.Descendants("TargetFramework").Single().ReplaceNodes("net5"); } if (Path.GetFileNameWithoutExtension(project) == "RazorClassLibrary") { document.Descendants("TargetFramework").Single().ReplaceNodes("netstandard2.1"); document.Descendants("PropertyGroup").First().Add(new XElement("RazorLangVersion", "3.0")); } if (Path.GetFileNameWithoutExtension(project) == "classlibrarywithsatelliteassemblies") { document.Descendants("TargetFramework").Single().ReplaceNodes("netstandard2.1"); document.Descendants("PropertyGroup").First().Add(new XElement("RazorLangVersion", "3.0")); } }); // Check that static web assets is correctly configured by setting up a css file to triger css isolation. // The list of publish files should not include bundle.scp.css and should include blazorwasm.styles.css File.WriteAllText(Path.Combine(ProjectDirectory.TestRoot, "blazorwasm", "App.razor.css"), "h1 { font-size: 16px; }"); var publish = new PublishCommand(ProjectDirectory, "blazorhosted"); publish.WithWorkingDirectory(ProjectDirectory.TestRoot); var publishResult = publish.Execute("/bl"); publishResult.Should().Pass(); var publishPath = publish.GetOutputDirectory(DefaultTfm).ToString(); var intermediateOutputPath = publish.GetIntermediateDirectory(DefaultTfm, "Debug").ToString(); // GenerateStaticWebAssetsManifest should generate the manifest file. var path = Path.Combine(intermediateOutputPath, "staticwebassets.publish.json"); new FileInfo(path).Should().Exist(); var manifest = StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)); // We have to special case this test given we are forcing `blazorwasm` to be a `net5` project above. // Given this, the `dotnet.*.js` file produced will be a dotnet.5.*.*.js file in line with the TFM and not the SDK (which is .NET 6 or beyond). // This conflicts with our assumptions throughout the rest of the test suite that the SDK version matches the TFM. // To minimize special casing throughout the entire test suite, we just update this particular test's assets to reflect the SDK version. var numFilesUpdated = 0; var frameworkFolder = Path.Combine(publishPath, "wwwroot", "_framework"); var frameworkFolderFiles = Directory.GetFiles(frameworkFolder, "*", new EnumerationOptions { RecurseSubdirectories = false }); foreach (var f in frameworkFolderFiles) { if (Regex.Match(f, DotNet5JSRegexPattern).Success) { File.Move(f, Regex.Replace(f, DotNet5JSRegexPattern, DotNet5JSTemplate)); numFilesUpdated++; } } Assert.Equal(3, numFilesUpdated); AssertManifest(manifest, LoadPublishManifest()); AssertPublishAssets( StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)), publishPath, intermediateOutputPath); }
private void triggerRemoveDirectory(ProjectDirectory dir) { if (FileDelete == null) { return; } dir.Enumerate(true, delegate(ProjectEntity e) { if (e is ProjectFile) { FileDelete(this, (ProjectFile)e); } return true; }); }
protected override bool ValidateArguments() { if (Sources.Values.Count == 0) { Error.WriteLine($"{Sources.Description} should have at least one value."); return(false); } if (Outputs.Values.Count != Sources.Values.Count) { Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {Outputs.Description} has {Outputs.Values.Count} values."); return(false); } if (RelativePaths.Values.Count != Sources.Values.Count) { Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {RelativePaths.Description} has {RelativePaths.Values.Count} values."); return(false); } if (DocumentKinds.Values.Count != 0 && DocumentKinds.Values.Count != Sources.Values.Count) { // 2.x tasks do not specify DocumentKinds - in which case, no values will be present. If a kind for one document is specified, we expect as many kind entries // as sources. Error.WriteLine($"{Sources.Description} has {Sources.Values.Count}, but {DocumentKinds.Description} has {DocumentKinds.Values.Count} values."); return(false); } if (string.IsNullOrEmpty(ProjectDirectory.Value())) { ProjectDirectory.Values.Add(Environment.CurrentDirectory); } if (string.IsNullOrEmpty(Version.Value())) { Error.WriteLine($"{Version.Description} must be specified."); return(false); } else if (!RazorLanguageVersion.TryParse(Version.Value(), out _)) { Error.WriteLine($"Invalid option {Version.Value()} for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); return(false); } if (string.IsNullOrEmpty(Configuration.Value())) { Error.WriteLine($"{Configuration.Description} must be specified."); return(false); } if (ExtensionNames.Values.Count != ExtensionFilePaths.Values.Count) { Error.WriteLine($"{ExtensionNames.Description} and {ExtensionFilePaths.Description} should have the same number of values."); } foreach (var filePath in ExtensionFilePaths.Values) { if (!Path.IsPathRooted(filePath)) { Error.WriteLine($"Extension file paths must be fully-qualified, absolute paths."); return(false); } } return(true); }
public void ExpandDirectory(ProjectDirectory directory) { TreeNode node = findNodeByTag(directory); if (node == null) { return; } node.Expand(); }