|
No AnotherPartOfLibrary is not inherited from MyBase. They don't have any relationship. This a library which can be extent. Its a component for the programmers. My problem is related to design of the component. Ok I will tell you the scenario. In this library, I am not aware of the user implemented classes. The users will implement the classes by extending the classes in my library. So those classes are defined only at the time of user implementation, not at the time of designing the library. Here comes my problem. I want to call the user extended functionalities in my library. Hope I am clear now.
|
|
|
|
|
I agree with the other answer...are you sure you don't want an interface and not an abstract class?
Also, how are you not getting errors with what's written anyway? First, you need to specify that abstract void DoSomething() is public. Secondly, in order to implement it, you have to override it in the class that inherits from it. In other words, it should be
public override void DoSomething()
And why would you ever want to call a method within an abstract class? You want to call a method within a class that inherits that abstract class. Unless, you just want an interface.
If you just want an interface, you would want something like this:
|
|
|
|
|
William Winner wrote: how are you not getting errors with what's written anyway?
yes I know I can't call a method in an abstract class, it will make a runtime error. I just demonstrated how I want to implement it. It was to make clear my idea.
William Winner wrote: Secondly, in order to implement it, you have to override it in the class that inherits from it. In other words, it should be
public override void DoSomething()
Sorry that was a typo.
William Winner wrote: And why would you ever want to call a method within an abstract class? You want to call a method within a class that inherits that abstract class. Unless, you just want an interface.
May be I couldn't explained my problem properly. This is a design issue. myBase and AnotherPartOfLibrary are in my library. The
UserImplementation is not part of my library. It declared only at the time of user implementation. That is my problem. This a set of components for the use of programmers. They can use the classes in library. Also they can inherit some class for extending its functionality. So my problem is, while designing this set of classes I am not aware of the classes the users going to implement. How can I initialize those classes in my classes?
|
|
|
|
|
Your users can pass any instance of thier class that derives from your abstract base class to any method that has a parameter of your base class's type as per my earlier example. You will only have access to properties/methods declared (not necessarily implemented) in the base class of course - but that's all you need.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
To do this you need to either have a parameter of MyBase or ineriting class in the method
public abstract class MyBase
{
public abstract void DoSomething();
}
public class AnotherPartOfLibrary
{
public void AnotherFunction(MyBase myBase)
{
myBase.DoSomething();
}
}
public class UserImplementation : MyBase
{
public override void DoSomething()
{
throw new NotImplementedException();
}
} or a field of MyBase or inheriting class that you can use in AnotherPartOfLibrary .
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
I'm trying to obtain the row number yet I haven't been able to figure out how. I have tried this:
x = reunionBindingSource.Position;
However, since I have already done this:
this.reunionBindingSource.Sort = "LastName";
the position does not equal the row number. I know I can save the position number, unsort it, grab the row number from position, resort it, and set the position. I could also build a dictionary before sorting it using the database key as the dictionary key, but there has to be a better way.
Thank you,
Glenn
modified on Thursday, May 13, 2010 1:01 PM
|
|
|
|
|
Sorry - but not sure what a non-grid view is...
|
|
|
|
|
What I mean from a non-grid view is a detail view, where the controls are individual controls on a form instead of a grid view.
Thank you,
Glenn
|
|
|
|
|
Hi
Does anyone have any decent links or documentation for non blocking TCP programming. I have a server that accepts incoming connections and processes requests from users but I cant get it working very well. Any help would be appreciated.
Thanx
|
|
|
|
|
|
When you accept you get a socket.
You process that socket in another thread. Either create one or use the thread pool.
|
|
|
|
|
Hello,
I've some list<string>, i would like to retrieve a sub list of a given list from 'startPos' till 'endPos'
how can i do that ?
thanks
|
|
|
|
|
If you are using List<T>[^] class then see GetRange[^] method.
If you are talking about a different kind of list then you need to elaborate a bit.
|
|
|
|
|
and after GetRange, i should Clone it ? (avoid shallow Copy)
|
|
|
|
|
igalep132 wrote: and after GetRange, i should Clone it ?
It depends on your requirements.
If you really need to avoid shallow copy, then you can make a deep copy on result returned from GetRange .
For this purpose you can use a generic method like this one:
public static T DeepCopy<T>(T obj)
{
object result = null;
using (var ms = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(ms, obj);
ms.Position = 0;
result = formatter.Deserialize(ms);
ms.Close();
}
return (T)result;
}
The code above should work for all serializable types.
modified on Thursday, May 13, 2010 10:49 AM
|
|
|
|
|
thanks
|
|
|
|
|
Dear experts,
I'm often creating a lot of small applications for learning some features of .net or for creation of small tools. I do this mainly, by creating a standard winforms-application with some buttons and e.g. some stupid text-controls hacking in the code; that's it.
But I continuously find out, that some of these small applications tend to evolve over time to some bigger projects and I get more and more problems for the update/extension/maintenance of my "hacking"-versions.
I experienced, that I always need the same standard-features during the evolution of these small app's.
Some of these features are:
--> Clear separation of View(Form) and Controller(AppLogic) and sometimes also Model (This actually is the ModelViewController-Pattern)
--> The Controller should run in it's own thread
--> Basic LoggingSupport
--> Basic support for updating the view by some event-like messaging
--> Getting some User-Feedback into the Controller (e.g. if a file is not found)
--> ..... and may be some more basic features .....
Creating these features for each application again and again consumes a lot of time.
My Question: Is there some small "Standard"-Framework available which supports my type of programming - may be via configuration?
Thanks
|
|
|
|
|
Assuming you are using a version of Visual Studio you should be able to create a new template from your project. Then when you need a new sample you can create it from your template.
It's time for a new signature.
|
|
|
|
|
Dear experts,
I want to update the configFile "app.config", but the "Save(..)" function does not work.
Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works
static void Main(string[] args)
{
Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " ");
config.Save(ConfigurationSaveMode.Full);
config.SaveAs("Test.config", ConfigurationSaveMode.Full);
}
Question: What sense does the Save()-Method make?
Can somebody help me?
Thanks in advance
|
|
|
|
|
Is it throwing any error?Can you check if the file is readonly
|
|
|
|
|
No exception is thrown by the Save()-Method, the file is also not "read-only"
|
|
|
|
|
The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config
|
|
|
|
|
Sorry, of course, app.config is not expected to be updated, but I expect that in the bin-directory one of the files ".xx.exe.config" or "xx.vshost.exe.Config" should be updated at least. But none of them is updated.
I', puzzled. What's the purpuse of the Save()-Method?
Thanks for you kind replies
|
|
|
|
|
Hi
In my application, the Main form starts a thread in another class.
In this thread I need to show another form as modeless. If i call it in the thread, the form shows but in a hanged state. no controls are visible and it is in not responding state.
How can i achieve my requirement.
Please help.
Thanks.
|
|
|
|
|
Did you use BackgroundWorkerClass???
|
|
|
|