Make sure all classes share the same method and fields

I my data access layer I want to use DTOs and make sure that all gateways (table data gateway) will implement method which return List of some DTO specific for given gateway. To make this happen I have created empty interface like this public interfa

DRY Fix Possibilities, C #

This code has been bothering me all day, partially because the if (result != OpResult.Success) { // return code is repeated, everywhere. A series (1..n) of evaluation are performed. After each evaluation, a check is made to ensure that the operation

How to return an empty MVC 6 view component?

I have searched but I did not find any way to return an empty IViewComponentResult. The only way I managed to do it is by returning an empty View. Is there a better way? This is my code: public class ClientNavigationViewComponent : ViewComponent { pu

Sending screenshots using NetComm dll to the host

I am using NetComm dll to handle multiuser. My problem is when i send text it works fine but when i take screenshots its not working. My client code is ms = new MemoryStream(); bmpScreenshot.Save(ms, ImageFormat.Png); byte[] buffer; buffer =imageToBy

Deleting the dynamic assembly / module class

I am working on emitting a class that is based on user's input. Dynamic classes are convenient, since user is free to comeback later and change the input, and program will re-emit new class. If user comes back later and decides to make some changes,

How to convert a RectangleF to PointF [] for drawing?

I'm not sure if the question is too trivial but, I need to use the following overload of the method Graphics.DrawImage: public void DrawImage( Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr ) I h

Threading inside the loop to improve performance

foreach (int tranQuote in transactionIds) { CompassIntegration compass = new CompassIntegration(); Chatham.Business.Objects.Transaction tran = compass.GetTransaction(tranQuote); // then we want to send each trade through the PandaIntegration // class

How is Math.Pow () implemented in the .NET Framework?

I was looking for an efficient approach for calculating ab (say a = 2 and b = 50). To start things up, I decided to take a look at the implementation of Math.Pow() function. But in .NET Reflector, all I found was this: [MethodImpl(MethodImplOptions.I

WCF Web Service Without SOAPAction Header

How can I implement a web service in WCF such that it does not require the SOAPAction header to be present in the request, and would thus dispatch the call using the message body root element name? By default, BasicHttpBinding requires the SOAPAction

Declare the namespaces in the XPath expression

My application needs to evaluate XPath expression against some XML data. Expression is provided by user at runtime. So, I cannot create XmlNamespaceManager to pass to XPathEvaluate because I don't know prefixes and namespaces at compile time. Is ther

Easiest way to delete an object with Entity Framework 4

Ack! I'm new to Entity Framework and am trying to find the simplest way to delete an item. I have a listbox with the datasource set to TagCategory objects from the database. This is working fine. Now I'd like to delete the selected item. So I do some

SqlDataReader Read method

Does the read method just position itself to next record? or it actually reads the record? lets say i call read 1000 times, does it actually get all values of that each records? or its when I call GetValue?The read method advances to the next record

Sanitize XML attribute values

How can i easily sanitize the values I pass into the Value property of an XAttribute.Here's an extension method to clean away your trouble. /0 is not allowed in XML. I'm not sure if other chars are also disallowed, but I believe not. Probably best to

C # Changing the class method at runtime

This question already has an answer here: How do I replace a method implementation at runtime? 4 answers I need to extend the behavior of an instance, but I don't have access to the original source code of that instance. For example: /* I don't have

System.Speech and Voices

is it possible to create portable applications from Scansoft voices .exe files ? (www.portableapps.com). and then be able to access the voices programmatically through System.Speech namespace in .NET 3.5 ? I want to do that so I don't have to take a

One type of general delegate to handle any event

I have a function that receives two parameters - an object, and an EventInfo structure defining an event on that object. I need to block that function until the specified event fires. The problem I have is, how do I add a delegate to the specified ev

Winforms: Position of cursor position screen

How can I find the screen position of the caret for a standard Winforms TextBox?You can do it only with native interop: GetCaretPos [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool GetCaretPos(out Point lpPoin

Divide F # modules between multiple files

Is it possible to split an F# module across files? According to the book I have it is, but the book is probably outdated (Foundations of F#)Apparently not: C:\temp\Tim>type 1.fs 2.fs 1.fs #light module Module let sayHello1 = printfn "Hello, "

Learn Oracle for the first time

I am a very experienced MS Sql developer, and a few new job positions are coming my way where I will be working with Oracle on a more daily basis. As with all the technologies I have learned, I want to know the best places and books to get started an