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.

484 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
149 views

KMP algorithm searching from the right

The generic version of extension method is aimed to work like String.LastIndexOf which can search t from the last position of <...
4
votes
0answers
360 views

2-tier c# cache

I have slightly altered Marc Gravells 2-tier cache code which can be seen here. I changed it to use Stackexchange.Redis instead of Booksleeve and also added some retry logic and serialization. ...
4
votes
0answers
3k views

REST Web API Claims / Identity 'refresh' per request

I intend to expose a ASP.Net REST API for a project. I would like to use the default ASP.Net Identity system to provide the SQL backend. Users are managed in a different project. For my REST API ...
4
votes
0answers
284 views

Unit of work with Repository pattern

I am trying to work on a WPF application and decided to go for Unit of Work and Repository pattern, along with MVVM. I am using Entity Framework as my ORM. Could ...
4
votes
0answers
3k views

WPF MVVM Dialog with Prism, MahApps.Metro

I am building a Metro-themed WPF application with MVVM approach using Prism and MahApps.Metro. I have to show a custom dialog from view model. Currently, I am using ...
3
votes
0answers
58 views

C# Dictionary Wrapper for VBA

I am a technical reviewer/writer and I use VBA for Word a lot to manage issues in Word documents I receive. I have frequently come across niggles when using Collections, Scripting.Dictionaries or ...
3
votes
0answers
65 views

Hosted service for queuing and running tasks in parallel in ASP.NET Core

I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the ...
3
votes
1answer
27 views

Feedback on reactive operator for distinct values that must change by amount

I would like feedback on this DistinctUntilChangedBy operator for System.Reactive that only emit when the current value is ...
3
votes
1answer
80 views

Speeding up HTTPS API Call helper method

I am having severe problems with performance on a WEB API helper method, the performance is simply dreadful, 1-2 connections / second, I am trying to make 40k API calls and 5 hours later it is still ...
3
votes
0answers
59 views

