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

0
votes
1answer
23 views

Sdk building, declare dependencies inside the assembly or use external?

At my company, we're building an SDK consisting of a number of assemblies. For example, we deliver an assembly called Company.Platform.Security that contains the implementation of our authorization ...
0
votes
1answer
52 views

How can I avoid duplicating information in this scenario?

I have a Data class that can be placed inside a DataCollection class that can be placed inside a DataCollectionCollection class. Kinda like an egg can placed inside a box that can be placed inside a ...
0
votes
2answers
72 views

Is it a good idea having default static variables for new instances?

OK let's say I have something like this: public class MyObject { public static int DefaultValue = 9 private int _value = DefaultValue; public int Value { get { return _value; } set { ...
0
votes
0answers
39 views

Good examples for use of design patterns in Unity [on hold]

My students have learned OOP as well as the strategy design pattern during the first semester (Processing/Java), which lead to understanding Unity's component based architecture (similarity of ...
1
vote
2answers
58 views

Ambient dependency injection through static service locator

After some googling I found some debates about whether constructor injection or property/field injection is better, but there is yet another alternative that strikes me as more beneficial. In most ...
4
votes
2answers
123 views

Service-locator anti-pattern alternative

I'm using Unity as IoC with C#, but I guess the question really isn't really limited to Unity and C#, but IoC in general. I try to follow the SOLID-principle, which means that I got very few ...
1
vote
1answer
43 views

Validating transaction codes with reference codes… Best way to encode the validation rules?

Good Day, I have a series of reference codes that my end users create during the course of the day. These reference codes correspond to a transaction code that is stored in a database. As of now, ...
1
vote
0answers
35 views

MVVM approach to mahapps.metro Dialogs

I want to use a ShowMessageAsync method, but, at first sight, there is no obvious way to do ViewModel binding, even though there are already a certain number of answers and examples about this. Now, ...
-2
votes
0answers
63 views

Maintaining a Unique id within List in two different iterations

I am struggling to create an algorithm which fulfills my requirements. I have a class which shows my FinalDestinationName and Time for the train to arrive to reach platform let's say like this ...
1
vote
1answer
79 views

What is the correct reusable architecture using Entity Framework for common database tables and services?

Context I have a line of business application "MyApp" in C# using EF. Layers are separated as MyResusableLib.DataAccess // Class Lib: EF based utils, extension methods, MyApp.DataAccess // Class ...
1
vote
0answers
50 views

Using delegate to handle cross cutting concerns

