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
0answers
49 views

Is there any way to take advantage of portable ViewModels for ASP.Net?

Microsoft supports portability when taking advantage of the MVVM pattern: https://msdn.microsoft.com/en-us/library/hh563947(v=vs.110).aspx This means that I can create a ViewModel that is reusable in ...
2
votes
1answer
139 views

In a polled interface, is it okay for an object representing hardware to start a task responsible for the polling?

I am a hardware/test engineer currently writing a C# application for a device that does not have any event/interrupt mechanisms. Because of this I am forced to poll the device's internal control ...
0
votes
1answer
77 views

Conditionally creating objects at runtime using Spring.NET

I have a couple classes in a project I'm working on that only register event handlers. public class EventLogger { public EventLogger(EventRaiser someObject) { someObject.EventRaised ...
0
votes
0answers
45 views

Migrating off a Silverlight application to SPA - technologies

We have pretty big Silverlight LOB application. It works great, took many years to write and it's big... Back when we made a choice (2011) JS/HTML5 was in unknown state. Today we have all kind of ...
10
votes
2answers
607 views

Why does C# allow you to make an override async?

In C#, when you override a method, it is permitted to make the override async when the original method was not. This seems like poor form. The example that brought me to this was this — I was ...
4
votes
3answers
98 views

Visibility of abstract factory's implementation's product

I'm implementing a factory like this: public interface IMyProduct { void DoSomething(); } public interface IMyFactory { IMyProduct CreateMyProduct( string aParameter ); } internal MyFactory ...
2
votes
3answers
155 views

Writing new code in async but calling sync

I am writing some new code and would like to write it using async and await, but the calling code does not currently support async. Is it right to write the new code in async and call it sync until ...
-4
votes
2answers
144 views

Automatically creating .pdf files from CSV [closed]

Ok, so I already have a small console program written (full code can be seen here) for this task. Basically, what it does, is the user grabs a CSV that is full of filenames, then chooses where to save ...
0
votes
0answers
134 views

Winform User Control on ASP?

I wrote a C# Winform User Control as follows when Executable is Run: My question is how we can use this Winform C# user control in one ASP Page. I know about WEB User Control and using in ASP but ...
3
votes
1answer
96 views

Unit testing a large project with few publicly accessible components [duplicate]

I'm asking about C#, but this probably applies to most other languages as well. Imagine I have a project with a lot of complex logic, split up into a lot of small components. Let's say that, among ...
1
vote
2answers
228 views

Would adding enums to my class make my code more compact or efficient?

I am working on a C# class library for my colleagues to use when programming industrial cameras. I'm trying to determine both the most compact and elegant method to write the class. The commands are ...
0
votes
2answers
250 views

Trust .net compiler after Microsoft updates

Microsoft releases upgrades and changes to .net, msbuild and Visual Studio quite frequently. How can I be sure the MSIL code created by msbuild or the Roslyn compiler in VS 2015 will be the same or ...
2
votes
1answer
288 views

Strategy Pattern not sufficient for my problem?

