C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform

learn more… | top users | synonyms

1
vote
2answers
142 views

How to write a custom EventHandler class

When I started using Java, I created a custom Event class to mimic C#'s implementation of Events. Since then, I've added some other features, like event listener priorities, and cascading events were ...
0
votes
1answer
241 views

Speech Recognition in the .NET framework is not efficient [closed]

I want to create a Virtual Keyboard that can catch whatever key you 'speak' and send the keystroke to the active application. The Virtual Keyboard part and linking it to Speech Recognition will be ...
11
votes
7answers
2k views

Name/Fix for Production Code Whose Sole Purpose is to Facilitate Testing? [duplicate]

The linked "duplicate" question is an iffy match at best, because it's asking is pattern X OK (YES/NO) and I'm clearly already in the NO camp, and subsequently asking what is pattern X called ...
2
votes
1answer
146 views

In what way are union types better for correctness than a common interface?

I've just recently started familiarising myself with functional programming, mostly via F#, and there's one particular functional idiom that I'm not fully understanding the benefits of. I've seen it ...
0
votes
1answer
74 views

Is there a standard to imitating an async filestream

Im trying to replace an async filestream method, which is reading data from a Hid Device and feeding it to the UI. Ive considered writing the output into a log and then importing that log again, but ...
0
votes
3answers
274 views

Force Derived Class to Implement Static Method C#

So the situation is like, I have few classes, all of which have a standard CRUD methods but static. I want to create a base class which will be inherited so that it can force to implement this CRUD ...
0
votes
1answer
71 views

Inverse property naming (ORM scenario) [closed]

I have a class that represents a process. In this process there are inputs boxes and output boxes. public class Process { public long ProcessId { get; set; } public virtual List<Box> ...
0
votes
1answer
89 views

Which transaction manager will be used in WCF?

I am going through the transactions exist in WCF service but seeking some more clarification on this. I am not sure about which transaction manager WCF will use for following scenarios: If the WCF ...
1
vote
1answer
74 views

Setting fields of a base class when using the constructor is not an option

I am refactoring a base class, implementations of which are plug-ins, loaded at runtime by another class using reflection. The class I am refactoring uses a user ID of the form domain\user. I need ...
0
votes
1answer
61 views

DAL / Model / Application-Design Question for a MVC Application

I have a device that stores raw binary log data as a BLOB in a MySQL DB. That process is a blackbox to me (closed source) which I cannot change. I know, however, how to decode that BLOB and transform ...
1
vote
0answers
48 views

Does using membership provider in the model of a MVC project mean the model knows it is part of a website?

My basic design is that the model is in a separate project from my website, and the project never references the website. That tends to enforce the model being agnostic of how it is being used. But ...
2
votes
3answers
67 views

Pre-processor usage to separate logic to different versions of product

In the .NET code base of a product, there are #if pre-processor statements to define whether certain functionality should be available. Like so: shared logic #if version1 some logic #endif #if ...
0
votes
1answer
73 views

What possible things to log in mvc webapp [closed]

I'm about to learn to handle logging in my c# asp.net mvc app and are going to store my log in a noSQL-db. How to handle the logging is done. The thing is I'm having a hard time to figure out possible ...
2
votes
1answer
278 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
1
vote
2answers
198 views

Mocking the context of application

We have a context of the application which is a static class named Holder containing several static properties initialized by objects that are used throughout the application. All over the unit tests ...
1
vote
0answers
145 views

C# structure needed for dynamic behaviour

I am using Unity to build a visualisation of a serious game. I am using the C# programming language. My problem is that I receive data from a JSON and I parse it and I end up with a list of different ...
12
votes
2answers
917 views

How to calculate figure rotation efficiently?

I have a Figure represented through a matrix of bytes (bitmap-like matrix). Example Figure is shown on the Picture 1. The goal is to find the best rotation angle of some given Figure. When Figure ...
0
votes
0answers
42 views

Decreasing MongoDB Load

I have some stream workers. They are listening to twitter stream and save into mongodb. I need to aggregate saved tweets for intermediate analyze result. I have analyzer workers. They are periodically ...
1
vote
1answer
87 views

Controller / Service - Should a service save changes to the database

I have an action on my controller called DeleteLine. This removes a line from the users basket. My controller action looks like this: [HttpGet] public ActionResult DeleteLine(int orderId, int ...
1
vote
1answer
186 views

How to find duplicate strings

I allow my user to create profiles, meaning they potentially could create some with duplicate names. This can be problematic so I want to prevent them from doing so. I coded up this first pass ...
0
votes
0answers
50 views

Creating a user-customizable web api

Technologies: Javascript for $http call, ASP.NET Web API, MSSQL for data retrieval Web API will return array of widget objects with following properties: WidgetId, WidgetAttribute1 Bool, ...
0
votes
1answer
191 views

Good design pattern for linq to sql

I currently have a linq to sql project that was used for one project and not much work was put into it, only the generated context and entities were used. Since then the project has started to become ...
3
votes
1answer
161 views

Web Forms and MVC in the same web project

I'm working in a large legacy project which was build with ASP.NET Web Forms and the idea to add in the MVC libraries to the same project has been tossed around. I know that this is possible (there ...
1
vote
4answers
244 views

Order by different Enum property each row

So I have a list of DefaultSearchModal items that have an enum called TypeSearch in every list item. I would like to order the list to have a different enum property each row. So if you have an ...
0
votes
1answer
85 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
6
votes
2answers
622 views

Does laziness yield more race conditions?

I recently ran into a race condition while accessing a configuration setting. After examining what I could of the code, I came to the conclusion that the Configuration class' laziness1 was the source ...
1
vote
1answer
67 views

Why does a custom action filter need to inherit from both ActionFilterAttribute and IActionFilter?

I m first time creating a custom action filter and following this link http://www.asp.net/mvc/overview/older-versions/hands-on-labs/aspnet-mvc-4-custom-action-filters They are saying to Extend ...
0
votes
2answers
123 views

how to carry a specific number of significant figures while computing? [closed]

How to carry more or less than six significant figures (4 , 5 , 7.. ) in the computation while running a program ? i'm writing a program to solve a system of linear equations /using Gauss elimination ...
2
votes
1answer
232 views

My first SOLID re-factoring

I am trying to make use of SOLID principles for the first time. I am re-factoring a File class that stores file information and makes file operations available. This class is then inherited to ...
1
vote
1answer
134 views

Should one write a custom IndexOutOfRange exception?

In the process of writing a special collection I utilized the already exisiting IndexOutOfRangeException as e.g. a list or array would throw if I were to access an illegal index. Code analysis tells ...
3
votes
2answers
263 views

How do you apply Single Responsibility principle to a repository

I am trying to apply "SOLID" whenever I can and try to use common sense and avoid a pattern when I see that a pattern is creating more problems than it's trying to solve. I don't want to apply a ...
-2
votes
2answers
175 views

Real World example implementation to explain Task Parallel Library [closed]

I need to provide a knowledge session on Task Parallel Library.i have not used it in any of the practical scenario.I decided to learn it by preparing for the session(may seem weird). I searched for ...
2
votes
2answers
169 views

Separation of retrieving data and business objects between DAL and BLL Layers

I did some research before posting this question. Among other questions or post, one of those is provided below. I could not get a clear mind how to determine.. Business Objects within a Data Access ...
2
votes
3answers
209 views

Is this extension method any better than just casting to an int?

The following extension method was set up in some code I maintain. public static Int32 GetInt32(this System.Data.Common.DbDataReader reader, string name) { return ...
10
votes
5answers
667 views

What is the best way to initialize a child's reference to its parent?

I'm developing an object model that has lots of different parent/child classes. Each child object has a reference to its parent object. I can think of (and have tried) several ways to initialize the ...
0
votes
0answers
29 views

What is the best way to initialize a child's reference to its parent? [duplicate]

I'm developing an object model that has lots of different parent/child classes. Each child object has a reference to its parent object. I can think of (and have tried) several ways to initialize the ...
0
votes
1answer
124 views

IOC Between Presentation and Infrastructure Layer

Question: I would like to set forth dependency mapping from a *.config file from a project that has no reference to the project that contains the concrete class. Scenario: I'll be using terms from ...
1
vote
0answers
143 views

Better to keep JScript.NET dll or try converting JScript.NET code to C#? [closed]

Let me explain the back-story to my question: I have made a .NET program that logs into an account on a website and scrapes various pages of information. In order to login to the website, I must ...
3
votes
3answers
223 views

Interface to enumerate over files

I'm trying to design a generic interface for enumerating over a list files. Each iteration will open a file, allow the consuming code to access the file to perform some task, and then close the file. ...
5
votes
2answers
271 views

Should the sender of an event always be a generic Object?

When programming events in C#, it is advised to create a delegate in form of: delegate XEventHandler(object sender, XEventArgs e); My question is on the first argument of the delegate, object ...
0
votes
1answer
75 views

setting class members automatically like Photon Servers Operation class does

I'm wanting to mimic something that I saw in Photon Server with my application. Entity Framework does something similar. Photon Server has an Operation class. You pass it a dictionary of ...
2
votes
2answers
376 views

What is an alternative to bitwise flags?

I was trying to be smart and elegant, and I ended up shooting myself in the foot by coding my entire application to use flags to store various combinations of settings. Now, I have hit a point where ...
11
votes
4answers
2k views

Is it permissible to use explicit interface implementation to hide members in C#?

I understand how to work with interfaces and explicit interface implementation in C#, but I was wondering if it's considered bad form to hide away certain members that would not be used frequently. ...
0
votes
0answers
89 views

Nhibernate operations on a separate thread for a desktop MVVM application

I am developing a single user .net desktop application that lists numerous (over 2000) contacts sorted by an algorithm. I use NHibernate and did consider a session per use case (or conversation as it ...
3
votes
1answer
232 views

why Web API 2 has RouteConfig.cs file?

I m working on Web API project, and it is using WebApiConfig.cs file to defined routs for Web API. Web API fold RouteConfig.cs file. I have googled and they say RouteConfig.cs is for MVC routing. It ...
0
votes
2answers
276 views

Do GC generations have any purpose (for an application programmer) other than answer to “tricky” HRs' questions?

I'm using C# for a several years, never actually willing (until I really need to) to dig into its "deep" mechanics and to intervene in GC work, IL-compiled code and so on. My point is if you ever ...
17
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
3
votes
1answer
210 views

How to store a potentially large amount of optional properties of objects?

I'm using Entity Framework Code First with ASP.NET MVC. This handles my database design based on the domain models within my application. As it stands, the engine I'm writing will have a website ...
-1
votes
2answers
139 views

Moving old desktop application to a robust platform [closed]

Several years ago I wrote a desktop application, a small accounting system, in Delphi 7, that is in user in a medium-sized company. The code belongs to me. I ported another Accounting system that I ...
1
vote
2answers
220 views

Decide the type of an object during runtime

I try to implement a PriorityQueue with C#: public class PriorityQueue<T> : Heap<T> where T : IComparable<T> { ... } The Heap is abstract. I have MinHeap and MaxHeap that are ...