|
Some IDE's have something similar integrated; Code Analysis[^] from the IDE, seems to return the same information. Isn't available in my IDE at home - different version probably.
Bastard Programmer from Hell
|
|
|
|
|
No.I got some tools likes Fxcop runner and Fxcop integrator.Its doing a nice job.
|
|
|
|
|
Cool, FxCop Runner[^] provides an integration that's comparable to the built-in code-analysis. Going to try it tonight
Bastard Programmer from Hell
|
|
|
|
|
Hello,
There namespace Company.Service01, which contains classes and interfaces.
There namespace Company.Service02, which contains classes and interfaces.
Both spaces have the same structure of, contain the same classes and interfaces.
I need to somehow ensure that I could work with class (for example: Eso9PortClient) from this namespace,
depending on the input parameters of the program.
It's possible there is some technique to it?
The goal is that I did not have to repeat the same code n times the number of namespaces.
Example:
file01.cs
namespace Company.Service0X
{
public interface Eso9Port {...}
public partial class FaultInfo {...}
public interface Eso9PortChannel {...}
public partial class Eso9PortClient {...}
}
file02.cs
namespace Company
{
class Program
{
static void Main (string [] args)
{
if (args [0] == "01")
{
MultiService MultiService m = new ();
m.CreateOrder ();
}
else if (args [0] == "02")
{
MultiService MultiService m = new ();
m.CreateOrder ();
}
else if (args [0] == "03")
{
MultiService MultiService m = new ();
m.CreateOrder ();
}
}
}
public class MultiService
{
public void CreateOrder ()
{
// Work with the instance Company.Service0X.Eso9PortClient
// depending on the parameter in class Program
Company.Service0X.Eso9PortClient Company.Service0X.Eso9PortClient x = new ();
string xx = x.orders
...
}
}
}
Thank you in advance for your reply
|
|
|
|
|
Use an Abstract Factory pattern
|
|
|
|
|
Firstly, take out common code and put that in base classes in a base interface, and make sure that each implementation implements a common namespace. The main driver code shouldn't have to store references to any of the specific company namespaces. Then the problem simply comes down to creating an instance of the main object within one of the namespaces.
Depending on how flexible you want your system to be, and whether you permit runtime plugins, you either want a hard-coded factory:
class MultiServiceFactory {
IMultiService Create(string name){
if(name == "01") return new Company.Service01.MultiService();
else if(name == "02") return new Company.Service02.MultiService();
else throw new ArgumentException("Can't make a service for "+name);
}
}
... or you need to use reflection to look up the requested name ("Company.Service"+name+".ClassName") in either the current assemblies or loaded runtime plugin assemblies. I won't go into the entirety of plugin architecture in a Q&A reply, there are plenty of articles on CP about it.
|
|
|
|
|
Hello Experts,
I have assign work for creating add in for PowerPoint. In which i want toolbar in Powerpoint slide. So can any one pls help me for this issue.
I have no deep knowledge for Powerpoint Addins.
Thanks
If you can think then I Can.
|
|
|
|
|
|
I have a table, Models, in a database. It contains the following fields: ID (auto-generated; unique ID), Model Name (Text), Division (Text). I have a class, AuditRecord, which stores information about each record in another table, Audit Entry. It contains a field which looks values up from the Models table. How should I store a Models record in the AuditRecord class?
I am currently using:
<br />
Dictionary<int, Tuple<string, string>><br />
However, I am not sure this is the most efficient way to go about storing the data. Should I create a class with three properties corresponding to the three fields in the Models table? Or is my current method okay?
|
|
|
|
|
Matt U. wrote: Should I create a class with three properties corresponding to the three fields
in the Models table?
Yes.
|
|
|
|
|
Is the reason about maintainability/readability/encapsulation? Or is there more to it?
|
|
|
|
|
All of that and more.
Plus, not doing so is just lazy; there's no reason not to.
|
|
|
|
|
I figured as much. I'm not entirely sure as to why I didn't create a class to begin with. Thank you for the answer.
One more question: this means I should create classes for similar database objects as well, correct?
|
|
|
|
|
Probably. It depends on what you do with it. Most of the time a DataTable suffices for what I need to do.
|
|
|
|
|
Those and, particularly, extensibility. If you add another field to the table, it's easy to add another one to the class, but it would break all the existing code if it couldn't fit in a Tuple<string,string> any more.
|
|
|
|
|
I need to have one of my properties in a custom control to open the "open file dialogue" window when selected.
I have googled around but it keeps throwing me .net controls!
At present I have a property and when "set" opens the dialogue, but this forces me to enter some text and open it only when deselected...
Just to clarify:
1: Click on the property name in visual studio designer property area
2: it opens the open file dialogue
Thanks
|
|
|
|
|
What you're looking for is a custom PropertyEditor. Read up on it here[^].
|
|
|
|
|
Thanks
|
|
|
|
|
There is a built-in FileNameEditor which you can use as well.
<br />
[EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]<br />
public string FileName<br />
{<br />
get<br />
{<br />
return _FileName;<br />
}<br />
set<br />
{<br />
_FileName = value;<br />
}<br />
}<br />
|
|
|
|
|
Hey guys,
I have a Form1 with a text box in it. When user clicks inside the text box it will pop up Form2 which has a MonthCalendar in it.
Now after the user selects a date and click OK on Form2, i want that selected date string to be displayed in the Form1 text box.
How can i get the Form2 date string to be displayed in Form1 text box?
Thanks in advance.
|
|
|
|
|
The way I do it :
On Form1 I listen for the Form2.FormClosed event like this
Form2 myForm2;
private void textBox1_TextChanged(object sender, EventArgs e)
{
myForm2 = new Form2();
myForm2.FormClosed += new FormClosedEventHandler(myForm2_FormClosed);
myForm2.Show();
}
Then when the event happens :
void myForm2_FormClosed(object sender, FormClosedEventArgs e)
{
this.TextBox1.Text = myForm2.TheDate;
}
On Form2 you need to have a Public property TheDate which you set when they click on your calendar
OnOkClick you just close the form.
hope that makes sense.
|
|
|
|
|
|
Hello Experts,
an application creates an instance of Form1 on startup. During Form1_Load(), an instance of Form2 is created and shown:
private void Form1_Load(object sender, EventArgs e)
{
Form2 form2 = new Form2();
DialogResult dialogResult = form2.ShowDialog(this);
if (dialogResult == DialogResult.Cancel)
{
this.Close();
return;
}
} While user sits in front of his notebook and thinks about pressing "OK" or "Cancel" (both are buttons on form2), there is no icon for Form1 in the taskbar. Neither is there for Form2.
I suppose that Form1's icon is not there because Form1 initialization is not complete at the time form2 is displayed. And Form2 doesn't show an icon since it's modal and leaves taskbar icons to parent. Right?
I'd like to have one icon in the taskbar. Two would be acceptable. How could I achive this?
Ciao,
luker
|
|
|
|
|
All you should need to do is set the ShowInTaskbar property to true in the second form.
|
|
|
|
|
Now this one is weird:
I tried changing ShowInTaskbar without any hope it could help because I had already tried that yesterday in the evening. But I had tried to set it from the calling class. This time I set it in Form2's constructor after InitializeComponent . No luck.
Then I suspected it could relate to Form2 being set to FormBorderStyle = None (Forgot to mention that in the original post, sorry). I tried Sizeable and FixedToolWindow and both lead to the desired result: Icon was present in the taskbar.
But Form2 needs to look exactly like FormBorderStyle = None . So I changed that back and (you're sensing that already, aren't you?) it still works.
What am I supposed to learn herefrom? "If something doesn't work, change a property that could be related to the problem but rather shouldn't get changed. Change it back and hope that it does work now"?
Ciao,
luker
|
|
|
|