C# is a multiparadigm, managed, garbage-collected object-oriented programming language created by Microsoft in parallel with the .NET platform
-3
votes
0answers
74 views
Could someone explain these advanced programming constructs, in plain simple terms [on hold]
I like to think I can pick most things up, but I am struggling to even understand what I need to research to understand what I don't understand. Understand?
Method signature
internal static V ...
0
votes
1answer
31 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
62 views
How to get rid of the dependency on the Excel application?
I've recently taken over the development and maintenance of an Excel add-in, it is a pretty bad piece of software. Most of the functionality is stuffed inside the class VeryHugeMonsterClass, other ...
-5
votes
0answers
34 views
Take my python over to web development or expand my language arsenal by learning C# or something like go? [on hold]
I currently know Python (most used) and JavaScript. I've been thinking about whether to go over towards web development or not.
If I were to go to web development, I would most likely learn Flask or ...
-4
votes
0answers
73 views
Circle packing in C Programming [on hold]
Basically the idea is to generate a bunch of circles, as many as possible, but none can intersect. I'm easily able to generate circles of random colors and sizes, but I have not been able to figure ...
0
votes
0answers
24 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 ...
-5
votes
1answer
46 views
Where and how I can find explanations of abstractions and fancy stuff used in business level programming? [on hold]
This question is broad, but I'll try to be concise and to restrict the wideness of it.
I'm full of hate toward these business hipster programmers, so I won't be formal this time. Sorry.
Don't get me ...
8
votes
2answers
254 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
86 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
134 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
97 views
Automatically creating .pdf files from CSV [on hold]
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
1answer
57 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 ...
1
vote
1answer
77 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 ...
-3
votes
0answers
22 views
Cannot bind Items, always receiving null values with BeginCollectionItems [closed]
I´m doing Editing a variable length list, ASP.NET MVC 2-style, but when I try to do post, I have a null exception
Model:
public class WebPages
{
[Key]
public int WebPagesId { get; set; }
...
0
votes
2answers
208 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
232 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
270 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 ...
2
votes
3answers
136 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 ...
-5
votes
0answers
27 views
.NET WebClient and Fiddler Posts fail with Bad Gateway while identical nodejs post works [closed]
I've seen a lot of topics relating to 502 Bad Gateway errors when posting to an nginx server, but none have noted that the "exact same" post made from either fiddler or c# fail, which one made from js ...
3
votes
2answers
195 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
38 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
62 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
164 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 ...
1
vote
0answers
152 views
How can I change the behavior of a static method at runtime? [migrated]
Is there a way to modify the behavior of a static method at runtime?
for example:
Say I have this class
public class Utility {
public static void DoSomething(string data){
//...
}
...
4
votes
4answers
481 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
32 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 ...
-1
votes
2answers
194 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
169 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
47 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
53 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
113 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 ...
-1
votes
0answers
16 views
Possible ways to return a new DataView object as a result of applying row filter criteria on an existing DataView object [on hold]
Is it possible to filter rows on a DataView and have it return another DataView object instead of affecting the current DataView? Currently the RowFilter method filters the current DataView object and ...
1
vote
2answers
178 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
81 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 ...
0
votes
0answers
24 views
How do I include a complex type to an Entity Index? [migrated]
I have these 2 POCOs...
public class SqlTrace
{
public int id { get; set; }
public string Name { get; set; }
public virtual List<SqlTraceFile> TraceFiles { get; set; }
}
public ...
38
votes
8answers
3k 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
126 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
22 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
154 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
81 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
181 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 ...
0
votes
0answers
39 views
async/await, what is the purpose of async keyword? [duplicate]
Consider this sample taken from MSDN article about the subject
async Task<int> AccessTheWebAsync()
{
// You need to add a reference to System.Net.Http to declare client.
HttpClient ...
1
vote
0answers
90 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
110 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
121 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
198 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
60 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 ...
1
vote
3answers
154 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
78 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
216 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 ...