Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Interface implementation
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