|
If you can read the code (for example from a file), compile it and investigate fields, functions etc without actually parsing it yourself, CodeDOM should be useful.
If you really want to parse the original yourself, have a look at for example Yacc[^] which can also be found for Windows.
The need to optimize rises from a bad design
|
|
|
|
|
Just to make clear what I want.
I have a Sourcefile (c, cpp, h...) and want to check if the pass certian programming rules (in my case the MISRA-C 2004 rules). Therefore I need all the Variables and Functions. Can I do that with the Codedom? And if yes can you please post me an example?
|
|
|
|
|
|
Hi, take a look at Irony .NET. you can find references here in CP. It's well worth to take a look, I think it does what you want.
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
Irony is quite good.
As is PerCendburg(?) Grammatica. Used that for quite a few projects where I've had a configuration DSL.
|
|
|
|
|
Hi any one.
i want to create some class library and allow user to add it some data in a Collection.(example of it is Items property in Combobox or listbox).
i define a Dictionary collection and when using , it appear in control library but when i click it to add some data it show a disabled window.
its my public property:
public Dictionary<int32,> States
{
get
{
return MySexCell.States;
}
set
{
MySexCell.States = value;
}
}
sepel
modified on Tuesday, October 7, 2008 2:01 PM
|
|
|
|
|
sepel wrote: public Dictionary<int32,> States
Does that even compile? You need two datatypes in a Dictionary definition, one type for the key and one for the value.
Perhaps you should use a List instead of a Dictionary ?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I'm to being DIZZY .
i write dictionary (int32,string)but it dosen't appear.(using "(" instade of "<")
take it easy . i try to use List.
But think about this forum syntax way does not appear my code.
I test another type for my second Dictionary parameter but after post it no one appear.
sepel
modified on Tuesday, October 7, 2008 1:52 PM
|
|
|
|
|
MySexCell? *sniggers* Just what kind of application is this?
You probably don't want to expose a "set" accessor. That is if you want people to change the entire dictionary. People can "get" the dictionary and then call .Add on it.
You need to google the correct attributes to put on your property to enable designer support.
|
|
|
|
|
Hahahah.(MySexCell)
it is a cell that for male or female that saved in bit format in db, show corespond string such as "man or woman or Mr or
Mrs,...".
i think i should use Attribute . tnx
sepel
|
|
|
|
|
Suppose I have this class:
public abstract class EmployeeBase
{
public string _sEmpName = "Some One";
public int _iPayRate = 0;
public abstract string sEmpName
{
get;set;
}
public abstract int iPayRate
{
get;set;
}
public abstract void CalcPay();
}
I then subclass it as:
public class FTEmployee : EmployeeBase
{
private new string _sEmpName;
private new int _iPayRate = 0;
public override string sEmpName
{
get {return _sEmpName;}
set {_sEmpName = value;}
}
public override int iPayRate
{
get {return _iPayRate;}
set {_iPayRate = value;}
}
public override void CalcPay()
{
}
}
I'm trying to define the _sEmpName member in the base class and make it private in the subclass, but when I test it, the _sEmpName member contains Null.
Can someone help a newbie?
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: when I test it, the _sEmpName member contains Null.
Not in the base class it isn't.
You have two _sEmpName members - one in the base class and one
in the derived class.
Sounds like you just need the one in the base class.
Only methods/accessors can be abstract.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What I'm trying to do is define the member in the base, then make it private in the subclass so that the property implementations can access it.
When I made the members private in the base I get the error
"Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
Everything makes sense in someone's mind
|
|
|
|
|
KMAROIS wrote: When I made the members private in the base I get the error
"Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
Correct. As John mentions below, you can't access a private member
outside the class, including derived classes.
Try protected instead.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Make the variables private in the base class and don't define them in the derived class since you inherit them
KMAROIS wrote: public abstract class EmployeeBase
{
private string _sEmpName = "Some One";
private int _iPayRate = 0;
KMAROIS wrote: public class FTEmployee : EmployeeBase
{
private new string _sEmpName;
private new int _iPayRate = 0;
led mike
|
|
|
|
|
A private variable isn't visible to derived classes - he has to make them protected if he wants them visible unless he has public (or protected) properties.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Bingo! That's what I was looking for.
Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
John Simmons / outlaw programmer wrote: he has to make them protected
correct, my mistake. Good thing compilers tell me about my errors like that eh?
led mike
|
|
|
|
|
I tried that, but then the property implementations in the FTEmployee class I get the error "Abstract.EmployeeBase._sEmpName' is inaccessible due to its protection level"
That' why I thought I needed to make the public in the base and private in the subclass.
Everything makes sense in someone's mind
|
|
|
|
|
Looks like you're also using the new keyword in the derived class as well. Get rid of new (unless you WANT to disregard the members in the base class) and mark the base classes members as protected as John pointed out. Another maybe unwanted tip here would to use constructors to force a fully instantiated object when it's created. Mark the setters as private and assign them in the constructor. Otherwise you'll have 3 lines and a possibly unusable object as opposed to one line and reliable data.
public abstract class EmployeeBase {
private string _sEmpName = "Some One";
private int _iPayRate;
protected EmployeeBase(String name, int payrate) {
EmployeeName = name;
PayRate = payrate;
}
public string EmployeeName {
get { return _sEmpName; }
private set { _sEmpName = value; }
}
public int PayRate {
get { return _iPayRate; }
private set { _iPayRate = value; }
}
public abstract void CalcPay();
}
public class FTEmployee : EmployeeBase {
public FTEmployee(String name, int payrate) :
base(name, payrate) {
}
public override void CalcPay() {
}
}
public void SomeNonsense() {
FTEmployee employee = new FTEmployee("James Harwood", 65000);
}
hope that helps...
Oh, and if you're using .NYET 2.0 have a look at Auto-Properties so you don't have to always implement the backing field in a property.
Scott P
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
You don't need to have
private new string _sEmpName;
private new int _iPayRate = 0;
in the derived class. The public properties should work for you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Can any one help,
Is the Conversion of VB.net 2.0 code to ASP is possible or not?
Thanks,
|
|
|
|
|
Depends. Assuming you mean asp.NET, then any non-gui related code (such as business logic and database logic) should be reusable, but the gui bits will have to be re-worked.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi all..
can anyone help me..i am retrieving data from sql in a dataset, i wanna create a dynamic table to place the values in.
the table must look as follows:
Account Name Date
AccountName UserName UserDate
the first row is normal text inserted by me, the second row is retrieved from the dataset...can anyone plz assist me on this.
living life on the flip side
|
|
|
|
|
Agweet wrote: i wanna create a dynamic table
Why? That would be something that a stored procedure might do but not an application.
led mike
|
|
|
|