diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35d4ccd --- /dev/null +++ b/.gitignore @@ -0,0 +1,206 @@ +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +# [Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# Remainings from resolvings conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +**/node_modules/* + +# Added by Jskonst +.vscode/ +Properties/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### \ No newline at end of file diff --git a/Program/Program.cs b/Program/Program.cs new file mode 100644 index 0000000..0e5e8b7 --- /dev/null +++ b/Program/Program.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; + +namespace ConsoleApp +{ + public class Program + { + public static Dictionary SetNewDictionary(Dictionary>> dict) + { + Dictionary dictresult = new Dictionary(); + string reskey = ""; + foreach (var x in dict) + { + if (x.Value is Dictionary>) + { + reskey = x.Key + "/"; + foreach (var y in x.Value) + { + if (y.Value is Dictionary) + { + reskey += y.Key + "/"; + foreach (var z in y.Value) + { + if (z.Value is string) + { + dictresult.Add(reskey + z.Key, z.Value); + } + } + } + } + } + } + return dictresult; + } + static public void Main(string[] args) + { + Dictionary>> dictionary = new Dictionary>>(); + dictionary.Add("a", new Dictionary>()); + dictionary["a"].Add("b", new Dictionary()); + dictionary["a"]["b"].Add("c", "12"); + dictionary["a"]["b"].Add("d", "Hello World"); + foreach (var a in SetNewDictionary(dictionary)) + { + Console.WriteLine(a); + } + + + } + } +}; \ No newline at end of file diff --git a/Program/Program.csproj b/Program/Program.csproj new file mode 100644 index 0000000..8a6317a --- /dev/null +++ b/Program/Program.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.0 + + + + + + + diff --git a/Program/Program.sln b/Program/Program.sln new file mode 100644 index 0000000..4bcbbc0 --- /dev/null +++ b/Program/Program.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.852 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Program", "Program.csproj", "{73C60823-A309-4DB1-9963-E4C2921B2055}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject1", "..\XUnitTestProject1\XUnitTestProject1.csproj", "{7EA94ABA-1B14-4812-89B6-586EFE9BF36A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {73C60823-A309-4DB1-9963-E4C2921B2055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {73C60823-A309-4DB1-9963-E4C2921B2055}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73C60823-A309-4DB1-9963-E4C2921B2055}.Release|Any CPU.ActiveCfg = Release|Any CPU + {73C60823-A309-4DB1-9963-E4C2921B2055}.Release|Any CPU.Build.0 = Release|Any CPU + {7EA94ABA-1B14-4812-89B6-586EFE9BF36A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7EA94ABA-1B14-4812-89B6-586EFE9BF36A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7EA94ABA-1B14-4812-89B6-586EFE9BF36A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EA94ABA-1B14-4812-89B6-586EFE9BF36A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {29D3FEF4-C6B7-445C-8849-A168496B8F1E} + EndGlobalSection +EndGlobal diff --git a/XUnitTestProject1/UnitTest1.cs b/XUnitTestProject1/UnitTest1.cs new file mode 100644 index 0000000..3f70acc --- /dev/null +++ b/XUnitTestProject1/UnitTest1.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using Xunit; + +namespace ConsoleApp +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + Dictionary>> dictionary = new Dictionary>>(); + dictionary.Add("a", new Dictionary>()); + dictionary["a"].Add("b", new Dictionary()); + dictionary["a"]["b"].Add("c", "World"); + dictionary["a"]["b"].Add("d", "Hello"); + Dictionary truedict = new Dictionary(); + truedict.Add("a/b/c", "World"); + truedict.Add("a/b/d", "Hello"); + Assert.Equal(truedict, Program.SetNewDictionary(dictionary)); + } + + [Fact] + public void Test2() + { + Dictionary>> dictionary = new Dictionary>>(); + Dictionary truedict = new Dictionary(); + Assert.Equal(truedict, Program.SetNewDictionary(dictionary)); + } + } +} \ No newline at end of file diff --git a/XUnitTestProject1/XUnitTestProject1.csproj b/XUnitTestProject1/XUnitTestProject1.csproj new file mode 100644 index 0000000..aecc707 --- /dev/null +++ b/XUnitTestProject1/XUnitTestProject1.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp3.0 + + false + + + + + + + + + + + + + +