I have the following class and I am trying to create an interface for this. However when I try refactor in VS2010. I get a message that: Could not extract interface. The type does not contain any members that could be extracted to an interface.
Is this related to my defining the class and/or method as static? What I do need is to be able to get this data without having to create an instance so that's why I made it all static.
public static class DataSourceService
{
public static IEnumerable<DataSource> GetDataSources()
{
return new[]
{
new DataSource { Value = "0001", Text = "Development" },
new DataSource { Value = "0002", Text = "Production" }
};
}
}
You cannot have a static class with an interface, that's why the refactor tool cannot extract one. You would need to turn it into an instance class with instance members in order to extract an interface.
You don't have any methods that could be extracted. static
methods can't belong to an interface.
Google for static interface method
and you'll get some interesting articles such as http://discuss.joelonsoftware.com/default.asp?dotnet.12.305680.12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With