Questions tagged [c#]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
100 views

C# - Menu Implementation - Help writing it in a testable way

The Question: I'm developing an app in C# and am currently designing a menu which contains submenus and needs to be different depending on the category of the user. I've written the code but am ...
0
votes
0answers
66 views

Is it a bad practice to have a class with a namespace that goes "out" of it's project name?

I have a solution with multiple projects, lets suppose there's one project with the name Company.Name.Foo.Bar. If I declare a class inside the project Company.Name.Foo.Bar but with a namespace Company....
0
votes
1answer
85 views

How to implement Inter-Process Communication(IPC) at the local machine without parent-child model?

I'm trying to exchange some small data between my two apps. This two apps located at the same PC, so all exchange happens inside this machine. At first, I thought maybe to use sockets for it, cause I ...
2
votes
2answers
763 views

Data Repository and Complex Queries (DTO)

Following the classic 3 layer architecture domain Model (a list of entities live there and has no dependencies) DAL layer - My Repositories lives there with DBContext implementation (Ado.net) Dal ...
0
votes
3answers
87 views

How do you structure components to objects so they are more decoupled and non dependant?

I want to setup my objects to be composed of components that can be added and removed so I have more flexibility in how I set them up. A simple example would be some object that can have components ...
0
votes
0answers
42 views

Sentinel nodes in a 2-3 tree

I want to implement a 2-3 tree in C# language, where every leaf has a unique key. The keys are from a given class that implements the IComparable interface (the specific class is unknown, and it's ...
1
vote
1answer
59 views

How can I write integration tests if I need dynamically generated values from a javscript file?

We have a react website that, as part of it's process, loads a dynamically generated javascript file from a third party. It uses some of the scripts in this javascript file to generate values, which ...
1
vote
4answers
323 views

Raising concerns on the codebase as a new hire

I'm new in the team (< 3 weeks) but I believe I am experience enough as a Xamarin dev to know what I'm doing and also experience enough on using Prism library to give some criticism on how things ...
4
votes
2answers
100 views

In the absence of code-contracts, what techniques exist to represent state invariants (e.g. "Customer with Orders loaded" with Entity Framework)?

In Entity Framework 6 and/or Entity Framework Core 3+, the code-first types generated by the scaffolding (or other code-generation tools, my preference is this T4 script) are mutable classes that do ...
-1
votes
2answers
167 views

What makes LINQ (C#) unique compared to another DSL such as Django query syntax?

My question to the community is this: What makes C#'s LINQ Unique from other query language in other languages and frameworks, or does it not have anything to make it unique at this point? ...
5
votes
2answers
821 views

Is there a name for this construct with generics?

I wrote this valid piece code, which made me wonder if there was a name for it: public class GenericObject<T> { public T Obj { get; set; } } public class DerivedClass: GenericObject<...
0
votes
1answer
120 views

Should snapshot tests compare against stored test data or data from a database?

I have a method GetReportAsync that takes one XML and generates another: public async Task<string> GetReportAsync(string id) { // Get Order.xml from a file database var order = await ...
1
vote
1answer
61 views

Refactoring similar integration service code block

Context: Creating a "middleware" between 2 services I have to Get data from Service Source and get it into Service ERP. There is a multiple type of Data: A, B, C. An integration process ...
-2
votes
1answer
81 views

WPF MVVM using TPL - should I handle exceptions in the back or front end?

I have a WPF MVVM application, the WPF is the UI frontend and I have another project in the same solution that does DB access, I do this by starting a Task from the frontend that executes the backend ...
-3
votes
4answers
121 views

What's should I call a Location (Longitude and Latitude) associated with a DateTimeOffset? [closed]

In the Xamarin.Essentials library there is a Location class that comes with a DateTimeOffset TimeStamp. I know I'm being pedantic and I should just move on - I know it's to indicate a location of the ...
-2
votes
2answers
100 views

Ideas for implementing a hardware interface

I am looking for alternative ideas of how to implement the following situation (.NET Core, C#) Having multiple sensors that communicate over a RS485 interface with the host. Each sensor is implemented ...
0
votes
1answer
132 views

Is this the right way to call async and await

Hi I am new to async/await in C# . I have created a controller which is accessing result from HttpClient injected through HttpFactory. Here is my working example class MyController { private ...
0
votes
2answers
154 views

Simple vs bracketed usings C#

Visual Studio often recommends the 'simple using' statement rather than brackets. However, which is actually better? I quite like the simple using statement, but I can see it potentially causing ...
1
vote
1answer
162 views

What approach would I be using for multiple DLLs using the same data but processing it with different classes

**** EDIT: See below for "working" code based on the discussion. I'm re-writing my software from scratch and instead of hardcoding the processing libraries I decided to take a look at ...
7
votes
3answers
241 views

How to replace a file to its latest version in server that is being constantly fetched by a REST API

We have a REST API Get request which downloads a file from the server. This file needs to be updated whenever there is a latest version. Currently this is done by deleting the existing file and moving ...
4
votes
2answers
756 views

Unit testing a generic method not caring about the generic type

I have the following code public class MyCollection<T> { public void Add(T obj) { ... } public int Count { get; } } and the following unit test to check whether Add increases the Count ...
1
vote
1answer
75 views

Identifying Risks/Gotchas When Using Static

I am intending to come from the perspective of development choices, code reviews, and general testing against defined environments (Development, Test, Production, etc.). I will be using C# as the ...
1
vote
0answers
42 views

How to implement timing-mechanism for fantasy draft process utilizing ASP.NET Core 3.1 SignalR

I have developed a Fantasy Draft system utilizing ASP.NET Core SignalR, along with Azure's SignalR service (for backplane/scaling stuff). Last year I utilized a poor-mans' javascript version that just ...
0
votes
1answer
69 views

Animation system with generics can't use polymorphism

I am trying to make an animation system that affects different types so I thought I would use generics. I have an animation controller that gets all animation objects into a collection (or at least ...
-4
votes
1answer
68 views

Efficient database for multiple key searching?

I'm trying to implement a solution that stores every product from a shop, and then allows me to search them either by ID (an integer index), description (string) or barcode (string). The idea I came ...
0
votes
0answers
154 views

Storing tree data in a database for fast reading of the whole hierarchy

I have a class that looks something like this: class Entity { public string Id { get; set; } public List<Entity> Children { get; set; } public void DoStuff(Data data) { ...
1
vote
2answers
112 views

Implement business logic as dictionaries of delegates

In my application I'm dealing with periods. A period is defined by it's end date. A period may shrink or grow, can restart and can have a priority. This is modeled using the following struct: public ...
0
votes
1answer
94 views

Should I decouple domain models from IIdentity in ASP.NET core?

I saw a lot of examples of decoupling domain models from Identity models. For my knowledge, currently IIdentity is included in standard .NET library, so is this actual now and should I follow this ...
-1
votes
3answers
286 views

What is the best practice for monolithic desktop frontend-backend communication?

For a monolithic desktop application with two projects - a frontend and a backend, both in C#, what would be the best practice for communication between them? The frontend needs to make calls to the ...
1
vote
0answers
260 views

The most "correct" way of detecting changes to a database

We have a few 100's lines of code, that according to some complex logic decides if certain columns of certain entities should be updated from some legacy system. Those columns don't necessarily get ...
1
vote
2answers
269 views

Why it is possible to specify a value comparer for ImmutableDictionary<TKey, TValue>?

What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property? Why is it useful being able to compare dictionary values by using a specified equality semantic? I ...
0
votes
2answers
110 views

Best way to code lazy loading outside the model in vanilla c#

I have to implement a LazyLoading on the properties of my Entites Class. I can't use any framework and external dll (nugets package are forbiden, I can't use Entity Framework or Castle Dynamic Proxy ...
3
votes
2answers
127 views

How to handle additional parameter to existing interface

In my existing code, I have an interface like so: public interface IStudentService { T GetStudent(int userId); } This interface is called in many places, and the concrete implementation, let's ...
1
vote
1answer
154 views

Is there a library or algorithm I can use to solve this type of problem efficiently in C# (.NET Core 3.0)?

I'm having trouble defining this problem space (example below), where to look, what to search etc. and would appreciate any help with suggestions of algorithms or libraries that I should look into. I'...
1
vote
1answer
55 views

Custom File System Index/Cache - How to save index

I've got an extremely oniony(deep) folder structure which contains Appx 1,000,000 text-based files on a network share. Using windows search is extremely slow and unreliable. I've created some text ...
1
vote
1answer
139 views

How significant is the speed of native code for back end tasks?

Going native is extremely good for front end development. Whether its using android vs ionics, c++ vs dotnet/java, the benefits to GUI are significant. I was wondering if the same had significant ...
5
votes
4answers
322 views

How to create a modular system of multiple .NET Core applications extending a single application?

So first of all let me explain what I want to achieve: I want to create a basic .NET Core console application which is responsible for loading external extensions (more on this later on), listening ...
2
votes
5answers
306 views

How should I work around a particular "chicken and egg" problem with entity construction?

I'm struggling to think of a concise way to phrase the question, but assume you were developing an application that managed employees at various company branches. You could potentially model this part ...
7
votes
2answers
582 views

Suggested OO Design Pattern for a Query Builder

Essentially, I'm building a Query Builder (in C#, if that's relevant) which has this sort of interface, exposing more statically typed functions as the query gets more refined. AnimalQueryBuilder - ...
0
votes
0answers
61 views

Is it secure to make a seperate project which checks whether a license is active

I am trying to make a project which will help me to implement feature based licensing in future projects. The projects in this solution are C#/WPF Projects. So I have a Helper-Project with a class &...
-1
votes
3answers
247 views

Preventing presentation layer from directly accessing repositories?

I'm trying to design my application in line with the "onion architecture" principles, and have something like the following: HospitalController (depends on IHospitalService) \ --- ...
-4
votes
1answer
119 views

What's the best way to design a state machine with different object inheritance

I have a class A and class B, both derive from the same parent class. Each object has a state machine inside it that defines it's behaviour. The behaviour is different though depending on if the ...
0
votes
1answer
51 views

How should I structure a solution allowing direct repo access *and* a BLL layer?

I was wondering whether there was a good established design pattern for sometimes allowing direct access from the presentation layer to one's repositories, but requiring the use of the BLL (because ...
1
vote
2answers
67 views

How to edit and monitor changes in a complex Datamodel

I'm working on an Editor-GUI (C#, WPF, Windows-Desktop) for a quite complex domain model. The domain model consists of many different node types mainly coupled in a hierarchie. Also it is possible to ...
0
votes
1answer
120 views

Is it bad practice to mutate your HttpClient objects?

Im in the process of creating a base class for typed HttpClient services (yes, I'm utilizing IHttpClientFactory). I wrote the process in such a way that for each CRUD method invoked from the service, ...
0
votes
1answer
103 views

How can I have two interfaces implement one interface?

I have device interface classes written in c# for electronic variable loads. They are mostly for DC devices. We got a new one that does loading for both AC and DC devices. I also have an interface ...
0
votes
1answer
97 views

Implementing the microservice pattern

We are developing a system that runs a certain kind of simulation for our customers: Every simulation runs on it's own server. We typically have a two digit number of simulations running. A client ...
1
vote
1answer
142 views

C# design for handling a high rate of async network operations that complete with a callback (hundreds per second)

I am working with a message broker technology, to which events will be published (following an "event carried state transfer" architecture) for consumption by other applications. The vendor ...
2
votes
2answers
176 views

Providing same API implemented in multiple languages

Our budding (currently internal) API deals with building information models, originates in our main application written in c++. There is a small implementation of it in C# for easy interop with other ...
-7
votes
1answer
113 views

method and class overloading (good programming practice or ridiculousness) [closed]

I have yet to hear an answer from anyone as to why overloading of any type is a sound programing practice. Calling the same function name with an almost infinite number of variations on the surface ...

1
3 4
5
6 7
95