ASP .NET Core DI: Dependency on single implementation of multiple registrations of service type

Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (...
3
votes
0answers
67 views

Longest palindrome code in C# takes time out on LeetCode

I like to request a review of the code below, which is my attempt at answering the question here on LeetCode site. The code passes 43 tests, but it times out on the next one. I copied and ran the test ...
3
votes
0answers
27 views

Procedural Generation

I'm currently working on a procedural generated terrain. I've written the Chunk script, and it works great. When I generate a few chunks in Unity, it runs alright, but it could definitely run better!...
3
votes
0answers
79 views

cleaning up c# code which connects to sql database using windows form

All I would like is for help with putting this code into separate classes as I cant seem to figure it out. I would just like to understand how this would be possible with this set of code. ...
3
votes
0answers
59 views

Running a JavaScript program from C# with sandboxing

I am using EdgeJS in my application. The application is used to run a user-provided javascript program from C#. Because we allow execution of user scripts some sandboxing is required. I am using vm2 ...
3
votes
0answers
64 views

God-class which controll CNC machine

I have a god-class (GodClass) which work with class-adapter. Class-adapter (OldController) work with old api-class which can't to use directly cause it has bad api with low-level parameters. God-class ...
3
votes
0answers
66 views

Optimizing throughput when writing millions of rows with Parquet's row group

I'm building a basic data pipeline in .NET to extract data from tables in our RDBMS systems, that exports into columnar storage using Parquet. I'm using Parquet's row group to batch up the writes into ...
3
votes
0answers
28 views

Configure multiple application features by common criteria

My FeatureSerivce provides only basic APIs, so it is good in dealing with single features. Like I can configure only one feauture at a time: ...
3
votes
0answers
75 views

Converting VBA Add-In to C# VSTO. Code following button click event

This is my first program with C# and VS and was originally a VBA Add-In I wrote. I have embarked on this as a learning exercise. The code does work and provides the desired output in a new workbook. ...
3
votes
0answers
494 views

Controller in an ASP.NET Web API application which generates a CSV file

I have a controller in an ASP.NET Web API application which generates a CSV file. The controller looks like this: ...
3
votes
0answers
73 views

Document class for various formats

I must to model Document class. I receive document as bytes array. I can receive pdf, zip, text and xml documents. After few operation I must store documents. If document is in xml format I can get ...
3
votes
0answers
49 views

Generic library for querying various kinds of databases

Since C# 8 and .Net Core 3 are going to be released sometime this year, I wanted to try and convert the library I made to make querying databases easier, implementing the already accepted features (...
3
votes
0answers
78 views

Scheduler built with observables v3 (follow-up) - now testable

This is a 2nd follow-up to my previous one about a Scheduler built with observables. Although the last one was working correctly, it was only possible to see this ...
3
votes
0answers
166 views

AJAX shopping cart with quantity +/- buttons

I'm a junior developer (couple years into it) and very new to AJAX. I'm writing an internal inventory application built on MVC and right now I'm dealing with adding and removing items to/from a cart. ...
3
votes
0answers
1k views

Deserializing JSON with Utf8JsonReader

Path of Exile is a PC game where players can list their items for sale. The game has a public API that serves JSON which contains all of these items. My application consumes that JSON and indexes the ...
3
votes
0answers
63 views

Industrial Automation App with tightly integrated classes

I have written a Windows Forms app that interfaces with a variety of equipment to automate the testing of some gas sensors. The program has four main objects, and sometimes these objects have to call ...
3
votes
0answers
401 views

TCP client reading socket asynchronously

I'm relatively new to .Net/UWP networking and have been trying to make sense of the APIs. I'd like to implement a TCP client that is capable of reading and sending messages independently (there is no ...
3
votes
0answers
82 views

Generic object-to-XML mapper

This code is part of a larger mapping library I'm working on to address some business concerns of transforming data. I was inspired by mapstruct in Java, but opted for users to annotate / add ...
3
votes
0answers
139 views

Iteration of self-refreshing MemoryCache encapsulation

I have attempted to implement the advice from the original post and debugged the original concept. Certain changes in the logic have necessitated other changes, including breaking into the library ...
3
votes
0answers
597 views

Generic Unit of Work implementation

I am implementing the unit of work pattern to be used in the logic layer of my application. The goal is to abstract away the tasks of managing transactions / connections. My implementation relies ...
3
votes
0answers
2k views

Structure and Implementation of Generic Repository and Unit of Work patterns with Dapper and SqlTransactions

I am attempting to update some legacy code that I work with, but my knowledge of data access is limited to a basic use of Entity Framework and simple Dapper. After some research, I have a loose ...
3
votes
0answers
43 views

Creating a series of relationship hierarchies from a list of nodes and connections

I have put together some code that creates a tree structure from a large list of nodes (entities) and connections and am looking to speed it up. HierarchyWorker: Converts the list data into the tree ...
3
votes
1answer
1k views

Proper way to display form with filtering in ASP.NET MVC 5

I want to create page when user can use form to display filtered data in table. Form has to remember its own state, because after every refresh it shouldnt change. So after submitting form I should ...
3
votes
1answer
135 views

Rx.NET operator

I need an operator to allow a stream of booleans to act as a gate for another stream (let values pass when the gate stream is true, drop them when it's false). I would normally use Switch for this, ...
3
votes
1answer
331 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 ...
3
votes
0answers
176 views

Object pooling in WPF

In a WPF project I'm working on, often multiple objects reuse the same AnimationTimeline, to smooth that out I made an ...
3
votes
0answers
163 views

Extendable REST-Client - follow-up

My previous RestClient wasn't disposing a lot of resources. I've fixed it (hopefully without introducing new issues) and because a few new patterns emerged I did a ...
3
votes
0answers
752 views

List nearby bluetooth devices as well as devices in the database

I made a list of all nearby printer devices (that match the same name in the database) as well as all printer devices from the database. They are separated in the list by "--". I am able to get the ...
3
votes
0answers
1k views

Cancel running Task on Dispose and race condition

I'm building a wrapper around NamedPipeServerStream and NamedPipeClientStream. Currently my ...
3
votes
0answers
336 views

Media player in WPF - Event binding

I recently started making a media player, this is the first time I'm using WPF and I found that most project are utilizing the MVVM architectural pattern, I haven't used that one either but I decided ...
3
votes
0answers
335 views

Extension methods with reusable logic - passing Action to Func<TResponse>

I have several extension methods for interacting with the Google Calendar API, and these all use an ExecuteWithRetry function for wrapping API calls within retry ...
3
votes
0answers
1k views

wcf service client wrapper for asp.net core

My goal is to grab some data inside asp.net core app on server from external source via wcf service. In future i would like wcf responses to be cached on server and provide asp.net app clients "normal"...
3
votes
0answers
1k views

Using websocket to show progress for slow action with ASP.NET Core MVC

I have a process that takes a substantial amount of time (several minutes) and would like to trigger it from a web browser and give feedback to the user that it is working. I created some code that ...
3
votes
0answers
711 views

Navigate to three pages in parallel with Selenium, ChromeDriver, and NUnit

As an experiment, I've created an NUnit test project that should, when running all tests, open three browser windows simultaneously, and each should load a particular page before closing. My question ...
3
votes
0answers
1k views

Create PDF preview

I have written the following GetPDFPreview() method. It open a PDF file, create a thumbnail (using PdfDocument class) and ...
3
votes
0answers
380 views

Generic repository accessor in a unit of work

I'm giving the repository + UoW patterns my first shot on the server side, so bear with me. Also, it's worth mentioning that I haven't used an IoC container on the server side before either, so I'll ...
3
votes
0answers
45 views

NodeFlow - How to connect Properties in a clean way?

I have implemented a project called NodeFlow. As you can see in the picture you can create multiple nodes and connect their properties with other (Function)Nodes to modify the properties and let the ...
3
votes
0answers
51 views

Select Top N elements nested objects

I want to select top N related products using GetTopRelatedProducts method. ...
3
votes
0answers
64 views

Enabling parents and dependencies of selected items recursively

I have a class Feature as such: ...
3
votes
0answers
370 views

Hackerrank: Sherlock and anagram (optimal time complexity)

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...
3
votes
0answers
1k views

Hackerrank: Sherlock and anagram

Problem statement Given a string \$S\$, find the number of "unordered anagrammatic pairs" of substrings. Input Format First line contains \$T\$, the number of testcases. Each testcase ...