Questions tagged [.net]

.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

Filter by
Sorted by
Tagged with
3
votes
1answer
46 views

C# KeyNotFoundException with more information

Preliminary rant: System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary. Oh. My. So I finally got fed up with how ...
2
votes
1answer
53 views

Different versions of the Operate method

I have code that basically is the same, but depending on the number of arguments you provide (up to 5), it will operate with them in a very repetitive way. I have the feeling that this can be ...
3
votes
2answers
153 views

Build byte array from multiple different types of data for sending over a network

The following codes purpose is to generate an array of bytes that represents some user defined data. This array of bytes will later be used for sending over a network. ...
-2
votes
2answers
59 views

How can I refactor a function to be inline? [closed]

I'm refactoring functions trying to do more of a in-line aproach. ...
3
votes
2answers
75 views

Exporting objects in various formats while reporting progress

Description A WinForms application has a function to export objects of the following type, in various formats: ...
2
votes
0answers
21 views

Applying OOP to refactor my Windows Forms APP [closed]

Could you please give me some direction about how I could refactor my code? As I add functionalities to my Budget App the class is getting bigger and I'm sure I could start looking at separating ...
1
vote
0answers
87 views

Code refactor - eliminate generic interface and object methods

I'm building a method that tries to detect whether given information about an object's property to retrieve, a constraint operator and some data to compare it against, whether the result is true or ...
7
votes
3answers
2k views

C# Am I using proper SOLID principles?

I am currently practising using the SOLID principles in C#/.NET I have made a little example, but i am not sure if i have followed it correct. Its a simple example where i have an API controller that ...
3
votes
1answer
60 views

Undirected graph data structure in C#

Description A class representing an undirected graph. At the moment, it supports integer values as vertices. An example of the type of graph represented is shown in the following diagram: It is ...
3
votes
2answers
123 views

Refactor multiple if-else conditions when condition is a minor change

I'm new programmer and I'm working on Xamarin MVVM app and I have a pin view like So, basically I have numbers from 0-9 if you pick one number its visible then if ...
7
votes
1answer
317 views

Is Lock necessary to make operation thread safe for this scenario

I have the following method that is responsible for retrieving an Item from the database. There will be multiple threads instantiating this class, so I want to make ...
12
votes
2answers
466 views

C# - name separation & last name in upper to Camel

I had an xls file with lots of full names in the following form at work: ...
3
votes
1answer
67 views

Simple Password Generator Feedback

This is my first major project in F#, looking for any critique on how I can make it more standard or more concise. Some things I feel like I could have done better are the command flag parsing and the ...
1
vote
0answers
103 views

C# Neural Network project

