c# - Extension Method for Interface in Internal Class -


i trying write extensions dynamic linq. need add method signature ienumerablesignatures interface located in internal class expressionparser.

internal class expressionparser {     interface ienumerablesignatures     {         [...]     } } 

while add signature code directly, i'd rather define extension method interface, keep original code clean. usually, add method defaultifempty, this:

internal static class extension  {     static void defaultifempty(this expressionparser.ienumerablesignatures sig); } 

this gives access error though, because expressionparser internal. have tried several combinations of access level class , method.

is there way add extension method such interface or have mess original code?

[edit] turns out that, when making interface internal (or public matter), not recognized dynamic linq. still got not-found exception on runtime. there's no (obvious) way around editing codeplex code. [/edit]

you can not since ienumerablesignatures private interface (it has no access modifier , default 1 private) , there no way access outside of expressionparser class.

but if can change interface access modifier there should no problem if assign access modifiers correct.

internal static class extension {     internal static int foo(this expressionparser.ienumerablesignatures b)     {         return b.ib;     } }  internal class expressionparser {     public int ia { get; set; }     internal interface ienumerablesignatures     {         int ib { get; set; }     } } 

you can not hide safe (private/less accessible/inner class) inside house (outer class) if give key someone.

you can not use less accessible class in class higher accessibility. example using private class in public one. can not make public extension method class internal because can not use public extension method outside assembly because can not access internal class outside of assembly!


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -