I apologize in advance if this gets a little convoluted.
I have an attribute class like so:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RepositoryCollectionMethodAttribute : Attribute
{
public string MethodName { get; set; }
public RepositoryCollectionMethodAttribute(string methodName)
{
MethodName = methodName;
}
}
I am traversing my class domain using EnvDTE
, collecting classes for code generation. Finding a class that decorates one or more properties with the RepositoryCollectionMethod
.
This part was relatively easy, so for each class with some of these properties decorated, I now have an IEnumerable<CodeProperty>
I call properties
.
Now I'm stuck. Due to the nature of these EnvDTE objects (which seem to have an aversion to strong typing and good documentation/ examples) I cannot figure out how to extract a distinct list of MethodName
property values from the collection of properties, at least one of which will have a RepositoryCollectionMethod
decorating it.
In other words, if I have a class `Foo' like this:
public class Foo
{
public Guid FooId { get; set; }
[RepositoryCollectionMethod("GetFoosByCategory")]
public string Category { get; set; }
[RepositoryCollectionMethod("GetFoosByClass")]
[RepositoryCollectionMethod("GetFoosByClassAndLot")]
public string Class { get; set; }
[RepositoryCollectionMethod("GetFoosByLot")]
[RepositoryCollectionMethod("GetFoosByClassAndLot")]
public string Lot { get; set; }
}
...given an IEnumerable<CodeProperty>
of Foo
's properties, I would like to generate the following list:
- GetFoosByCategory
- GetFoosByClass
- GetFoosByClassAndLot
- GetFoosByLot
Can anyone help me with this?