vendredi 2 décembre 2016

Get all types with some type included in properties

I read type from loaded assemblies:

var someType = loadedAssemblies
 .Where(a => a != null && a.FullName.StartsWith("MY."))
 .SelectMany(a => a.GetTypes())
 .Distinct()
 .ToArray()[0];

Type name is "AddressesRevisionContainerId".

Now i have this 2 classes:

public class RevisionContainer {
  public RevisionContainer(RevisionContainerId revisionContainerId)
  {
    this.RevisionContainerId = revisionContainerId;
  }

  public virtual RevisionContainerId RevisionContainerId { get; private set;}
}

public class AddressesRevisionContainerId : RevisionContainerId
{}

If you have someType, how can you find all classes, which have this type included? For example, how can I find from type "SomeType" that it is included in RevisionContainer class (and maybe some other class)?





Aucun commentaire:

Enregistrer un commentaire