I'm writing a NeuralNetwork library, so everyone could use it and I'm wondering if I can optimize it even more. Here is my GitHub repo if you want to check the whole project (I recommend using the <...
1
vote
0answers
34 views

Find assemblies in subfolder of primary assembly

I'm using the following handler to resolve assemblies in a specifically named subfolder of the main assembly's folder. I am looking for improvements in: clarity correctedness flexibility, as long as ...
1
vote
2answers
106 views

Building a Word document containing two different tables

I am trying to generate a Word document with two different tables inside it. For this purpose I have two similar methods where I am passing word document reference and data object and table to the ...
1
vote
1answer
50 views

Update cache with minimal blocking

As part of the task, it is allowed to use slightly outdated data. It is required that only one thread per key is involved in the critical section, while the remaining threads use data from the cache ...
0
votes
0answers
51 views

C# class to dump the memory of a process in several formats

I made this because I couldn't find any good C# classes/libraries that allow you to dump the contents of a process' memory into a file or a byte array. I haven't tested this on 32 bit systems but it ...
3
votes
1answer
101 views

In Memory Database in Unit tests, isolate the tests

I have stumbled across these unit tests in a code review that are using in memory db: ...
3
votes
1answer
96 views

Writing a c# class that has enum like constraint while behaving like string

Following This post : https://stackoverflow.com/questions/630803/associating-enums-with-strings-in-c-sharp/56482413?noredirect=1#comment107635743_56482413 I wanted to go further as it didn't quite ...
2
votes
0answers
31 views

Email Service - Sending an email with azure blob storage Version 2.0

Now implemented changes suggested in my previous post and now am back again for the internet to tear me and my shitty code down. PatchNotes Extracted templateRetriever class from the email service ...
1
vote
1answer
67 views

Email Service - Sending an email with azure blob storage

Here is some code that sends an email using Mimekit for .net C# to send email via Office365. DI is done using TinyIOC. It downloads an image from blob storage and then sends it with an attachment. ...
3
votes
1answer
34 views

Compare 2 directories for equality

Currently, I'm working on a legacy application written in .NET that does not contain any unit tests. This application, when executed produces a very large directory tree with roughly 20.000 files in ...
-1
votes
1answer
59 views

ASP.Net Core API JsonPatchDocument

Hi I am creating a website for my chiropractor and I am creating the API for data access. I am creating a HttpPatch Method and want to know if this is the right approach so would be grateful if you ...
2
votes
1answer
46 views

Enum conversion to Enumeration class with small Business Logic inside

I had old enum, I converted it to Enumeration class and added one method inside (isValid). I am not sure if it is good approach ...
1
vote
1answer
34 views

String Concatenation and Comparison

I have the below code. I have list of status which contain may contain 4 values. R,UR,DO,NDO based on this list. i need to convert to Y,N values If list contains R the Readstatus="Y" If list ...
1
vote
1answer
67 views

My simple implementation of a DI container

I decided to make my own light DI container. I know about Zenject, etc. I wanted a very light analog. I'm concerned about a few things: 1) is it correct to use struct instead of class for reference ...
1
vote
1answer
76 views

Initialize bunch of variables in constructor by extracting value from dictionary

I have a headers dictionary value being passed to one of my constructors and based on that dictionary value I am extracting individual headers I need and setting ...
5
votes
2answers
137 views

ASP.NET Core 3.1 AddHttpClient call that includes a call to the database

So, I have an ASP.NET Core 3.1 web site that makes occasional calls to a vendor's RESTful API. I use the HttpClient class to perform these calls. Currently, the ...
4
votes
1answer
79 views

A* pathfinding for integer Vectors

This class is for calculating the shortest path in a 2D World (without minding obstacles). I'm using the A* algorithm and 2D Vectors (from the SFML Framework). It is working but takes (a lot of) time ...
0
votes
0answers
32 views

Handling disconnected entity scenario in Entity Framework Core

As some you you may know, handling disconnected entities in EF can be a bit of a headache. After a really long weekend, I managed to make it work for my use case and refactor the code to the best of ...
2
votes
1answer
32 views

Send Data from DynamoDB to Lambda (C#) and to Azure Queue

I am a beginner and trying to send data from AWS DynamoDB to Azure Queues. Note that this code will be invoked 10,000 and alot more. Can you guys review it once. ...
6
votes
4answers
216 views

All your Base - Exercism.io

This is an exercise on the website Exercism. I am self taught trying to learn C# and C++. This is the information from the readme. Convert a number, represented as a sequence of digits in one base,...
1
vote
0answers
36 views

Handle login method with external users and LDAP users

I'm working with a ASP.NET Core (v2.2) Web Api project and implemented some APIs. However, I'm facing performance issues, hence trying to optimizing the code. Here is the login API code. ...
2
votes
1answer
73 views

Programmatically getting the GUID of an application

Intrigued by the events chronicled here (also here and here), I saw the inherent utility in having a program-specific GUID available. The SO answers that were correct seemed a bit tightly-coupled and ...
1
vote
1answer
77 views

Getting names/values of multiple properties [closed]

Lets say I have one method, which extracts property name and value: ...
1
vote
0answers
60 views

Extension method: Task<T>.CoalesceAwait

There has been ongoing concern about the question of awaiting a task that could possibly be null, as when using null-coalescing operators. Consider the following: ...
1
vote
1answer
81 views

Serializing object graph to proprietary binary file

I'm creating a class library to read/write .3di files which are binary files describing 3D models for a video game. This review is for the write/serialization process. I've mapped the different ...
2
votes
1answer
106 views

Can this async method be improved or simplified

I was tasked to write process that initially seemed like a straight forward thing. "Fetch data from database, create a cache object, and assign this data to it. Use existing class to model this after."...
3
votes
1answer
1k views

Dependency Injected StackExchange.Redis Client

I am currently building cache for my application, and I would like to have my redis cache client work the same way you would dependency inject a DbContext. I am using StackExchange.Redis to manage my ...
2
votes
0answers
231 views

Generic CQRS Query handler with custom return type

I am trying to build a generic query handler using the MediatR (v8) library. Let's jump to the code: First of all I have an abstract query class like this: ...
1
vote
0answers
32 views

calculate time in data processing into XML and CSV [closed]

I made a program (C#, .NET) that calculates time for XML and CSV export and please I have a question for improving my knowledge in programming. Do you think that I can improve the structure of the ...
1
vote
0answers
227 views

Reactive Extensions wrapper around Confluent.Kafka for .NET

Just an Rx wrapper around Kafka to represent topic consumption as IObservable<T>: ...
1
vote
0answers
314 views

Accurately measure ASP.NET Core 3.x actions execution times (Web API project)?

I want to be able to log the time spent by a certain Web API action in an ASP.NET Core 3.x application. This is a very old question from ASP.NET which relies on global action filters, but in ASP.NET ...
3
votes
0answers
82 views

Creating SQL Server Database Users Dynamically from User Input

The Application I have an application in testing that runs off of an MS SQL Server database. The app allows users to authenticate using Windows authentication (that is, using the Windows username the ...
4
votes
2answers
64 views

Feedback on automatic form filling with reflection

Context: I need to fill a handful of .docx templates with answers that come from form.responses, which is a dynamic object that comes from a JSON and can have different properties that vary according ...
3
votes
1answer
125 views

Bulk inserting/updating people with additional properties

The below code is either inserting or updating a list of person with a lot of properties of these persons. The code is repeating itself a lot but is working as intended. Unfortunately making all the ...
4
votes
3answers
101 views

Method that fetches rows from database and maps it to a Model class with SqlDataReader

So, I have a project that has a lot of methods that look alike. In the below method as you can see it just fetches a bunch of rows from database and maps it to a model class. In this case ...
15
votes
0answers
189 views

Open source project to ease the Assert part from the functional tests of .Net Core Web APIs

I have built an open-source project based on FluentAssertions in order to solve some recurring tasks I was doing while testing the .Net Core APIs I'm developing. I find the capability of doing in ...

1
2 3 4 5
23