|
Either way (using an base class with a public virtual function or a code snippet) you can have a comments.
Chris
|
|
|
|
|
Thanks again. code snippet is OK but in that case I need to tell user to call snippet but I'm not sure that by implementing virtual function I would be able to generate automated code or code template if possbile can you please send me a quick example.
Regards;
Uttam Kumar
|
|
|
|
|
I think instead of Interface you better go for Abstract class. This will serve your wish.
Anindya Chatterjee
|
|
|
|
|
If all you want is to run some code before allowing the derived class's method to run, you can use the Template Method pattern. It looks like
abstract class BaseFoo
{
public bool DoSomething()
{
BaseFooDoSomething();
DoSomethingInternal();
}
protected abstract void DoSomethingInternal();
}
Clients can only override DoSomethingInternal and you'll always get to run BaseFooDoSomething before executing the derived class code.
Does this help?
|
|
|
|
|
Sorry but that's not my question. What is want is a method when you implement a method some how a wizard would give you a templete code. I also don't want to use snippet as it would be additional step for the consumer.
Regards;
Uttam Kumar
|
|
|
|
|
Uttam Kumar Unik! wrote: What is want is a method when you implement a method some how a wizard would give you a templete code.
So you don't care if the developer deletes the autogenerated code?
|
|
|
|
|
That's correct. Let me explain what I want to do. I'm writing a pluin to do some sort of auditing. Now who ever consume the plugin would be setting different types of value as per need. Now I want to give them an automated sample code so that without going through the document he would know how to setup the configuration etc. Just wanted to make my plugin smart enough so that I would go even 80% - 90% client coding it's own. Ofcourse one way is code Snippet but the problem with code snippet is user can easily forget to call the snippet and it's an addition step for the user as well. So I want to physically do some coding for the user through the plugin.
Regards;
Uttam Kumar
|
|
|
|
|
|
The C# forums are not a place advertising, no matter how good you think it is.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
|
Please report his original post.
|
|
|
|
|
I have some custom controls which contains a System.Windows.Forms.Label control. I would like to be able to swap out those label controls with a third party label control. What I would like to do is the following...
#if UsingThirdPartyControls
namespace WindowsApplication4 {
public class MyCustomLabel : ThirdPartyLabel {
}
}
#else
namespace WindowsApplication4 {
public class MyCustomLabel : Label {
}
}
#endif
Now I can use MyCustomLabel in my custom controls and based on the type of build (one build will have UsingThirdPartyControls defined and another will not).
The problem is removing the reference to the third party controls. Is there a way I can programatically tell the C# compiler to remove the references to the third party assemblies. That way when I deploy my custom control the third party assemblies are not deployed because they are not required?
Chris
|
|
|
|
|
I never tried, but as of my understanding,
The Solution file ( *.csProj ) contains the sections to add reference
under ItemGroup tag these references are listed. This tag supports condition attribute.
So you can write a custom task, which executes under target BeforeCoreGet and sets the condtion attribute of reference ItemGroup accordingly.
Try to search for CustomTask for MSBuild, you found many pre built tasks contributed by communities.
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
Wow thanks alot. I found this web site which shows that you can have a condition where if the build is set to a certain type then you can include or exclude references. Then in the build I can define something like UsingThirdPartyControls and in my code I can place #if UsingThirdPartyControls #endif.
I think this could work. Thanks alot.
Chris
|
|
|
|
|
I have an object graph that abstracts the operation of a machine. It will calculate paths, so there are several large lists of points. Currently I am using Zedgraph to plot these lists.
Originally I was using Zedgraph's PointPairList for these points. Everything worked OK. But it didn't seem proper to be so closely coupled to Zedgraph.
As an interim solution I have created PointPairLists that are identical to Zedgraph (but in my own namespace). I am having trouble casting these to Zedgraph PointPairLists. (I was hoping to avoid having to iterate through these rather large lists.)
Here is my question: Is there an elegant solution? Any helpful references or search terms would be helpful. (I did find an MSDN reference to writing custom casting operators.)
I feel like I am missing something obvious.
Thank you-
Squeak
|
|
|
|
|
So let me get this straight - you're using ZedGraph to graph some data, and you don't think that an internal ZedGraph structure should be so closely coupled to ZedGraph?
My advice is to stop over-analyzing it. If you don't, you'll never finish the application.
"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
|
|
|
|
|
Zedgraph has a definition as follows:
Ourcompany.PointPairLists points = value;
<pre>
When you "code the exact same thing" you change the namespace so you have an object that is actually:
<pre lang="cs">
Mycompany.PointPairLists;
Unless you explicitely inherit Ourcompany.PointPairLists you will never be able to cast to the object type that they are requesting.
The product probably has a domain uniqueness that using their collections is the only choice. You may also find, if the company is sharp, that they have coded the objects so that they are not inheritable which stops you from encapsulating them as well.
|
|
|
|
|
Hi,
Sorry if this is too basic, Can you please let me know how to typecast string to char* in C#? I need this as Im calling a managed DLL function.
Thanks
Vikas
|
|
|
|
|
Do you mean char[] ?
string s = "abc";
char[] c = s.ToCharArray();
|
|
|
|
|
|
"Managed" ???
Do you want to use pointer in managed environment ???
|
|
|
|
|
Actually from C# I'm calling an unmanaged MFC DLL.
MFC DLL has an API for example:
<br />
int fnSetMonitorNo(char* m_MonitorNo)<br />
int fnGetMonitorNo(char* m_MonitorNo)<br />
If I pass char* to the DLL, it will see the MonitorNo. I tried to do in C# as follows
[DllImport("OfficeCTE.dll")]<br />
public static extern unsafe int fnSetMonitorNo([MarshalAs(UnmanagedType.LPStr)]string arg1);<br />
<br />
[DllImport("OfficeCTE.dll")]<br />
public static extern unsafe int fnGetMonitorNo([MarshalAs(UnmanagedType.LPStr)]string arg1); <br />
But it didn't work.
How can this be done?
|
|
|
|
|
Vikas K. wrote: Im calling a managed DLL function
I don't think that you will be using pointers much in managed environment.
Vikas K. wrote: string to char*
If you want to call some native C++ functions you can use Marshal.StringToHGlobalAnsi[^] method.
*jaans
|
|
|
|
|
hi
i want to detect sql server instances on the system, i was use System.Data.Sql.SqlDataSources
it was work correctly, but does not detect local or default instances, i want to detect it by wmi(like sql server 2005 configuraion manager), but how to do ?
thanks
|
|
|
|
|
Hi all,
I have one resource file and i want to update and delete the content from the resource file programetically, but when i update the resource file thru one form then it will insert the new record rather than update. Below is my code.
ResXResourceWriter w = new ResXResourceWriter("ResXForm.resx");<br />
w.AddResource("test", "test123");<br />
w.Generate();<br />
w.Close();
And when i insert the record programetically, at that time it will insert the record, but it will overright the previous record. how it is possible ?
Rana Krishnraj
|
|
|
|