I need to generate a class using Reflection.Emit that implements the following interface.
public interface IObject
{
T Get<T>(string propertyName);
}
Does anyone have an example of how I would emit the following as a simple test case?
class GeneratedObject : IObject
{
public T Get<T>(string propertyName)
{
// thi...
The responsibility of the visibility of a method is relegated to the class that implements the interface.
public interface IMyInterface
{
bool GetMyInfo(string request);
}
In C# set access modifier public, private or protected before the method GetMyInfo() generates the following error: The modifier 'private' is not valid for this i...
Hey
Im trying to use generic types for the first time in Java , as I only want my constructor to accept classes that implement the "Anealable" interface. theres a problem with my code by the only error I get is "Illegal start of Type" which is not getting very far with trying to make it work
here is the code for my class
package simul...
public class Foo : IFoo
...
What is the difference between
IFoo foo = new Foo();
and
Foo foo = new Foo();
...
Sorry for the poor title, can't think of a succinct way of putting this..
I'm thinking of having a list of objects that will all be of a specific interface. Each of these objects may then implement further interfaces, but there is no guarantee which object will implement which. However, in a single loop, I wish to be able to call the me...
Is there any way I can get VS2008 to provide further detail on how a particular interface should be implemented?
I'm thinking along the lines of how the /// tags work when using a method. It seems to me that sometimes the method name and params just can't provide enough information about exactly how the interface is meant to work.
Edi...
Hello everyone,
I'm looking at how to solve a problem and I'm not even sure this might be possible at all in C# & .NET 3.5:
Say I have a limited number of interfaces, each describing a specific, non-related set of methods. Now I have a number real-world devices which each may implement just a subset of these interfaces.
During set-up ...
Hi
I have 2 base interfaces, IViewBase (which all views will implement) and IPresenterBase (which all presenters will implement):
public interface IViewBase { }
public interface IPresenterBase
{
IViewBase View { get; set; }
}
Then i've created a new interface ILogPresenter that derives from IPresenterBase and ILogView deriving f...
Hi,
We've got a large system that's loosely bound to its data source (Navision) via Unity - we're getting the opportunity to swap it out and have our own database.
So we've had a look around and really like the look of Fluent NHibernate - we're trying to get a proof of concept going and swap out a couple of the services.
We want to us...
This is something curious that I saw in my coding today.
Here is the sample code:
public class SomeClass
{
public IUtils UtilitiesProperty { get; set; }
}
public interface IUtils
{
void DoSomething();
}
public class Utils : IUtils
{
void DoSomething();
}
This compiles fine.
So what is UtilitiesProperty? Is it a Util? ...
I'm trying to map an interface and concrete class with fluentnhibernate.
here's my interface / class:
public interface IUser
{
int Id { get; set; }
}
public class User: IUser
{
public int Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
}
here's my mapping files:
public class IUserM...
AccountController can't extend BaseAccount and BaseController at the same time. If I make all BaseAccount or BaseController methods empty, I can have an interface, but if I implement that interface in two different places, that is, I make a contract to implement a method in two different places, I will have duplicated code. Do interfaces...
I have an interface which is now empty, and extends another interface. I'd like to remove the empty interface and use the base interface, and am trying to find the correct refactoring in IntelliJ.
I've tried "remove middleman" but got "cannot perform the refactoring. The caret should be positioned at the name of the field to be refactor...
I have a data access library that has a few classes that all implement the same interface, which has a generic type parameter:
public interface IGetByCommonStringRepository<TEntity>
{
TEntity GetByCommonStringColumn(string commonString);
}
public class Repository1<Entity1> : IGetByCommonStringRepository<Entity1>
{
public Entity...
I am working with MVP in ASP.NET and wanted see if there is an easier/cleaner way to do this.
I have a presenter with a view. It turns out I can reuse some of the view properties and presenter methods in other views/presenters in the same application area.
Lets say I have a Bar, which is logically a Foo. The base presenter, FooPresen...
In C# I can create an interface, and when I use the interface the compiler knows that certain interface requirements are fulfilled by the base class. This is probably clearer with an example:
interface FormInterface
{
void Hide();
void Show();
void SetupForm();
}
public partial class Form1 : Form , FormInterface
{
publ...
Hello,
I know that we can't have constructor in an interface but here is what I want to do :
interface ISomething
{
void FillWithDataRow(DataRow)
}
class FooClass<T> where T : ISomething , new()
{
void BarMethod(DataRow row)
{
T t = new T()
t.FillW...
I recently saw some code using macros like
#define CONTAINS(Class, Name)\
private:\
std::list<Class> m_##Name##s;\
public:\
void add_##Name(const Class& a_##Name) {\
m_##Name##s.push_back(a_##Name);\
}\
int get_##Name(int pos) {\
return m_##Name##s.at(pos);\
}\
...
I want to make an interface in C# that defines a method that always returns an object of the implementing class, thus:
public interface IParser {
IParser Parse(string s);
}
public class Parser : IParser {
public Parser Parse(string s) {
return new Parser(s);
}
}
Can I force an implementing class to return an objec...
I added 3 optional boolean parameters to a method found within a VB6 DLL. The class that houses it is MultiUse (public), and the method itself is Private. The class implements a specific interface from a TLB, allowing for public calls to this method.
After adding the 3 optional parameters on the VB6 side, I modified related C# code so t...