Hi,
i have a namespace string like "Company.Product.Sub1.Sub2.IService". The Sub1/Sub2 can differ in their count, but normally their is one part which matches to a Dictionary with AssemblyFullname as key and path to it as value.
Now ive written this code
string fullName = interfaceCodeElement.FullName;
var fullNameParts = interfaceCodeElement.FullName.Split('.').Reverse();
KeyValuePair<string, string> type = new KeyValuePair<string,string>();
foreach (var item in fullNameParts)
{
var match = references.Where(x => x.Key.Contains(item)).ToList();
if (match.Count > 0)
{
type = match[0];
break;
}
}
Works but doesnt look nice in my opinion.
I tried it with linq but i dont know how ive to write it.
var matches = from reference in refs
where reference.Key.Contains(fullNameParts.Reverse().
Thanks for help.