|
|
snaits
snaits
 |
|
Stories kicked by snaits
|
|
submitted by
sangam100
4 days, 16 hours ago
dotnetspidor.blogspot.com — The use of apostrophe (') character as an input text in an sql query troubles the query operation. Say, you have a textbox in which user can input her search text and she inputs "john's" as her search text. Now your employee query will look like:
So I have explained the solution to this universal problem. This may occur anywhere in any database query: sql server , oracle of mysql. <a href="http://dotnetspidor.blogspot.com/2008/11/dealing-with-apostrophe-problem-in_28.html">So here goes the handy solution</a>
read more...
add a comment
|
category: ASP.NET | Views: 10
|
|
tags:
ASP.NET | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
tags:
C# | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
submitted by
twyford
4 days, 17 hours ago
dotnetsolutions.ltd.uk — Recently I've been spending a lot of time working on various SharePoint projects, none more challenging than the Citroën site launched earlier this year. I'm going to take the time to explain how we put together our web parts and server controls, particularly from the point of view of a WCM scenario where the complexity of our mark-up was significantly greater than that of a traditional "vanilla" intranet SharePoint due to the various accessibility guidelines we needed to adhere to as part of the project. read more...
add a comment
|
category: ASP.NET | Views: 8
|
|
tags:
ASP.NET | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
published 6 months, 28 days ago, submitted by
Pakl
7 months ago
dotnettoad.com — In this article I will show you how you can unit test your events. I will show you a simple technique that will enable you to test if your events fire exactly as often as you want them to and I will provide you with two implementations. One implementation works well with the .NET Framework 2.0 and the second one uses .NET 3.0 (anonymous methods) in order to minimize the code necessary. read more...
add a comment
|
category: C# | Views: 27
|
|
tags:
Events, UnitTesting, C#, TDD | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
submitted by
animaonline
9 months, 18 days ago
softscenario.blogspot.com — Some weeks ago I was working on a project where we receive some ten or twenty different message types from a server, and they all need to be handled when they arrive. Of course, we want to use event driven programming to make this happen on the fly, instead of polling all the time.
All of the messages have the header in common, so we already made a abstract parent class called Message, and when it came to handling all the different messages, we wanted to write as little code as possible. So we added an abstract method called HandleResponse to the code.
So the idea was to identify the incoming message type and invoke the HandleResponse using reflection on the object that we had identified this as. To do this, we made a little xml file that contains the message code (A-Z) along with the name and reference to the class linked to the message type. When the program starts, it reads the xml into a dictionary, so we can look up the key (message code) and get the class reference in return.
XDocument descriptorsXml = XDocument.Load( @".\Data\MessageDescriptors.xml");
var descQuery = from desc in descriptorsXml.Descendants("Message")
select new MessageDescriptor
{
Code = desc.Element("Code").Value,
Name = desc.Element("Name").Value,
ObjectType = desc.Element("ObjectType").Value.ToType() ,
IsServerMessage = Convert.ToBoolean( desc.Element("IsServerMessage").Value )
};
foreach (MessageDescriptor m in descQuery)
{
descriptors.Add(m.Code, m);
}
Then, we have a MessageHandlingFactory that simply gets objects in from a queue, identifies the type, and invokes the HandleResponse. If the object isn't recognized (could be a new message type, or could be that the programmer forgot to insert the description in the XML file), the MessageHandlingFactory can either throw an exception, or better yet, return a string with message that tells the user what went wrong. If everything goes as planned, it returns a string with the identified typename.
object theType = Activator.CreateInstance(t, SessionID);
EventInfo eInfo = t.GetEvent("OnWriteEvent");
Message.WriteEventHandler theHandler = new Message.WriteEventHandler(OnWriteEventHandler);
eInfo.AddEventHandler(theType, theHandler);
theType.GetType().GetMethod("HandleResponse").Invoke(theType, new object[] { message });
return "MessageHandler: " + messageType;
That's all, folks!
Update February 13, 2008: The code has now been tested in a very high throughput environment, and it performs read more...
add a comment
|
category: C# | Views: 3
|
|
tags:
software, Scenario, .Net, C#, Reflection | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
submitted by
animaonline
9 months, 18 days ago
softscenario.blogspot.com — Have you ever wondered where your user settings are saved from an .NET application? You would probably think that it's saved in the [application].exe.config(located in your application folder) file, but this is only partially true. The default values you create in Visual Studio are saved in this file. But if you change these settings at runtime:
Properties.Settings.Default.myValue = "MyNewValue";
Properties.Settings.Default.Save();
they are saved to a different location. Namely the User.config file:
C:\Documents and Settings\[USER]\Local Settings\Application Data\[company]\[applicationname]\[version]
Note that if you should change the company name or AssemblyVersion attribute in your AssemblyInfo.cs your Settings will be saved in a new location.
Since you do not override the default settings in the exe.config file, you can call the reset() method to restore the settings to its original state:
Properties.Settings.Default.Reset(); read more...
add a comment
|
category: C# | Views: 3
|
|
tags:
software, Scenario, C#, .Net | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
submitted by
animaonline
9 months, 18 days ago
softscenario.blogspot.com — Unmanaged Resources are objects that are not garbage collected, which means that they are not reclaimed by the system when the garbage collector cleans up after you.
But are Unmanaged Resources resources outside .NET framework like DLL used through interop? No, unmanaged resources can also be database connection. It is a common mistake by programmers not to close the connection when finished working with it, in misconception that the garbage collection will close it.
So how do I identify if the object is an unmanaged resource? If the object implement the IDisposable interface it have an unmanaged resource and you need to call the IDisposable.Dispose() method to clean the objects unmanaged resource.
If you use the object in a single call you can wrap it in a using statement (http://softscenario.blogspot.com/2007/10/using-using.html), and it will call the Dispose() method for you. If you keep the object for a longer time you must support the IDisposable interface in your class, and in your implementation of the Idisposable.Dispose() call the member's IDisposable method.
Remember to look for the IDisposable interface in the classes you use in your development. You will be surprised how many classes that do. read more...
add a comment
|
category: C# | Views: 0
|
|
tags:
software, Scenario, C#, .Net | tag it
Everyones tags: | Your tags: | |
|
|
|
|
|
submitted by
animaonline
9 months, 18 days ago
softscenario.blogspot.com — I see many forumposts solving this problem by simply adding the CheckForIllegalCrossThreadOperations=false;
While this is a totally legit workaround, it is highly thread-unsafe, and should only be used for debugging purposes. To be able to update for instance form-components from another thread, you will need to use delegates and invoke. Sounds scary? Not really.
A delegate is simply a "blueprint" that describes how a particular function or method should look. In C++ world, delegates are similar to Function pointers, but since we don't work with pointers in C# this is the closest we get. Still, function pointer is not a correct definition, as the delegate won't point to a function unless you make it do so. Here's an example: read more...
add a comment
|
category: C# | Views: 2
|
|
tags:
software, Scenario, C++, C#, .Net | tag it
Everyones tags: | Your tags: | |
|
|
|
|

Sponsored Link: www.carlist.ie
Ads via The Lounge
|