Questions tagged [c#]

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.

Filter by
Sorted by
Tagged with
2
votes
1answer
49 views

Write strings to a file while downloading new one simultaneous

I created this console app that gets some JSON strings from a web request using a Parallel.For loop, ...
1
vote
0answers
7 views

Getting all descendants IWebElements (using XPath) is too slow in Selenium

Well, I'm working with Selenium to scrap a webpage that has obfuscated class names (example <div class="example-gHJkLM">...)... So I needed to create an ...
4
votes
0answers
55 views
+100

Display Child View and Subscribe to its event on ReactiveUI

I am very confuse what is better approach to display child view and subscribe to its event on ReactiveUI WPF, so far I have 2 implementation that somehow works for my case: Implementation 1: ...
1
vote
0answers
28 views

ConcurrentDictionary performance

i need to improve the performance of ConcurrentDictionary. for that i created 2 classes for check if the more efficiencies than the original. ...
-2
votes
0answers
16 views

Code running but not all the way through [closed]

I have a library program that checks out books to patrons, instead of printing original data, then changes I made to the data and finally the original data again (return the books to the shelf making ...
0
votes
4answers
108 views

Code to test four conditions if C#

First I have two conditions on the number of list elements,then in one of these conditions I have two others conditons to treat it : My code: ...
-5
votes
0answers
21 views

c# Object reference not set to an instance of an object. unit test [closed]

hello i am trying to write a unit test for my processor class in my project i try to deserialize a json file and then build and process it then save it to database i want to write a unit test for my ...
2
votes
0answers
24 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
29 views

.NET Core Service/Console App Architecture

I have the following setup code for my .NET Core 3.1 console application/microservice app and I want to learn and improve what I have - I have a feeling I could be utilizing the core Microsoft .NET ...
7
votes
3answers
2k views

CQS implementation with decorators

I've created a "framework" or more of a library for a CQS implementation with a few decorators. Using ASP.NET Core for the front end, I wanted an opinion about how this looks/feels. I changed the ...
3
votes
1answer
136 views

Strongly typed unit system in C#

I am working on a Units library for a personal project that is a physics-heavy C#/Unity3D game, and I am looking to improve it in a few areas: 1) Is there a way to reduce the code duplication? 2) Is ...
3
votes
1answer
40 views

Basic Unit Test of Application Service, setup and cleanup methods

I'm not experienced with testing, therefore I'd like you to look at my code proposal of unit test. My solution has following projects Tests\Application.Tests Application Domain Infrastructure Web ...
1
vote
0answers
27 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 ...
-4
votes
0answers
30 views

Unit test for Builder class [closed]

everyone, I'm working on a project that deserializes JSON file and Builds then Process the data and store them in database I'm trying to write a unit test for my Builder class but I have a problem I ...
4
votes
1answer
372 views

Executing a sequence of actions over time in Unity

This script executes a sequence of actions over time and is based on the methods exposed by the UrhoSharp framework. I am new to Unity, but well acquainted with C# so I know what I'm doing for the ...
4
votes
1answer
153 views

Architecture Logging

I have two database tables UsersDownload, Non-UsersDownload. There is also two model object and two service that take in the object and insert the data into the correct table. Is this the best ...
6
votes
3answers
137 views

C# Event Manager without allocations

I'm using my own Action-based Event Manager for a while and looking for ways to improve it. Mainly it's used in game development, where excessive garbage generation can lead to severe consequences. ...
9
votes
3answers
360 views

Creating a round robin MySQL connection manager

Background I am working on an e-commerce website, my web server is written in ASP.NET MVC (C#, EF6) and I am using 3 instances of MySQL DB. These DBs are in a cluster (Galera Cluster) and they are ...
1
vote
1answer
70 views

Async Check for Domain Fullname With WPF and Caliburn.Micro

I have a small WPF program built using Caliburn.Micro which checks Active Directory for a user with the current username of the logged-on user. I have a Bootstrapper...
2
votes
2answers
111 views

Is it good to use the builder design pattern for HttpWebRequest?

I've a C# WinForms application that relies heavily on sending HttpWebRequests. I've build an HttpWebRequestBuilder, and ...
4
votes
2answers
48 views

Reactive operator for distinct values that must change by amount

I would like feedback on this DistinctUntilChangedBy operator for System.Reactive that only emits when the current value is ...
2
votes
1answer
75 views

Vectorization, 7-bit encoding

I was curious how vectorization works and how to write suck code. To start simple I choose 7-bit encoding as my test suspect. I'm not expecting improved throughput in any way. My implementation works ...
1
vote
0answers
13 views

xamarin SegmentedControl

I wanted to know is this the best way to handle a SegmentedControl using the e.NewValue? Base on the selected segment I hide and select different data? XAML ...
-1
votes
1answer
59 views

Unit testing an unspecific order of method calls [closed]

I cannot figure out how I am supposed to unit test the implementation of GetFilteredEntites(IEnumerable<MyEntity> myEntities). ...
1
vote
0answers
30 views

Reactive Extensions wrapper around Confluent.Kafka for .NET

Just an Rx wrapper around Kafka to represent topic consumption as IObservable<T>: ...
3
votes
0answers
89 views

UPDATED: Ambient time context to help unit testing

The following test demonstrates the functionality of Time class which is supposed to be used instead of DateTime.Now. You could ...
1
vote
0answers
32 views

Maximal Bipartite Matching

I have been working on creating a code solution for the Hungarian Algorithm, and from the testing, the slowest and buggiest part has been the bipartite matching. The most recent rendition is based on ...
0
votes
1answer
51 views

Schedule talks in tracks [closed]

Consider my simple business requirement as follows: There is a list of talks and they need to be scheduled in tracks. Each track has a morning session starting at 9am and an afternoon session ...
7
votes
4answers
1k views

Maximum character insertion

I would like to know any suggestions about to improve my code and/or get a better approach for this problem solution and your rating of my approach to the problem.(besides removing the ...
3
votes
0answers
85 views

C# Rest Client Benchmarking

I build a C# Rest Client library / framework. I noticed that it seemed to be significantly faster than RestSharp for GET at least. So, I decided to put together some benchmarks comparing it to other ...
3
votes
1answer
57 views

Payment system migration

GitHub There need to be a software design supporting gradual migration from one payment system (E-xact) to another (Stripe). Credit cards data are stored outside, so I would like to use both systems ...
1
vote
3answers
130 views

c# IndexOf string search

I have this code working but its using IndexOf I am not sure if that is the best or only option for search for a string value. What I have is a list that will need to remove a world from the child ...
1
vote
0answers
19 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 ...
7
votes
2answers
1k views

Extendable REST-Client

I've been working on a REST-client. The client itself provides only very basic and generic functionality. Everything else is done with extensions. Its raw usage does not need to be convenient but ...
1
vote
0answers
52 views

HTTP Client - Best practices

I've made a HTTP client and would like some tips to improve my code, it's supposed to be built for xamarin forms but should work with any implementation. My goal of this project was to learn more ...
1
vote
1answer
122 views

Connect 4 class in C#

I wrote the following class for a connect four game in C# ...
4
votes
1answer
58 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 ...
2
votes
1answer
46 views

Validate implementation of ECIES

I've created a basic implementation of ECIES (Elliptic Curve Integrated Encryption Scheme) based on http://www.secg.org/sec1-v2.pdf section 5.1. ...
1
vote
0answers
60 views

Abstract vacation time tracker with states [closed]

I am writing a program for vacation in a company and the time that is allowed to be in a specific holiday I used an Abstract class with an abstract method: ...
1
vote
0answers
58 views

get better performance [closed]

I have this code that works, but I'm sure that it can be done better, any suggestions? ...
4
votes
1answer
41 views

Multi-threading with TPL - Access Internal Class Properties

I am using the TPL library to parallelize a 2D grid operation. I have extracted a simple example from my actual code to illustrate what I am doing. I am getting the desired results I want and my ...
3
votes
2answers
56 views

Adding a cancellation token to TcpListener.AcceptTcpClientAsync()

There is no facility in TcpListener (or for that matter Socket) to close a listening socket that is waiting for a connection without throwing an exception. After running up a test bench with 8 ...
0
votes
1answer
26 views

c# Ftp.UploadFile

I am trying to improve working code seeing if there was any potential issues or performance problems. This code will connect to an ftp server and upload a file. ...
6
votes
1answer
2k views

Message bus in C#

I wrote a MessageBus class whose only purpose is to deliver messages from object to object without direct link between them. I encountered a problem with duplicate ...
0
votes
0answers
41 views

Array of varied dimensions

I wrote a UltraCube class whose purpose is to provide an array of custom number of dimensions. This was created because I needed to make number of dimensions for ...
3
votes
1answer
191 views

C# Windows Forms App: Adding An Element To The BindingSource And Save These Changes To The DB [closed]

I have build a C# Windows Forms app that used Entity Framework(DB first model). For the data I am using a .mdf database file. The data view of dbo.students: GUI: The Form1 class: ...
4
votes
1answer
128 views

Method that filters a list parameters based on different fields

I have this code which is a callback for Filter in WPF ICollectionView. When I run code analysis, the cyclometic complexity is reported to be 11. I consider this ...
1
vote
1answer
93 views

Increase Perfomance of Nested Object Instantiation C#

I'm filling a list of items from the database, which is taking extremly long time to run (Approx 60 seconds) Here is the code with the relevant breakdown 97% of the performance issues come in the ...
2
votes
1answer
57 views

Inserting large amounts data into Excel spreadsheet

I have a VSTO Excel Add-In which is used to retrieve data from another application and insert it into an Excel worksheet. Due to the potential for lots of pieces of data to be inserted into a ...
7
votes
2answers
137 views

Finding a way to make this 2D loop faster?

So I'm creating a unity3D game with infinite terrain and it's going great! However, I'm struggling with a specific but important part of the 'infinite' terrain. Make the terrain actually infinite. I ...