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
1
vote
0answers
9 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
120 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
310 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
462 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
62 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
99 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
31 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
102 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
49 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
45 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
98 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
94 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
56 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. ...
2
votes
1answer
32 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
50 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
45 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
65 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
90 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
77 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
31 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
214 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
72 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
58 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
79 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
797 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
151 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
173 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
211 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
76 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
124 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 ...
14
votes
0answers
170 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 ...
2
votes
1answer
4k views

Generate Unique ID in C#

Objective To create a unique id with few characters as possible. Language: C# Engine Unity3D Target : iOS && iPadOS Scenario I found quite a few solutions from Stack Exchange but would ...
1
vote
0answers
55 views

PowerShell script to execute Docker maintenance, optionally non-interactively

Problem Developers in my team are new to Docker. I wanted to provide a way to accomplish general Docker housekeeping tasks (like pruning unused images and compacting the Hyper-V volume) largely ...
0
votes
1answer
440 views

Cancel Long Running Query using Cancellation Token AND SqlCommand.Cancel()

I need to be able to cancel a long running query programmatically through our application. The code below will kick off a long running query and give control back to the main thread. At any ...
3
votes
2answers
115 views

Validate if either or both of two fields has been provided, as a ValidationAttribute

I have a binding model where at least one of two fields must be specified. I can't just set them both as [Required]. Here is what I came up with: ...
4
votes
1answer
217 views

WPF Custom Control with a Single ObservableCollection DependencyProperty

I'm learning how to write WPF custom controls. My example, NameLister, exposes a single DependencyProperty, Names, of type ...
3
votes
1answer
61 views

Formatting a type's name

I'm writing a code generation library, I've exposed a couple of methods and of course in order to define a member you need to specify it's type, the easiest way is to use ...
1
vote
0answers
72 views

Running some code every day at certain times

I am currently developing a windows service in C# which is supposed to run a data import every day at configurable times. For this purpose I have created a class "ExecutionTime" which contains the ...
5
votes
1answer
176 views

Encrypting credit card data

I need an encryption algorithm that would be secure enough to store credit card data. So it should be reasonably secure. Here's what I've come up with. I'd appreciate any constructive criticism. <...

1
2 3 4 5
23