Solved

one interface implementing another

Posted on 2012-03-23
3
266 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

861 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now