People who code: we want your input. Take the Survey

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

C# after-coding information [closed]

Probably it's a dumb question but: so far I have only made programs for school exercises that stopped at the code to be sent to the professor and nothing more, Now i'm doing an accounting software for ...
0
votes
1answer
58 views

How can I implement Windows close in MVVM pattern? [closed]

I'm newer to MVVM design pattern with WPF .Net Framework I have a : Model ( Student ) View Model (StudentViewModel ) RelayCommands MainWindow.xaml.cs MainWindow.xaml Everything works fine and I have ...
0
votes
2answers
53 views

Extend the ApplicationUser class or use a Person class?

I am making a web system using Asp.Net Core with individual user accounts (Identity), and I was thinking about how I should store the users' personal information in the database. The system will have ...
0
votes
1answer
34 views

In CQS is it accepted to have a coupling to another command

Consider this code, rather than hardcoding the hour when we execute a certain command I query the CQS engine and asks when it will be executed. Though now we have a high coupling to another command. ...
0
votes
1answer
115 views

C# is it acceptable to create a generic class and use an enum as generic type?

Abstract The case: Application contains a lot of views with a list of data. Data views (lists of records) have pagination, filtering and sorting options. The user must be able to select a "...
0
votes
2answers
50 views

Designing an API where an image can be supplied

I am designing an API whereby some other system can supply an image in their POST. As such this is an API for integration purposes, with no front-end. Postman is used for testing the API. Below is the ...
0
votes
1answer
70 views

Processing large number of messages in a thread-safe manner

I have the following use case and would like to implement it in a thread-safe manner. Think of a Stack Overflow-like web application. Somebody upvotes a question. A new event is sent to the message ...
1
vote
2answers
79 views

CQRS: Is it an antipattern if the Command invokes a database interface which contains business logic?

Martin Fowler states that, Command module executes validations and consequential logic which aligns with every CQRS demo app that I've studied. That is to say: validation -- does this Jedi exist? -- ...
3
votes
5answers
159 views

How can you ensure order of execution in concurrent tasks?

Here is what I am specifically doing: I have a thread-safe queue One 'write' thread constantly writes to the queue with data that comes from another service Multiple 'read' threads take from the ...
4
votes
7answers
474 views

When to use a class with a constructor vs using a method returning an object

I've been working in a rather large codebase filled to the brim with small classes such as class Person { public string name; public int age; public int height; } As a mainly front-end ...
2
votes
1answer
115 views

Dependency injection post-serialization

I'm modeling a general RPG-game-style quest system where player choices lead to certain effects. The below examples have been simplified for the sake of clarity. This is a web-based context, which I ...
0
votes
1answer
31 views

Does injecting ILazyLoader inside entities in EF contradicts separation of concerns in design?

Microsoft suggests to inject ILazyLoader service inside entities in order to enable lazy loading manually in EF: https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy#lazy-loading-...
0
votes
0answers
26 views

How to set up login pin system