Let me sketch the situation: I have multiple users, with certain properties (2 enums) For each user I need to fetch data, for some with some basic filtering, for some extended filtering (= basic ...
1
vote
2answers
210 views

Migrating large silverlight business application to MVC

I have the task to migrate a large silverlight business application in a new living technology. I had choosed asp.net MVC and web api. As we know, silverlight uses MVVM design pattern whereas asp.net ...
3
votes
2answers
287 views

Only use a dependency injection container at the root of an application?

normally, I'll use a dependency injection container (unity) in c# like this example: class SomeClass { private readonly ILogger _logger; public SomeClass() { _logger = ...
0
votes
0answers
39 views

Graphing Objects without invoking Domain Logic

I'm unsure of how to go about implementing a certain aspect of my objects. Given a model class that represents an object, with business functionality based on various events, how can we graph the ...
1
vote
1answer
68 views

How to determine what type of derived-class object to lazy-load from an associated object

I'm modelling a system that is a combination of two distinct yet similar data repositories**: one containing patent data and one containing trademark data. There is a very large overlap in the ...
1
vote
1answer
171 views

How do I write this method to adhere to the Single Responsibility Principle?

I'm writing code that imports values from a CSV file. As part of the import process, I need to write warnings to a log (displayed on screen) when values in the CSV file are invalid. The method below ...
4
votes
4answers
609 views

Generate a random color for every user and keep track of created colors. Every color MUST be different

In my app every user that connects to the server needs to get a random distinct color and I have to keep track of them. About 20 to 30 will be connected in the same time. When a user disconnects, his ...
0
votes
1answer
47 views

Integrating Logging Library into multilayer Object: What is a good structure?

I am integrating Serilog into and existing multilayer library that I've create. The previous logging technique I used was simply passing a string up the layers with events. I'd like to get away from ...
0
votes
2answers
200 views

General term for T[], T*, and T& [closed]

An array of T, a pointer to T, and a reference to T (represented as T[], T*, and T& respectively by Type.ToString) all share the similarity that they are constructed from an "element" type (which ...
3
votes
3answers
179 views

Would dependency injecting into entites be considered against SRP?

I asking a question on Stackoverflow earlier and someone pointed me to a previous post of his, He states that injecting a dependency into an entity violates the Single Responsibility Principle. To ...
0
votes
0answers
73 views

Rearchitecture: EF Core as DAL, how should my BLL look like?

A little background: Our system consists of a DB in SQL Server, a DAL layer using EF 6 (Database First, with a monstrous .edmx), a Web API 2 and MVC 5. The DB is very, very old and wasn't designed ...
1
vote
1answer
99 views

Let Xamarin clients listen when server send an API

My situation I will make a Xamarin application for Android that can access an ASP.NET MVC webserver with API's. The problem is when I'll send an API to the server, all the connected clients must ...
1
vote
2answers
151 views

Suggestions to distributed service pattern

We expose some webservices on a server, written in C#. Now we have to distribute the services to multiple servers, so the solution is distributed. And each request is dispatched to one the servers to ...
2
votes
2answers
325 views

SQL query or C# .net code for csv files import?

My aim here is to find out the best possible and feasible solution for my dilemma. I want to import some csv file (may contain around 50~60K records) into database after some manipulation into the ...
3
votes
1answer
96 views

Distributing work between TCP Clients

I have an application (run by a Windows Service) which connects to a TCP server (let's call the service 'Listener' from here on). [It's important to note that the TCP server is out of my reach, and ...
41
votes
8answers
4k views

Should I throw an exception in case of a meaningful value outside of the range or handle it myself?

I have written a struct that represents latitude/longitude coordinates. Their values range from -180 to 180 for longtitudes and 90 to -90 for lattitudes. If a user of that struct gives me a value ...
2
votes
1answer
161 views

Creating multiple instances of an implementing class

I currently have an abstract class and multiple classes extending it. My problem is, that there has to be a way to create a variable number of instances of an extending class. The number of instances ...
0
votes
0answers
29 views

Implementing a view updating system in C# with an XML-based model

I'm looking for feedback, whether my approach is sensible. Also not sure about what this paradigm is called, or technology that is most appropriate here. The question relates to figuring out a way ...
1
vote
1answer
167 views

What is the DRY-est factory pattern to instantiate subtypes based on one of their properties' values?

Take the following class hierarchy: Client FacebookClient PinterestClient TwitterClient Each client must define a value for an enum property named ClientType (string property Url in the ...
0
votes
1answer
119 views

Why does ObservableCollection require all changes to be made on the UI thread?

And is there any danger to making my own INotifyCollectionChanged implementation that doesn't? I'm trying to make a class library contains a Log class, which in turns contains some sort of observable ...
3
votes
1answer
225 views

Why covariance is forbidden for abstract class in C#

I've been digging in covariance and contravariance in C# and there is one thing I could not manage to understand. C# (AFAIK, as of 4 version) allows one to declare the covariant or contravariant ...
1
vote
0answers
103 views

Change object state in different point in program

This is not about whether or not getters/setters are wrong. I understand its impact to encapsulation and that question has been raised here and SO several times already. I also do not want to just ...
4
votes
2answers
133 views

Stateless service classes and method decomposition

I like implementing service classes as stateless. However, I also like to decompose my logic into more, simple methods or functions. In some scenarios it seems like the two are somewhat against each ...
3
votes
1answer
140 views

Project structure: Where to put object factories

I am working on a C# programming project in Visual Studio. I have created various VS library projects inside the VS solution containing the various components of the solution. Without giving it too ...
2
votes
1answer
206 views

Is it possible to write a regex that does one search then uses its results to do another search?

I'm searching for strings matching the pattern [A-Z]\W*[0-9]+, so that in V-2345 35A235 Q252 the V-2345 and Q252 would match. In another list, I want to find equivalent items that fit the same ...
0
votes
0answers
79 views

Implementing a one way web request/response in .NET

What is the better way to implement a request/response in .NET when dealing with just getting an xml web resource for the external source and process it to your system? By the way, to access this xml ...
2
votes
3answers
172 views

When and why would you extract an abstract method from an abstract class to an interface?

I have been asked the following question in an interview: "What is the need of an interface when you can have an abstract method within an abstract class?" Which I did not know the answer to. Could ...
-2
votes
1answer
85 views

Proffesional Systems Design [closed]

Please advise me and correct my understanding if I am in error. In my opinion, any programmer wanting to develop an accounting system should consider two approaches from the two mentioned below: ...
2
votes
1answer
246 views

Open / Closed Principle

I found this code example explaining Open / Closed principle. Code before application of principle: public class Logger { public void Log(string message, LogType logType) { switch ...
2
votes
1answer
155 views

Pattern to use (if any) to co-ordinate loosely coupled classes with strong interdependencies

I have a collection of cooperative classes whose behaviors are interdependent upon one another. But I wish to keep them loosely coupled, so I've created appropriate interfaces. I want to determine an ...
-1
votes
3answers
168 views

.Net Project architecture and DB connection

I'm looking at a new project to be developed in .Net, and I'd like to do it the right way. I'd like to create a solution with 3 parts : a front- and a backoffice, both using a the third part as ...
0
votes
1answer
238 views

Efficient way in comparing two lists

I have created two lists of objects: One is records from an xml and the other is records from the database. The rule is check if the record from an xml exist in the database then exclude. I have ...
3
votes
2answers
161 views

Is using getters in XAML view-models a bad thing?

I've recently had an argument with a colleague about using getters (without setters) in a view-model classes used by XAML. Example: public string FullName { get { return $"{FirstName} ...
1
vote
0answers
62 views

Using events and event subscribers to create windows in a desktop application

I should probably open this by saying I do mostly Web applications at work, which obviously have some major differences from typical desktop stuff. I had a small Windows Forms program I'd made for ...
0
votes
1answer
129 views

What's the most straightforward way to integrate my company's custom authentication with ASP.NET SSO?

My company has a series of WinForms applications that pretty crudely provides authentication by checking usernames and passwords directly against the database (with a little hashing). I have a fair ...
12
votes
4answers
376 views

What are the drawbacks to mapping integral identifiers to enums?

I've been thinking about creating custom types for identifiers like this: public enum CustomerId : int { /* intentionally empty */ } public enum OrderId : int { } public enum ProductId : int { } My ...
0
votes
0answers
75 views

How do you integrate separate projects into a single solution?

Background I'm a technical lead on a small team of three developers who work at a community college. Because of the nature of our environment, our projects are typically related (since the core set ...
0
votes
0answers
73 views

Parsing text with repeating blocks

I am parsing the responses from our Varnish load balancers in order to monitor the status of various nodes. One of the responses we get is text consisting of multiple blocks of data, one for each ...