|
DaveyM69 wrote: refactor it before anyone reviews the code
Right, that's basically what I'm doing -- revisiting my code before I publish it. I find this to be a good exercise.
|
|
|
|
|
Luc Pattyn wrote: goes against all normal coding guidelines; I'm not inclined to show the ugly beasts I sometimes create!
Chicken sh!^.
|
|
|
|
|
Luc Pattyn wrote: 4. Coding for performance, when taken to the extreme, goes against all normal coding guidelines
I would actually be interested to see what conditions are "acceptable" for breaking normal rules and different methods for acheiving said perfomance. Is that a bad thing?
DybsThe shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
There is nothing wrong as long as you are fully aware of the consequences. The first thing you probably loose is good readability and hence easy debugging and maintainability.
When in search of maximum performance, quite often object orientation is bad when the objects are very small and very many (too much overhead). Method calls are bad (they don't compute anything), conditionals are bad (they disturb normal program flow). Combine that and you may end up with large pieces of straight, hardly structured, code; and then there is a whole collection of hacks to choose from.
Whether all this is acceptable is matter of discussion.
|
|
|
|
|
Luc Pattyn wrote: CPU simulators
Yeah, this is kinda that -- a script language interpreter.
|
|
|
|
|
I need to make client-server project with separated access. It should be 3 groups of users with different access level. Access level defines the appearance of form witch user would see. Can somebody advise how to realize this separated access.
|
|
|
|
|
I would do it like this: (As long as I presume, that client doesn't access Database directly)
1. step: Client logs in with authentic username and password
2. step: Server sends to client current access level and the server holds its data per session. (Doesn't clean memory, till logout or Time out)
3. step: Client gets access level and then prepares GUI.
When client sends command, witch exceeds user privileges wont get them info. This design prevents users modifying client, to get higher access. This works as long you do not connect directly to database only to service that sits on Server side between client and database.
and bad design: If you want to directly connect to database (Witch I do not recommend) use for each privileges, use own build client for each access level.
C++ have compiler directive: (I do not know if exists in C#)
#define, #ifdef, #ifndef and #endif.
|
|
|
|
|
Hi,
1. I configured the Outlook to work with Windows Live Hotmail(my hotmail account)
2. Now i want to read all the inbox from my hotmail account using C#.
3. The outlook create for hotmail a file with .ost extension(not with .pst)
4. My procedure is like this:
TextWriter tw = new StreamWriter(@"C:\pstfile_html.txt");
// Create the Outlook application.
// in-line initialization
Outlook.Application oApp = new Outlook.Application();
// Get the MAPI namespace.
Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
// Log on by using the default profile or existing session (no dialog box).
oNS.Logon(Missing.Value,Missing.Value,false,true);
//Get the Inbox folder.
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
//Get the Items collection in the Inbox folder.
Outlook.Items oItems = oInbox.Items;
Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();
for (int i = 0; i < oItems.Count; i++)
{
//Output some common properties.
tw.WriteLine(oMsg.Subject);
tw.WriteLine(oMsg.SenderName);
tw.WriteLine(oMsg.ReceivedTime);
tw.WriteLine(oMsg.Body);
tw.WriteLine(oMsg.HTMLBody);
tw.WriteLine("Next Message-----------------------");
oMsg = (Outlook.MailItem)oItems.GetNext();
//System.Diagnostics.Debug.WriteLine(objMail.Body.ToString());
}
//Log off.
oNS.Logoff();
//Explicitly release objects.
oMsg = null;
oItems = null;
oInbox = null;
oNS = null;
oApp = null;
tw.Close();
}
//Error handler.
catch (Exception e)
{
Console.WriteLine("{0} Exception caught: ", e);
}
// Return value.
return 0;
}
6. I don't know how to take hotmail folder.
Thanks,
Anca
|
|
|
|
|
Hello,
I can't get the challenge and player respond working, it currently responds no player time, score only name, But the names are to little strange.
public string Challenge(string servIP, int servPORT)
{
byte[] buffer = new byte[100 * 1024];
byte[] PlayerQuery = { 0xff, 0xff, 0xff, 0xff, 0x55, 0x65 };
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipEP = new IPEndPoint(IPAddress.Parse(servIP), servPORT);
EndPoint EP = (EndPoint)ipEP;
socket.ReceiveTimeout = 1000;
socket.SendTo(PlayerQuery, PlayerQuery.Length, SocketFlags.None, EP);
int recvBytes = socket.ReceiveFrom(buffer, ref EP);
return ParseChallenge(buffer);
}
private string ParseChallenge(byte[] resp)
{
_CHALLANGE = System.Text.Encoding.ASCII.GetString(resp, 5, 4);
return _CHALLANGE;
}
private SourceQuery ParsePlayers(byte[] resp)
{
SourceQuery ret = new SourceQuery();
int i = 0;
ret.PPlayers = Encoding.ASCII.GetString(resp);
return ret;
}
public SourceQuery Players(string servIP, int servPORT)
{
byte[] buffer = new byte[4096];
string challenge = Challenge(servIP, servPORT);
byte[] PlayerQuery = { 0xff, 0xff, 0xff, 0xff, 0x55 };
string pQuery = Encoding.ASCII.GetString(PlayerQuery);
byte[] Query = Encoding.ASCII.GetBytes(pQuery + challenge);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint ipEP = new IPEndPoint(IPAddress.Parse(servIP), servPORT);
EndPoint EP = (EndPoint)ipEP;
socket.ReceiveTimeout = 1500;
socket.SendTo(PlayerQuery, PlayerQuery.Length, SocketFlags.None, EP);
int recvBytes = socket.ReceiveFrom(buffer, ref EP);
return ParsePlayers(buffer);
}
|
|
|
|
|
Hi,
i've got a Graphics Object and have drawn a rectangle (graphics.DrawRectangle) on it. Now I want to rotate it using the mouse. and the rotation matrix. But I don't see the rotation while moving the mouse, I just see it after realeasing the button...
Can anybody help me?
|
|
|
|
|
Without seeing any code it is difficult to tell you much - but are you calling Invalidate in the MouseMove Event? You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
It would be quite difficult to tell without seeing your code.
Still, are you changing the coordinates in the correct MouseMove event?
|
|
|
|
|
As you haven't shown any code, all I can do is say the principles are explained everywhere, including here[^].
|
|
|
|
|
I'm tryin to make a modified microprocessor programming language compiler in .NET but in my code generator part I face one big problem. It's the fact that microsoft intermediate language only supports stack based execuition which will indeed make me to think for other way. I want register based execuition since i'm planning for 8086 architecture. can anybody help me figure out how to handle this problem.
|
|
|
|
|
|
Whatever application you develop in C#, .NET using an intermediate language (IL), and IL being stack oriented, is irrelevant. A compiler written in C# isn't any different from a compiler in any other language (unless you want to compile some language to IL of course).
|
|
|
|
|
thanks!
as you can see in the code MSIL has opcode which are execuited by other functions which are not shown here. after these opcodes are execuited they are retured by the 4th line of the code and after that the code will create an assembly based on the compiler result for the code written by the user.this assembly is then saved and finally run so that the user can see his code runing.
now what i want to ask is that this MSIL execuite its codes on stack based approach. but my interest is to create a compiler for 8086 microprocessor architecture which in my opinion needs register based execuition so that I can access the individual register values.
public CodeGene(AST.Stmt stmt, string moduleName)
{
this.il = methb.GetILGenerator();
this.symbolTable = new Collections.Dictionary<string, Emit.LocalBuilder>();
this.GenStmt(stmt);
il.Emit(Emit.OpCodes.Ret);
typeBuilder.CreateType();
modb.CreateGlobalFunctions();
asmb.SetEntryPoint(methb);
asmb.Save(moduleName);
System.AppDomain.CurrentDomain.ExecuteAssembly(moduleName);
this.symbolTable = null;
this.il = null;
}
so please help me to figure out conceptually how i can get register based execuition of MSIL. or is there any other way of achieving register based compilation in C#?
thank you in advance!
|
|
|
|
|
Djtech01 wrote: in my code generator part I face one big problem. It's the fact that microsoft intermediate language only supports stack based execuition
Wait a minute. Your statement makes no sense at all. The .NET execution model has nothing to do with your compiler since it's your compiler code that's writing the resulting target for execution. Are you saying that you're using one of the .NET compilers to compile your code?
|
|
|
|
|
hello sir/madam,
I want to convert my foxpro application to c#/ms sql2005 server application.
It is a student management system.
If u have any tool or any simple method to convert it please email me.
My email id- bharat_v_patil@yahoo.com
Thanks in advance,
-bharat patil
|
|
|
|
|
There is no tool. You have to rewrite the code from scratch.
|
|
|
|
|
They are quite different. You would really not do a line to line conversion. Hence no tool would help. You will need to spend time and do it yourself.
|
|
|
|
|
Hi,
How can I get the 'pointer' of the stream writer the webbrowser control uses to navigate to websites?
Thanks in advance!
|
|
|
|
|
I *think* the DocumentStream[^] property is what you're looking for. Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
I thought that's the one i needed too. But where would i put the url to navigate to another url with it?
|
|
|
|
|
Yustme wrote: But where would i put the url to navigate to another url with it?
I'm not sure if I understand this, but to navigate to another URL, you call the Navigate method of the webbrowser control, passing in the URL to navigate to, like so:
webBrowser1.Navigate("http://codeproject.com"); Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|