C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.
1
vote
0answers
6 views
General Retry Strategy #3 with TryResult
I wanted to use the Try helper from @DmitryNogin's General Retry Strategy #2 but each attempt to implement it revealed another thing that is missing.
In my review ...
6
votes
2answers
128 views
Game of life c#
Unrelated to code:
I have only been programming for three weeks and this is my first project.
About code:
Uses preset grid.
It was all done on a single page , this I realise was a mistake and I ...
1
vote
0answers
15 views
Rest Client service generator (follow up)
GitHub Repository.
This library generates code to sent REST API requests by wrapping HttpClient and lets you operate at a higher level of abstraction. It only ...
2
votes
0answers
9 views
Auto-INSERT query for NLog
I use NLog everywhere and I really don't like writing the inserts everytime. You need to write the same variable three times: two for the insert and one for the parameter for example:
...
2
votes
1answer
32 views
Deriving classes to decorate auto-generated base class code with attributes
Background:
I am currently in the process of abstracting and refactoring out EF for Dapper with ...
6
votes
0answers
49 views
Ambient Context
What do you think about this way to make logging available across the application without passing log object around? Let’s say we have something which allows us to ...
-2
votes
0answers
19 views
Group By and Sum using Linq [on hold]
I am trying to group by UWYear (these are columns returned by the ...
5
votes
1answer
49 views
Find tags in text for replacement, my brute force solution
I have a text such as
string text = "Hi [img-2] tst[img-3] test ttteessstt grawr[img-1-800]tet";
I want to find img tags in the text and get their id (second ...
-2
votes
0answers
28 views
How to check if an exe is open or closed [on hold]
I did this code and I put in a timer in order to check if the exe is open or closed.
I create a class and put it inside and then call it after in Winforms.
Here is the code
...
1
vote
0answers
15 views
Optimize store proc performance being called in c# on array loop
I have a c# application(mvc) that allows a user to upload an excel sheet containing an account number key and amount value to be passed as parameters to a proc that then validates those records, the ...
1
vote
0answers
20 views
Server side formula computation of an Excel like client side view
One of the projects I am currently involved in requires to have a view that is similar to one in the Excel, except that most of the cells are read-only and the area is much more limited (the maximum ...
-4
votes
0answers
13 views
Create a aspx page, which of server name,user name, password [on hold]
This is vishnu, I have a query, I want to create a wizard (aspx screen) which consists of three textboxes and one drop downlist
SERVER NAME: TEXTBOX
USER ID: TEXTBOX
PASSWORD: TEXTBOX
When i ...
0
votes
2answers
35 views
Write ListItemCollection item to a file
I am using below code to write list item to a file. I want only 2 fields from the list. Is there any direct way without looping through all the items to do that? Here ...
3
votes
2answers
42 views
Basic API wrapper around a Restful service - follow-up
This is a follow up from my previous post: Basic API wrapper around a Restful service
I'm writing a basic wrapper around a restful service that returns a list of Stores. Naturally, I want to make it ...
-5
votes
0answers
30 views
C# all code paths do not return a value [on hold]
I am attempting to use the following code but get this error. My skills are very basic and it looks ok to me. Any help is greatly appreciated.
...
4
votes
2answers
84 views
LINQish command line parser
I needed to parse some command line switches from a string and I tried to do it the easy way so I just wrote this:
...
-5
votes
0answers
28 views
if condition only work one time [on hold]
Hi everyone i have a if condition but i want to implement only time , i mean if condition success only one time can be work this statements.How can i do this ? My first condition only must be work one ...
2
votes
3answers
153 views
Add ImageIndex to Treeview
As the title states. I need a different type of icon for the different nodes types. at the moment I have this hacky way of achieving that.
...
0
votes
1answer
38 views
Data paging for a forum website in Asp.Net MVC
I've struggled with this for quite some time. Today I finally wrote the following code.
The ViewModel contains an int property which later tells the view how many ...
2
votes
0answers
64 views
JSON REST client proxy generator
Trying to create something really lightweight. Sources are on GitHub.
To create a proxy we need to define an interface first, e.g.:
...
3
votes
2answers
154 views
Basic API wrapper around a Restful service
I'm writing a basic wrapper around a restful service that returns a list of Stores. I'm using RestSharp which I'm injecting into the class.
Naturally, I want to make it completely testable (that's a ...
8
votes
3answers
85 views
Representing and handling Data Sizes
In a very specific application I have, I needed the ability to easily convert between different data sizes. I.e. when I give an input of 1,048,576KiB, I needed it to say 1GiB, etc.
So, I built a <...
3
votes
1answer
120 views
Convert an image to 8-bit color
I have a function that will take an image and then return that image in 8-bit color. Almost all of the code was taken from MSDN.
The code is quite short compared to all of the other methods I've seen ...
9
votes
3answers
727 views
2
votes
0answers
22 views
Saving data to a Sharepoint list taking a long time
I inherited this code that saves data to a sharepoint list.
This method saves the data to the list.
In other parts of the application a list is presented and can be paged through.
You then select an ...
2
votes
1answer
49 views
Ensuring HttpClient can be used safely as a singleton
There has been talk recently of how we should be handling the lifetime of the System.Net.Http.HttpClient.
This article http://byterot.blogspot.co.uk/2016/07/...
3
votes
3answers
236 views
Generic WebRequest Method
I created this method to do all my WebRequests.
Generally my question is if it can be improved in any way.
As a side question, would it be better to create requests for each type separately?
...
3
votes
4answers
787 views
Billing for work using an hourly, dual, or flat rate
I asked this on Stack Overflow and got some good ideas, but was advised to post here instead. There are obviously several ways to code this, each with a drawback and a benefit.
A person works a ...
0
votes
0answers
26 views
MVVM Displaying a list of orders [closed]
I'm writing an application that will display a list of orders. I'm binding the properties ProductName, Quantity, ...
4
votes
2answers
49 views
Search for variants of keywords using LINQ
First, I'm adding words entered into a search field to an array. Then, I'm getting results from a stored procedure on SQL Server using Database First approach with Entity Framework.
Finally, for ...
2
votes
1answer
59 views
Invoke model logic in one UserControl from view-model in another UserControl without violating MVVM
I am developing WPF application keeping MVVM and using Prism. Here is simplified scheme:
I need to invoke model logic in UserControlResult when executing command ...
3
votes
1answer
82 views
General Retry Strategy #2
Previous version
Now supports async operations and cancellation.
Let’s say we copy some file using retry strategy (it might be blocked, etc.). App code comes bellow:
...
3
votes
1answer
36 views
Validation rules with support for immediate termination of processing
I am picking up a code smell from this code and I am not sure of the best way to rid myself of it.
I have a validation class that has a function that returns a list of ...
3
votes
2answers
185 views
C# Async Oauth API Wrapper Class
Two quick notes: I'm targeting 4.5, and the server already has newtownsoft's json library. I'd prefer not installing anything additional on the server.
...
9
votes
2answers
663 views
Simple C# console application to read from csv and query DB
I wrote a simple console application that reads contents from a CSV file, and using that input, checks a database table to see if the contents are within it. If there is a match, then the program will ...
-7
votes
0answers
24 views
4
votes
3answers
100 views
General Retry Strategy
Let’s say we copy some file using retry strategy (it might be blocked, etc.):
...
2
votes
1answer
83 views
Pixelate image with average cell color
I wrote a function that will pixelate an image using the average color of each 4x4 cell.
The function will "split" the image into 4x4 cells, and find the average color of each pixel in the 4x4 cell, ...
1
vote
1answer
42 views
Gabor filter implementation
I have implemented the Gabor Filter of which I provided the source code as bellow.
The code is deadly slow.
Applying the filter on a grayscale image of Lena 512x<...
6
votes
3answers
161 views
Get a value from a list in Sharepoint 2010
I am using SharePoint 2010 and get values from a list using the code below.
It might be called like this: ...
4
votes
2answers
58 views
X12 Reader (C#) Performance
Is there any way that I can improve the performance of my x12_reader? The main functions that seem to be the bottlenecks are ...
2
votes
2answers
48 views
Load/Save application sessions
I'm working on load/save application sessions functionality, and came up with this code:
...
2
votes
1answer
30 views
Pass logger dependency to PostSharp aspect
I'm trying to pass my logger to a Logging Aspect that I've created with PostSharp. I have one logger per job run (because I need to send each job's logs to different folders), each job runs in ...
1
vote
0answers
31 views
Node map builder for trees
I've been building a tree from a flat collection recently in this question (Re)Creating a tree from a flat collection (or “unflatten” a tree).
It turned out very soon that this wasn't enough because ...
-1
votes
0answers
25 views
Xpath to TreeView and Multiply A Node List of an XML File [closed]
I am trying to generate a tree view of an XML file. However, I am not quite there yet but close.
I just want the tree to show the name of the node and nothing else. but I am getting all sorts of ...
1
vote
0answers
26 views
Connecting to an MS Access database (OleDB) with multiple users
I'm writing C# applications that store their data in MS Access databases, (I'd rather use a different type of database but currently have no other option).
The applications are in use by multiple ...
3
votes
2answers
60 views
Weather forecast printing
I receive a weather forecast for 5 days, but in 3 hours intervals.
This classes represent the weather forecast:
...
-1
votes
1answer
77 views
Can I make this C# code any faster? [closed]
Is there any way that I can make these two functions faster. I call these functions millions of times from my application.
...
2
votes
1answer
59 views
Resository Pattern and Unit of Work with ADO.net
I am trying to implement the Repository Pattern with a Unit of work but i dont know if i am on the right direction. This is my Model
...
11
votes
3answers
1k views
Building car factory with custom features per car
I was once asked in an interview to build a factory that makes cars.
All cars has common features like price, rating and color and they have some features like fuel injection which can on specific car ...