|
Sorry, I explain more details as below:
This is my context
I have two solutions A & B which have many projects.
In each project, I have class C (or method, or variable) that can be used in other project of same solution (example: A solution) or another solution (B).
Each time I want to find class C (all places that is used), I must find in both solutions A & B.
It can take more time and not easy to track information between two solutions.
So I want to build a tool to analyze both solutions & give all references of class C in A & B.
So, in order to find all references of class C, I just searching on a tool.
|
|
|
|
|
That is a big job. The proper way to do this is by creating a full C# parser, and let it loose on the source files of all the projects in the solution(s). Are you sure you can't just use your IDE's class browsing facilities?
You could cheat quite a bit, like so:
- just scan all source files for curly brackets { and } to locate classes; if you assume namespaces are used, a class would be at nesting level 2 of {};
- within each class, search for the type name you're interested in;
- within each class that mentions the type name of interest, look for the type's member you're interested in.
This will yield some false positives, as it:
- does not discern code from comment;
- does not recognize string literals;
- does not associate the member name with the type you're looking for (i.e. while looking for:
TextBox.Text, it will also find
TextBox tb;
string s=myButton.Text;
However it will also not work well with nested types, e.g. a class nested inside another class. When the inner class holds what you are looking for, it would flag the outer class as positive (hence even more false positives).
|
|
|
|
|
Hi
Just seeking some help with a linked list in C# and if it can do what I require it to do. Below is a simple version of what I want to do.
public LinkedList<Object> createList()<br />
{<br />
LinkedList<Object> l = null;<br />
MyObject oj = new MyObject;<br />
l.addLast(oj);<br />
<br />
return l;<br />
}<br />
<br />
public convertObject()<br />
{<br />
LinkedList<MyObject> list = (MyObject)executeSQL(sql, array);<br />
}
The reason for this is because i want the createList to remain generic as the actual code will be used to collect data from a database, place the data in objects and then add it to the linkedlist. At all times the link list will only contain 1 object type but i want to be able to re-use the method regardless of what object type it is. Originally I had this working using ArrayList but I would prefer to use LinkedList due to the added features.
I hope the above explained what I wanted without having to type the actual code which is a couple of pages long.
Any help would be appreciated, if you need more info then let me know.
Cheers
|
|
|
|
|
You can work around the List(T) Class (System.Collections.Generic)[^]: it gives you all the functionalities of a linked-list and it's a generic type. What you need is to write down a class, that internally uses a List<object> member, and that expose the methods that you need to do your job.
|
|
|
|
|
I have managed to get the following to work but I would like to keep it as a linkedList rather then converting it to an array.
public Access[] findAll()<br />
{<br />
string sql = "SELECT * FROM access";<br />
<br />
LinkedList<Object> list = executeSQL(sql);
<br />
Access[] aArray = new Access[list.Count];<br />
list.CopyTo(aArray, 0);<br />
<br />
return aArray;<br />
}
|
|
|
|
|
Apologies about my first reply, I misunderstood your question. How about:
public LinkedList<T> ExecuteSQL<T>(sql)
{
}
public LinkedList<T> findAll<T>()
{
string sql = "SELECT * FROM access";
return ExecuteSQL<T>(sql);
return aArray;
}
Then you can specify the type, or you can change T to Object .
[Edit]: added the l to "public", Freud would have a field-day with me
|
|
|
|
|
Thank You so much. That works, all i needed to do was add the <t> in front of the method name
|
|
|
|
|
|
I now have a new problem. My code is as follows
private LinkedList<T> makeList<T>( SqlDataReader reader )<br />
{<br />
LinkedList<T> list = new LinkedList<T>();<br />
<br />
while( reader.Read() )<br />
{<br />
list.AddLast(makeObject(reader));<br />
}<br />
<br />
return list;<br />
}<br />
<br />
public abstract object makeObject( SqlDataReader r );
this line list.AddLast(makeObject(reader)); is showwing the error "cannot convert from object to t"
What have I done wrong? and how can I fix it?
Nevermind, Problem solved by
list.AddLast((T)makeObject(reader))<code><br />
<div class="signature"><br />
<div class="modified">modified on Monday, October 18, 2010 6:22 AM</div></div>
|
|
|
|
|
The following is safer, unless you know you are only getting Type T objects, (or T is not a class)
T value = makeObject(reader) as T
if(value != null)
{
list.AddLast(value)
}
You'll Also need to :
private LinkedList<T> makeList<T>( SqlDataReader reader )
where T: class
{
}
|
|
|
|
|
I don't know if this could help, but I wonder if a makeObject<t> method would do what you want, I mean:
public abstract T makeObject<T>(SqlDataReader r);
bye
|
|
|
|
|
There is a generic linked list[^] in .net 3.5 and above, this will do exactly as you ask, or you could just use the generic List<T> type, but this doesn't expose the AddBefore/AddAfter etc members that the LinkedList<T> does.
[Edit]
See previous thread, this isn't what the OP was asking for.
|
|
|
|
|
Yes but how do I keep it generic untill the last minute?
I have tried
public Access[] findAll()<br />
{<br />
string sql = "SELECT * FROM access";<br />
<br />
LinkedList<T> list = executeSQL(sql);
<br />
Access[] aArray = new Access[list.Count];<br />
list.CopyTo(aArray, 0);<br />
<br />
return aArray;<br />
}<br />
<br />
public LinkedList<T> executeSQL( string sql, string [] array )<br />
{<br />
LinkedList<T> list = null;<br />
<br />
try{<br />
<br />
...<br />
<br />
return list;<br />
}
but that does not work
|
|
|
|
|
Hello Friends,
I have made a Web Service and am using its reference in a Window Service that is being executed/called every 1 min. Through the Web Service, I am connecting to a remote MySQL Server database in which some of the table are accessed and data is being inserted/updated into them.
As the current window service is still in development phase, so whenever i install the batch file of the window service every other day, just in order to check that whether the whole process is running fine or not, The web-service throws an error:-"Unable to connect to server". This error comes only when the web-service is unable to connect to the remote server .
But the moment i rebuild the web-service at my my machine and then update (replace) it on the web-server and again add it as a reference to the window service then after rebuilding the window service when i run the batch installation file of window service; the whole process executes absolutely fine and the web-server database tables gets updated.
I am not able to sort out why an unusual behavior is being shown by web service. Please help me out.
Thanks
Varun Sareen
|
|
|
|
|
I believe your webservice reference includes the IP (is pointing directly) to the remote server.
This is probably what is creating the problem.
Remove this reference by changing your code to point to a dynamic IP and things should be fine.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Thanks dear Abhinav for providing such clarity but are you talking about:-
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053");
the italicized text or the Server address in the connection string.?
<add key ="ConnectionString" value="Server="ip address"; Uid="userId"; Pwd="password"; Host="hostname"; Port=3306; Database="dbName"; Compress=false; Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0;"/>
Thanks
Varun Sareen
|
|
|
|
|
Er no I was not talking about the connection string.
Have a look at the configuration file that includes the IP address you need to point to.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
|
Hi,I am able to draw rectangles on the picture but I am not able to capture the co-ordinates of the picture box instead it capture the screen coordinates.So the rectangle that I draw on the picture box doesn't appear on the position that I desire.
private void MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();
p1 = this.pictureBox1.PointToScreen (p1);
p2 = this.pictureBox1.PointToScreen (p2);
if (p1.X < p2.X)
{
rc.X = p1.X;
rc.Width = p2.X - p1.X;
}
else
{
rc.X = p2.X;
rc.Width = p1.X - p2.X;
}
if (p1.Y < p2.Y)
{
rc.Y = p1.Y;
rc.Height = p2.Y - p1.Y;
}
else
{
rc.Y = p2.Y;
rc.Height = p1.Y - p2.Y;
}
textBox1.Text = Convert.ToString(rc.X);
textBox2.Text = Convert.ToString(rc.Y);
textBox3.Text = Convert.ToString(rc.Width);
textBox4.Text = Convert.ToString(rc.Height);
ControlPaint.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Thick);
}
private void button1_Click(object sender, EventArgs e)
{
motionDetector = new MotionDetector(simpleBackgroundModeling, blobCounting);
int x = Convert.ToInt32 (textBox1.Text);
int y = Convert.ToInt32(textBox2.Text);
int width = Convert.ToInt32(textBox3.Text);
int height = Convert.ToInt32(textBox4.Text);
bflag = true;
rectangle[1] = new Rectangle(x, y, width, height);<pre lang="cs">
|
|
|
|
|
I am not getting your question properly
but I suppose you have to use MouseDown, MouseUp even to capture X, Y Point
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|
|
I think you are looking for the
PointToClient method. It's implemented on Control so just use:
pictureBox1.PointToClient()
E.g. If you want to convert the current mouse position to Control coordinates use.
Point ptControl = control.PointToClient(MousePosition);
|
|
|
|
|
I'm using the following code to back up a SQL Database :
void BackupDatabase(string sConnect, string dbName, string backUpPath)
{
using (SqlConnection cnn = new SqlConnection(sConnect))
{
cnn.Open();
dbName = cnn.Database.ToString();
ServerConnection sc = new ServerConnection(cnn);
Server sv = new Server(sc);
BackupDeviceItem bdi = new BackupDeviceItem(backUpPath, DeviceType.File);
Microsoft.SqlServer.Management.Smo.Backup bk = new Backup();
bk.PercentComplete += new PercentCompleteEventHandler(percentComplete);
bk.Devices.Add(bdi);
bk.Action = BackupActionType.Database;
bk.PercentCompleteNotification = 1;
bk.BackupSetDescription = dbName;
bk.BackupSetName = dbName;
bk.Database = dbName;
bk.LogTruncation = BackupTruncateLogType.Truncate;
bk.FormatMedia = false;
bk.Initialize = true;
bk.Checksum = true;
bk.ContinueAfterError = true;
bk.Incremental = false;
bk.SqlBackup(sv);
}
}
In my system (Win7 x64) it works fine but in destination system (WinXP SP3 x86) I receive the below error :
Exception[^]
How can I fix it ?
Thanks.
BTW:
I installed SQL Express 2008 R2 in destination system.
|
|
|
|
|
Is the version of .NET on the XP system the same as that on your Win7 system? If not, you may want to try to build against a lower version if possible.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Is the version of .NET on the XP system the same as that on your Win7 system?
The version that I've created the code based on was 9 but the version of destination system is 10, I created the project with 10 version but I receive below Exception :
Restore failed for Server '\\\\.\\pipe\\3F103E6E-3FD4-47\\tsql\\query'.
|
|
|
|
|
A simple Google action yields this[^].
|
|
|
|