i want to set up basic login page in xamarin.forms. There is no username/password, just a simple pin so far i have 3 pages to do this Sign-up Pin page Sign-up Confirm Pin Page (re-enter pin to ...
-4
votes
1answer
58 views

Calculate math function depend on N value [closed]

I have method with the following prototype : R[] = method(k,n) which : n = ordinal value 0 <n <10^9 k = math function depend on n value : i.e n^6 R = array of computed values For example : n = ...
1
vote
3answers
157 views

Should Source Generators be used for managing optional dependencies

Let me try to clarify my question with an example. Assume a library of some sort which has a built in logging system and it is published as Library.Core. As the maintainer you want to add a wrapper ...
1
vote
2answers
128 views

How are changes propagated from the ViewModel to the Model and how often in MVVM?

I am learning the MVVM paradigm and I have seen a few different implementations surrounding the Model and how it is updated which I want to understand. My understanding of the View and ViewModel ...
2
votes
1answer
95 views

CRUD is too simplistic for my usecases, how would you handle the repository pattern when using MediatR and EF Core?

I have a .Net 5 Web API project and use MediatR to encapsulate my business logic into commands and queries since I don't like to have a single CRUD service handling everything related to a specific ...
0
votes
4answers
297 views

How do I decouple this coupled application?

I currently have this Bot Viewer application Which consist of the application itself - the Bot overviewer, which depends on a library Bot.Core. Within Bot.core we have defined the core interface for ...
0
votes
0answers
42 views

CQRS command with complex creational logic

I have a domain model that defines the various aggregated levels (values by city, state, etc.) of historical data used by an associated web application. There are hundreds of these 'DomainData' ...
0
votes
2answers
117 views

Method that is aware of interface underlying type without reflection

I'm struggling with the design of a method CallSystemX() that needs to accept a parameter of multiple Types. To get around it I created an interface called IRequest to be able to pass different types ...
0
votes
0answers
63 views

Exposing an event source as an interface, but where the source may expose events individually or as a collection

I am using a publish-subscribe event broker, and am constructing libraries to help people interact with this broker consistently. One of the things I would like to design is some kind of IEventSource ...
-2
votes
1answer
62 views

How to implement factory pattern in following case?

I have a program which downloads web pages and then scrapes html to create domain specific collection objects e.g. ProductCollection, CatalogCollection, NewsCollection and more. The idea is to create ...
-2
votes
2answers
110 views

Which design pattern to use for a calculation pipeline with lots of varying rules

I'm currently trying to solve a problem with some legacy code that makes some calculations in order to find out the final value of a monetary benefit. The legacy code uses an imperative approach with ...
0
votes
1answer
146 views

Sharing form validation rules between backend and frontend (Having single source of truth)

I'm currently working on a web app using ASP.NET Core (C#) on the backend and Next.js (TypeScript) on the frontend. I have a lot of forms that need to be validated and I don't want to write validation ...
-2
votes
6answers
182 views

C#, design classes to be scalable

I'm creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to ...
0
votes
2answers
89 views

How to handle validation errors from API response when using repository pattern

I've got the following: Clientside C# application. Contains forms for CRUD operations. It uses an API for all data operations. Input is validated on the client, and obviously also on the server (API). ...
0
votes
0answers
20 views

When Receiving/Returning data in controller action - DateTime conversion between UTC and Epoch in Asp.net core WebAPI

I was wondering what would be a better approach designing a system which deals with UTC DateTime in the service and Database layer but needed to send and receive the DateTime in Epoch format from ...
-3
votes
1answer
125 views

Proper way of implementing MVP passive in C# .net

In "MVP Passive" where a view doesn't know about it's presenter the view just raises events observed by the presenter, the presenter knows the view and its controls how should view and ...
1
vote
1answer
93 views

Naming for services/workers ect

I'm kind of new to this "separate your methods from models" (yes I was one of those developers). From what I understand I have to separate everything into models, services and factories. A ...
-2
votes
1answer
107 views

How to sync async and await Tasks?

With threads you could use Semaphore, mutex, ManualResetEvent, etc... to sync a shared data, how do you accomplish the same thing with tasks? Essentially, if I have shared data between different ...
0
votes
2answers
59 views

Where to put files (interfaces) that link two independent assemblies: Authentication and Main Program

I'm having an issue with dependencies in a C# app that I'm creating. I have an assembly for my authentication process, and a separate assembly for starting up the main program once authentication is ...
-3
votes
1answer
56 views

Inter application communication .Net

I have multiple WPF applications running different programs some of them are interconnected so one might have to start another at some stage. I need a way to communicate and share large amounts of ...
3
votes
2answers
213 views

How to model classes that can be extendable?

I have recently inherited a codebase which has a weird problem and I am trying to search for an extensible solution that can solve my issue. Consider I have a model class that is used as a model to ...
0
votes
2answers
53 views

Strategy for Chrome timing out on a Database cleanup job which takes a long time

I have a notifications app which sends users notifications. It uses a .NET core backend, an angular frontend and Cosmos DB. Within this I have an API endpoint function which is linked to a button used ...
-1
votes
2answers
128 views

How to avoid CRUD and layered architectures in REST backends?

I'm creating a .Net 5 API backend and use EF Core for the database part. The simple CRUD way I know: API layer calling a command or query from the application layer using MediatR Application layer ...
-1
votes
3answers
207 views

Design pattern for creating and scheduling tests/exams

I have an Exam class that represents an examination/test: public class Exam { public int Id { get; set; } [Required] [StringLength(maximumLength: 30, MinimumLength = 1] public string ...
1
vote
2answers
115 views

Inversion of Control: Separation of concerns in a composition root

In a C# console application of mine (which uses CliFx for the command line processing), I'm setting up dependency injection using Autofac. What I've learned about IoC is that you should have a single ...
0
votes
3answers
222 views

Are C# unit tests running independently from each other?

I'm using C# with NUnit. Let's say you have a class public class MyClass { private int classMember; [Test] public void Test1() { classMember = 1; Assert.That(classMember ==...
0
votes
1answer
107 views

Is it any more efficient to reuse a variable than to create a new object?

In a project I am working on we load various entities from the database, do some work then attempt to save the resulting entities. If saving the result is not successful, we return a Result object ...
1
vote
2answers
248 views

C# convention for empty constructor [closed]

I know an empty method without any good reason is a code smell, but it can be required for constructors. What would be a good way to write an empty constructor among the following? class A { ...
1
vote
2answers
116 views

Application made up of multiple executable programs

I am developing an engineering application (WPF, C#) that consists of a collection of other programs that perform specific engineering tasks. I guess you can think of it like Microsoft Office, however ...
0
votes
2answers
100 views

Where should I put the initialization validation of a Value Object?

Hi I am making a Value Object. public class Age { public Age(int age) { Value = age } public int Value { get; private set; } } I want to check ...
0
votes
0answers
33 views

Am I doing Unit Of Work or Context Object pattern against my API, or none of em?

I have created a "simple" C# client library for an HTTP based API (So, think kind of REST.. but yet not.. but that aint important for this discussion anyways, but might be important for some ...
0
votes
0answers
45 views

How to debug your collegues NuGet package

Disclaimer: This is a rather broad topic and there is probably no clear right/wrong. Still I would like to exchange experiences with experts of huge projects to learn and improve work between teams. ...
0
votes
1answer
39 views

Best data structure for searching best color match? (4D space)

My current color distance formula is a modified version of Euclidian distance (eDist) because with eDist I was noticing weird issues where blue could be used instead of green in some situations when ...
0
votes
1answer
121 views

C# Design for database queries and commands

Currently I'm working on a project that will interact with a database. Based on my research, I would like to develop a repository class which responsability is to write/extract entities to/from a ...
5
votes
4answers
231 views

Use local or nested function for readability?

I found in the catalog of Refactoring by Martin Fowler, with Kent Beck book that they mention Extract Function refactoring. It is a good practice to wrap your related code into local functions to ...
1
vote
1answer
68 views

Does it make sense to have a facade centralizing events too?

From my understanding a facade is a class with the sole purpose of simplifying the use of a specific system/module behavior (its methods). It should not contain any relevant logic of the underlying ...
1
vote
2answers
65 views

c# template method pattern design question

I'm currently in a situation where I have multiple derived class types(just one is shown in the example below) that need to apply some logic before and/or after calling a method implemented in a ...
-2
votes
2answers
229 views

Measuring async/await overhead

A while ago I read an article stating that overhead of an async/await call was around 50ms. More recently I read an article that it was around 5ms. I was having a discussion about whether we should ...

1
2 3 4 5
93