473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inconsistent accessibility In base class and derived class

While working on a scripting engine I Encountered the following problem.
First I Created an abstract base class EPType that represent a variable type in the script.

Expand|Select|Wrap|Line Numbers
  1.     internal abstract class EPType
  2.     {
  3.         private String m_Name;
  4.         public String Name
  5.         {
  6.             get { return m_Name; }
  7.         }
  8.         public EPType(String Name)
  9.         {
  10.             m_Name = Name;
  11.         }
  12.         public abstract Object ParseValue(String str);
  13.     }
second I Add the two following classes

Expand|Select|Wrap|Line Numbers
  1.    public abstract class EPValueType : EPType
  2.     {
  3.         private EPReferenceType m_RefType;
  4.         public EPValueType(String strName)
  5.             : base(strName)
  6.         {
  7.             m_RefType = new EPRefernceType(strName + "Ref", this);
  8.         }
  9.         internal EPReferenceType ReferenceType
  10.         {
  11.             get { return m_RefType; }
  12.         }   
  13.     }
  14.     internal class EPReferenceType : EPType
  15.     {
  16.         private EPValueType m_Type;
  17.         public EPReferenceType(String strName, EPValueType vType)
  18.             : base(strName)
  19.         {
  20.             m_Type = vType;
  21.         }
  22.         public EPValueType Type
  23.         {
  24.             get { return m_Type; }
  25.         }
  26.         public override object ParseValue(string str)
  27.         {
  28.             return str;
  29.         }    
  30.     }
the problem is that i want EPValueType to be "seen" outside the current assembly so that anyone using this engine will be able to inherit from it and add new types, but I dont want it's base class EPType to be seen since there are only two categories of types, reference type and value type.But if I set EPType as an internal class and EPValueType as a public class i get an Inconsistent accessibility error. is there a way to do what i want without changing the entire design of the scripting engine?

hope I was clear...i got the the feeling that i wasn't :X

thanks in advance
Feb 29 '08 #1
3 3177
skipbr
13
Expand|Select|Wrap|Line Numbers
  1. [System.ComponentModel.Browsable(false)]
  2. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  3. public abstract class EPType
  4. {
  5.         private String m_Name;
  6.         public String Name
  7.         {
  8.             get { return m_Name; }
  9.         }
  10.         public EPType(String Name)
  11.         {
  12.             m_Name = Name;
  13.         }
  14.         public abstract Object ParseValue(String str);
  15. }
This will hide the class, even it being public.
Feb 29 '08 #2
Expand|Select|Wrap|Line Numbers
  1. [System.ComponentModel.Browsable(false)]
  2. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
  3. public abstract class EPType
  4. {
  5.         private String m_Name;
  6.         public String Name
  7.         {
  8.             get { return m_Name; }
  9.         }
  10.         public EPType(String Name)
  11.         {
  12.             m_Name = Name;
  13.         }
  14.         public abstract Object ParseValue(String str);
  15. }
This will hide the class, even it being public.
it hides the class partialy(only from the intellisense menu). I can still inherit from it in a diffrent assembly if I know it's name. what i'm looking for is a way to make EPType completly inaccessible.
Mar 1 '08 #3
Expand|Select|Wrap|Line Numbers
  1. internal abstract class EPType
  2.     {
  3.         private String m_Name;
  4.         public String Name
  5.         {
  6.             get { return m_Name; }
  7.         }
  8.         public EPType(String Name)
  9.         {
  10.             m_Name = Name;
  11.         }
  12.         public abstract Object ParseValue(String str);
  13.     }
  14.  
You will have to make EPType public. However, you can prevent assemblies outside of that one from inheriting your base type, by making an internal constructor.

Expand|Select|Wrap|Line Numbers
  1. public abstract class EPType
  2.     {
  3.         private String m_Name;
  4.         public String Name
  5.         {
  6.             get { return m_Name; }
  7.         }
  8.         internal EPType(String Name)
  9.         {
  10.             m_Name = Name;
  11.         }
  12.         public abstract Object ParseValue(String str);
  13.     }
  14.  
This way, any classes outside of EPType's assembly that tries to inherit it, will recieve an error of: The type EPType has no constructor defined.
Mar 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
7
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
4
by: waltborders | last post by:
Hi, Because the blind are unable to use a mouse, keyboard navigation is key. A major difficulty is that not all windows forms controls are keyboard 'tab-able' or 'arrow-able' or have "tab...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
5
by: Andy Fish | last post by:
Consider the following code fragment public class Wrapper { protected enum E { IN, OUT }; public class C { protected void foo(E e) { } } } I want the class C to be accessible from outside...
6
by: Taran | last post by:
Hi All, I tried something with the C++ I know and some things just seem strange. consider: #include <iostream> using namespace std;
5
by: Dennis Jones | last post by:
Hello, I have a couple of classes that look something like this: class RecordBase { }; class RecordDerived : public RecordBase {
1
by: bachyen | last post by:
I have the following code, but it is error when I build it. Can you help me? Can you tell me more about 'Inconsistent accessibility: return type', 'Inconsistent accessibility: parameter type'. ...
9
by: dylan.miller | last post by:
I'm having trouble understanding the internal access modifier. There are many classes in my assembly that should not be accessible outside of the assembly. I've used the internal access modifier...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.