Created
May 2, 2014 14:17
-
-
Save zippy1981/6383276113d0400a595b to your computer and use it in GitHub Desktop.
Interface implementation
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
interface IDependency | |
{ | |
int I { get; } | |
} | |
interface IService : IDependency | |
{ | |
int J { get; set; } | |
string Stuff { get; set; } | |
} | |
public abstract class Abba : IService | |
{ | |
public int I { get; private set; } | |
public int J { get; set; } | |
public abstract string Stuff { get; set; } | |
} | |
public class AbbaTeen : Abba | |
{ | |
public override string Stuff | |
{ | |
get | |
{ | |
throw new NotImplementedException(); | |
} | |
set | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} | |
public class LynardSkynard : IDependency | |
{ | |
public int I { get; private set; } | |
} | |
public class Other | |
{ | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var types = Assembly.GetExecutingAssembly().GetTypes(); | |
var typesEx = | |
from type in types | |
where type.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IService)) | |
select new | |
{ | |
type.Name, | |
type.FullName, | |
type.GetTypeInfo().ImplementedInterfaces | |
}; | |
foreach (var type in typesEx) | |
{ | |
Console.WriteLine("Name: {0}, FullName: {1} Dependencies", type.Name, type.FullName); | |
foreach (var iinterface in type.ImplementedInterfaces) | |
{ | |
Console.WriteLine("\t\tName: {0}, FullName: {1} Dependencies", iinterface.Name, iinterface.FullName); | |
} | |
} | |
Console.Write("Presss any key to continue . . ."); | |
Console.ReadKey(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment