Created
January 8, 2018 20:21
-
-
Save guitarrapc/705fcd25084be1a1c3807933ebeae278 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var hoge = new[] | |
{ | |
"ccc/hoge/Resources/fuga/tyger", | |
"ghoge/Resources/fuga/tyger", | |
"zxvzxvcz/Resources/fuga/tyger/hogemoge", | |
"test/fuga/Resources/fuga/tyger", | |
"asdfadga/fuga/Resources/fuga/tyger/hogemoge", | |
}; | |
var concat = hoge.OrderBy(x => x).Select(x => | |
{ | |
var index = x.LastIndexOf("Resources", System.StringComparison.InvariantCultureIgnoreCase); | |
var name = x.Substring(index, x.Length - index).Replace("Resources/", "").Replace("resources/", ""); | |
return new ResourceInfo(x, name); | |
}) | |
.ToArray(); | |
var duplicates = concat.GroupBy(x => x.Name).Where(x => x.Count() > 1).ToArray(); | |
if (duplicates.Any()) | |
{ | |
var dup = duplicates.SelectMany(x => x.OrderBy(y => y.SubdirectoryCount).Skip(1)); | |
concat.Except(dup).Dump(); | |
} | |
} | |
// Define other methods and classes here | |
private struct ResourceInfo | |
{ | |
public string Path; | |
public string Name; | |
public int SubdirectoryCount; | |
public ResourceInfo(string path, string name) | |
{ | |
Path = path; | |
Name = name; | |
SubdirectoryCount = Path.Replace("/" + Name, "").Count(y => y == '/'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment