.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

learn more… | top users | synonyms

7
votes
2answers
115 views

Can I stop validating email addresses now please?

Writing code to validate emails is a thing I don't like. It's usually pretty pointless as there's there is actually no right solution, so it leaves me with a certain sense of existential dread. I've ...
2
votes
1answer
58 views

Inheritence Cleanup

I have the following interface ...
1
vote
0answers
39 views

An Extended WebBrowser Control

I needed the ability to do a few extra things with a WebBrowser control on a .NET Windows Forms Form, and I found it needed some updates. So, I made a few. I added ...
0
votes
1answer
67 views

Data model decomposition into key value pairs using reflection and attributes

I'm trying to change how our system generates PDF files. Currently I have a class for each PDF that goes through the model for the PDF and fills in the properties. I want to change that to a self ...
1
vote
1answer
51 views

XSD Schema for optical media

I recently wrote my first XSD Schema: ...
34
votes
3answers
3k views

Benchmarking things in C#

I needed a better way to benchmark code, because, well, rewriting the same benchmarking code every time I need it is just...well...unpleasant. So, here's a class which does just that, it runs an ...
8
votes
1answer
101 views

Accessing the Stack Exchange API

Part of a project I'm getting started on requires access to the Stack Exchange API for certain data, as a result I built a .NET implementation to interact with it. The implementation is pretty ...
4
votes
4answers
209 views

Converting the DateTime to and from Unix epoch times

I'm currently working on a thing I needed this feature for. Essentially, these are two methods to convert DateTime objects to and from the Unix epoch time (two ...
5
votes
2answers
87 views

Indexed Property implementation

I have a class that encapsulates a PowerShell Runspace object which, among many other things, has methods for getting and setting variables in the session state. ...
1
vote
1answer
45 views

Copy a stream to a file using Universal .NET

I have answered to a question on Stackoverflow where Andy struggled to cancel a Stream copy to file operation using the Universal .NET Framework: Apparently, cancelling the cts CancelOperation token ...
1
vote
0answers
28 views

Current .NET session username injection in SQL Server stored procedures

I have a legacy WCF service that is ported from a security model using database logins and roles to a custom security. One effect of this change is that stored procedure are no longer executed using ...
0
votes
2answers
78 views
1
vote
1answer
24 views

Scoping resources per HTTP request

I am using this code in an MVC application to manage objects that should only have one instance per request. ...
5
votes
1answer
96 views

MVVM: Am I doing it right?

I read a lot of articles recently concerning XAML, WPF, data binding and MVVM. I also watched some MVVM tutorials and downloaded some MVVM samples. I finally got my first MVVM sample to work, but ...
3
votes
3answers
114 views

Performing parallel processing on a file

I have some code that reads a file and then does some parallel processing of the data. There are millions of lines in the file and this section of the code is the bottleneck in my program. Any ...
1
vote
1answer
57 views

Disposing of an SQL dataset

I am getting a compiler warning when running my code analysis. It is CA2202. It is saying that I have not properly disposed my dataset through all exception paths. Here is the code: ...
2
votes
0answers
40 views

Add transactional Units of Work to incorrect NHibernate usage (microsessions, single object actions)

This code is part of a quite huge repository using NHibernate in a wrong way: no units of work, but microsessions for every object loading and saving (ignorant of Persistence Ignorance, coded like ...
1
vote
0answers
46 views

UI code-behind for managing employees

I have a form code behind and it has what are called "Common Utilities". Basically the original author made a super class that is embedded into the main form code behind. What is the best way to ...
0
votes
1answer
49 views

Using EF 6.1 for updating objects and their children

I have an application that allows a user to create a poll that includes questions and answer choices as part of the poll. The hierarchy is a poll has one or more questions, a question has one or more ...
2
votes
1answer
47 views

Processor that would process an Object (say a message you received)

Sorry for being a little abstract but I have attempted to concoct something simple but it seems to spiral out of control. So I was thinking maybe I am taking the wrong approach. Here's what I am ...
2
votes
1answer
35 views

Property validation

I require that the Feature set of my Licence to have a non-empty intersection with a set of features that the module I am loading contains. I expect other lists in my License to form similar ...
-1
votes
2answers
91 views

Can this be written in a shorter way? Dynamic function call perhaps?

Below you'll find my switch case. My question is, for each function I am manually adding another case. Can this be somehow shortened? You see case names and function names are same. For example case ...
5
votes
1answer
38 views

Parallel extension enchancement

As suggested in comments here I created a new topic for next version. I edited a bit original code, added exception processing and optimization, that first N = 1/core count tasks are processed on main ...
1
vote
1answer
49 views

Multithreading extensions

I created a following class to manage multithreading without extra overhead, which exist when I use Parallel TPL class. It is also useful for systems without ...
-3
votes
1answer
45 views

Generating property for a class instance [closed]

Hope, it's my last question about current project. Yeah, it's still about respecting SOLID-principles. And it's still about calculator, so i've got realization of ITerm interface: ...
4
votes
1answer
73 views

Calculating a postfix expression

I've got the following code in my calculator project: ...
4
votes
3answers
311 views

'Retry' mechanism with callback

We've had a situation whereby we have to cater for certain exceptions and retry a particular method whenever these exceptions occur. This is required in various parts of the system. In addition, we ...
0
votes
1answer
97 views

Method or helper function to return objects from EntityFramework with Linq [closed]

The following code reads from Microsoft EntityFramework 6.0 domain model and returns the single view_patient object. The view_patient object is defined in the backend database and uploaded to the ...
3
votes
1answer
127 views

Recurring tasks in ASP.NET MVC

I have 2 alternatives for executing recurring tasks in ASP.NET MVC. We just need to add some code in Global.asax First alternative: ...
3
votes
2answers
47 views

Going to the thread pool and back using custom awaiters

I've figured out a way to switch threads in the middle of a method. The benefit of that seems super obvious to me: that's what everyone wants to do anyway, and splitting up methods, using callbacks, ...
2
votes
1answer
74 views

Recursive function application

I use a lot T4 templates and want to avoid extra code writing when it could be generated. Currently I have following class: ...
2
votes
3answers
121 views

Reflection optimization

In a web application I'm working on I have a class that Map objects to other (different) objects. It is implemented with something like: ...
1
vote
0answers
13 views

How to properly assess performance gain of CreateDelegate instead of pure reflection? [duplicate]

In a web application I'm working on I have a class that Map objects to other (different) objects. It is implemented with something like: ...
3
votes
2answers
94 views

Calculating template page numbers

I have a function which sets the text to a label displaying current active "products" and current active pages. The label displays "X products, Y pages/page" depending on the amount of products active ...
1
vote
3answers
177 views

A service to monitor CPU usage

I have written a windows service that I am currently not that happy with as I am facing design issues (first windows service). The aim of this service is to monitor CPU usage and send an alert when ...
5
votes
1answer
454 views

Navigation between pages in WPF MVVM application

EDIT: Here is the code repo: https://github.com/AntwanReno/navi I did a project in WPF MVVM. Just a single Window with single ...
3
votes
1answer
109 views

Inheritable ConfigurationElement values in .NET

I wanted to have a custom section in my app.config file in which any element could reference and reuse (or better said could inherit) any string value that is defined in it or above it in the element ...
2
votes
1answer
93 views

Custom data validation approach for store items and prices

I came up with a validation design for my project and wanted to hear if there's anything I could improve. Here's how it works. I have the models (code first) ...
3
votes
2answers
115 views

Save multiple group permissions in one go

The method SaveGroupStepPermissions(...) is a database API class. If an error occurs within the method the exception is trapped. Whether this is good design or not ...
4
votes
1answer
132 views

Parsing a string to extract values

I am writing some C# that will be running on Linux and will extract values from a kernel generated system file that represents readings from a sensor. The file contains two lines of text, and I have ...
5
votes
1answer
183 views

Minimalist countdown timer with C#

I'm looking to add a module to one of my utility classes that functions as a countdown timer for tools that execute tasks after a certain amount of time. The code below is what I have working for PoC, ...
11
votes
2answers
96 views

Markdown Markup Editor: MK2

Following on from this question I have added some more functionality to Markdown Markup, and made it more WPF idiomatic. It now supports saving data from any of the four boxes, and loading Markdown ...
5
votes
1answer
79 views

Markdown Markup Markleft Markright Editor

I have a blog that I occasionally post to, but it's a PITA because of the fact that it has it's own WYSIWYG editor and doesn't support Markdown. So I have to switch the WYSIWYG editor to the HTML ...
1
vote
0answers
137 views

Are there pitfalls to this solution to read messages from a queue in parallel?

I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed. Situation We have one message queue. We would like ...
3
votes
2answers
167 views

Handling events in a multi threaded environment

I have a service that raises multiple events, some of them can be raised at the same time. I need to process those events and run a potentially long running method based on the event arguments. What I ...
8
votes
2answers
353 views

Monitoring the clipboard

The following class monitors the clipboard and raises an event whenever the contents change. The monitoring starts when the class is created and ends when Dispose ...
4
votes
1answer
84 views

Task Scheduler for small interval and one number of start

Scenario: I want a task scheduler that enables my application to schedule some tasks in small time interval. I want to use it in my socket server application. For example, when the user connects to ...
3
votes
3answers
207 views

Unit of Work Pattern for creating users

CreateUser function assumes the data being delivered via parameters are clean and gets called or initiated from the Business Manager (another class). This function is responsible to do the following ...
3
votes
3answers
138 views

Enumerate list with filter criteria

Given the following CreditCard object, how would you get a count of unexpired credit cards? What are the pros/cons of using each method? Or is there a ...
2
votes
2answers
144 views

Producer/consumer implementation using Tasks and BlockingCollections

I'm implementing a Producer/Consumer but the generic interface doesn't require any knowledge of blocking collections or tasks. ...