Solved

one interface implementing another

Posted on 2012-03-23
3
270 Views
Last Modified: 2012-06-27
I want to have the two interfaces below.

public interface IWriteable<T>
                where T : class
{
    void Add(T newEntity);
    void Remove(T entity);
}

Open in new window


public interface IReadable<T>
            where T : class
{
    IQueryable<T> FindAll();
    IQueryable<T> FindWhere(Expression<Func<T, bool>> predicate);
    T FindById(int id);
    T FindById(Guid id);
}

Open in new window


Basically I want to control certain elements of different aspects of my website.

So some repositories will only be able to read certain classes, some read/write.

What I want though is for IWriteable to also Implement IReadable as my attitude is if something has the permission to write it is ok to read.

Using my interface above how to I make Iwritebale implement IReadabale?
0
Comment
Question by:scm0sml
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 37757358
Interfaces cannot provide implementation details, but you can certainly mark you IWriteable as "implementing" (only word I could think of, sorry) the IReadable interface, whose implementation responsibilities would also be passed along to classes implementing IWriteable. You simply need to note it in the implementation list (again, sorry). For example:

public interface IWriteable<T> : IReadable<T>
                where T : class
...

Open in new window

0
 

Author Comment

by:scm0sml
ID: 37757381
Thats exactly what I was after thanks!

Probably didint explain myself very well!
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37757389
Probably didint explain myself very well!
I'd say you explained it just fine  = )

Glad to help!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question