I am planning to write a net-core library for using with n-tier architecture. In this architecture, i want to handle cross cutting concerns(audit, error handling, logging, validation, transaction ...
1
vote
1answer
214 views

Does anybody still use TODO for writing code later on? [closed]

Statement I often find myself still writing the following statement all over my code: // TODO: (the work that needs done) I do this in order to flag that I need to come back and do something later ...
5
votes
1answer
231 views

How to avoid a crazy amount of interfaces in UI with dependency injection?

Problem I recently read a lot about Singletons being bad and how dependency injection (which I understand as "using interfaces") is better. When I implemented part of this with callbacks/interfaces/DI ...
2
votes
1answer
47 views

Writing Automated test cases for a folder Archiving Class.

Using C# and Visual Studio, I've developed a class that zips and archives a folder into desired location, creating directories and manipulating files on a machine. The intended use is as an part of ...
0
votes
1answer
164 views

How to structure Restful API client files in C# project?

I've developed a Restful API in PHP, now the API makes different resources available like: Article, User, Service, Trace etc.... I'm going to implement each resource in a portable DLL, so I can use ...
3
votes
1answer
199 views

How to pass data to OOP objects?

I'm new to this whole thing, so please tell me if I'm doing this wrong of if there's a better spot for my question. I'm making a game with basic systems for projectiles, npcs and items. This game ...
2
votes
3answers
167 views

Giving a class many constructors and assigning via them as many properties as possible

I have written a class which represents a SQLite Trigger. public SQLiteTrigger(string Name, string On, TriggerStartType StartType, ...
-2
votes
0answers
25 views

Basic OPC UA client example in C# [closed]

I've been busy getting OPC UA working, but the examples provided are one big plate of spaghetti with rubbish. Business code mixed up with gui related code. There is no descent piece of top-down ...
2
votes
2answers
118 views

Best way to enforce constraints in Class

I have a class, something like this one (C#): public class MyFavoriteClass { public string Name { get; set; } public string Description { get; set; } (...) public ReferencedClass1 ...
1
vote
3answers
113 views

Should I use nameof to avoid repetition in constants?

In C#, I sometimes use: const string FirstName = "FirstName"; const string SSN = "SSN"; ... var ssn = GetValue(key: SSN); // e.g. GetValue fetches value from some key/value store to avoid ...
3
votes
2answers
147 views

Write unit tests for the libraries, or just the application?

Background I am fairly new to unit testing, and have been recently using the Visual Studio Test Manager to create my Unit Tests. The way that I have currently been doing things is as follows: ...
-1
votes
2answers
94 views

Do you say “this” on protected members? [closed]

Background I have never had a formal class in OOP/OOD although I understand how the protected members work. Being accessible by any instance/derived class, they are thereby less private (more ...
1
vote
1answer
79 views

why exposing service instead of repository in onion architecture

I'm digging on how to structure projects and so I stumble into Onion Architecture. As to how I understand it, its more on a domain-centered-focus architecture instead of a database-driven type. I'm ...
2
votes
2answers
81 views

How to handle when only certain derived classes need to be disposed?

I am trying to build a framework of objects where the main actors can be interchanged freely. At the moment I've done this by creating an abstract base class that all of my actors can be derived from. ...
0
votes
1answer
69 views

Recommended approach to initialize Command

I've two commands in my View Model and one of them is initialized using lazy loading and other using eager loading. Which approach is good to go? Should I use lazy loading or eager for both? View ...
2
votes
2answers
110 views

Method to validate an object - should I have one method encapsulating all validation logic

I have a class, Customer which has some basic properties on it such as firstname, surname, email, dateofbirth. I have written another class called CustomerValidation which currently has one public ...
2
votes
1answer
90 views

Should I use BackgroundWorker in Pipeline pattern?

I am planning the implementation of a Pipeline pattern as seen in this MSDN article. This is a WPF application for which I need to monitor progress of each stage of the pipeline in order to display it ...
8
votes
3answers
292 views

How to share a code base among 10+ projects and minimize pain?

I have a number of applications that share the same data in the same database. To try and minimize redundancy of code the Data Access Layer is a shared project. This prevents each project from needing ...
3
votes
2answers
156 views

Most efficient strategy for search large text areas for multiple values

I have a requirement for a service that does the following. Take a block of text and identify the server names in it (by name or ip address). So given: Lorem ipsum dolor sit amet, consectetur ...
1
vote
3answers
299 views

Do I have to fork a server program as an “C” child process in order for correct interprocess communication to take place?

I would like to implement interprocess communication between an Ubuntu Linux 15.10 mono 4.1.2 C# recorder client and Ubuntu Linux 15.10 mono 4.1.2 C# video server using a C++ mutex class and C++ ...
1
vote
1answer
130 views

What's the benefit of generics in an in interface e.g. IEnumerable<HttpPostedFileBase>

I've come across a method that requires a parameter that implements IEnumerable and is of a certain type like this: public myMethod (IEnumerable<HttpPostedFileBase> myParameter) { ...
0
votes
1answer
97 views

Calculating variable distances

I'm attempting to write an algorithm that calculates the distance between vertebrae. The text parser already works perfectly in picking out vertebral references (cervical 6, c-6, c6, c six, cervical ...
0
votes
1answer
68 views

Passing a Serial Port Instance

Background I am thinking about designing a (GoF/behavioral) command-pattern interface. I may decide to call this thing ICommand. I am thinking that I would have some sort of a queue containing a ...
0
votes
0answers
23 views

How to find existing UserControl and Window at Runtime

We have a LOB Application where I want my users to be able to create themselves a Menu (Left-handed main menu like a webpage). The "poweruser" creates menu, add some security and then the final users ...
6
votes
1answer
146 views

Relaxed architecture DAL or anemic BLL?

Particularly for the sake of unit testing, I'm trying to implement an application with a layered architecture. I'm coding in C# and using ASP.NET Web API for the service layer. I'm aiming at a 3-layer ...
3
votes
2answers
193 views

How do I deal with unneeded inherited members?

Consider the following UML diagram: In a nutshell: ChildClass1 and ChildClass2 use all of the members of ParentClass. ChildClass3only uses Member1 and Member2 and the value of Member5 is a ...
2
votes
0answers
99 views

REST API Versioning in C# WebApi

I haven't really found a decent/future-proof way to version methods in my WebAPI. This is what I typically do now, but it can get confusing and hard to trace if it gets a bit large (I'll end up ...
2
votes
1answer
78 views

Possible DRY with Pausing Mechanism

Background I am currently working on the architecture for a future software design. The design is one long running task (hours-long) with thousands of sequential calls to various libraries. I ...
2
votes
0answers
47 views

Dictionary-Sorting in bigger projects

My concern is how to handle ResourceDictionarys in a WPF (MVVM)-Project. I usually only create small Projects, so it doesn't matter that much, but since I created a Project-Template to handle some of ...
1
vote
3answers
116 views

Use case for async/await?

Background Most of the applications that I write are hour long sequential tests for electronic equipment. The equipment under test has a specification that is a state-machine that looks like... Get ...
3
votes
2answers
116 views

Proper design for models

I have a class called ReplaceRule this is used by 2 classes DocumentRuleViewModel and SectionRuleViewModel as a List<ReplaceRule> in both Question 1: In my database implementation I have 2 ...
4
votes
3answers
385 views

What problems might arise if I didn't make a method static when I could?

I have a stateless method that takes an input, and based on that input returns an output. This method has no state so in theory it could be made static. But let's say I don't do this. What problems ...
2
votes
1answer
50 views

Merging dynamically created data with an HTML template

I have a C# application where I'd like to present information that is accumulated in memory from an embedded system in the form of an HTML page in a near real-time manner. As a proof of concept I've ...
-1
votes
1answer
119 views

Code structure of third party framework [closed]

Is an API always returning 200 OK, an issue?
2
votes
3answers
244 views

Why does C# not allow scope-local using Directive?

One thing I do not get with C#'s using Directive is why I can only "use" a namespace at file level, and not within any arbitrary block scope. (using namespace x; of C++ does allow this and certainly ...
0
votes
0answers
73 views

What to use in case of waiting for something that is complete: delegates, events and/or thread

I try to give a concrete example. Create a semaphore for a crossroads. I have two semaphores. I have possibility to set a duration of semaphore 2 minutes, 5 minutes, 10m inutes etc. When one ...
2
votes
5answers
232 views

Constructor overloading or allow null?

Which is the preferred design to use, one constructor that allows null, or two constructors where one throws an ArgumentNullException on null? Two constructors with exception throwing public class ...
0
votes
3answers
128 views

Using nested private class to hold data from csv file

I have a class that only has one method. This method has to read csv file, do some work concerning internal logic (check if item already exists, do some transformations, etc.) and finally write all ...
0
votes
0answers
23 views

Syncing file data and form data uploaded at separate times

I have a web application where users can upload office documents. In addition to uploading files users also specify extra information about them that's not contained in the files themselves but is ...
0
votes
1answer
42 views

Sequence of Integration Test in Build Process

We are developing a Web API (ASP.net, C#) project and use Bamboo CI for our continuous Integration. We run the Unit test before the deployment task so that deployment does not happen if test fails. We ...