Questions

Mock.Of<Object> VS Mock<Object>()

I'm currently confuse on how to mock. I'm using Moq. To mock objects I usually write this way ``` var mockIRepo = new Mock<IRepo>(); ``` However, I need to create mock object for my setup. Is it...

5 May at 04:53

async/await and opening a FileStream?

I came across the following question when trying to determine if I was using the `Stream` methods such as `ReadAsync` and `CopyToAsync` correctly: [C# 4.5 file read performance sync vs async](https://...

23 May at 12:8

Null conditional operator to "nullify" array element existence

The new C# 6.0 null-conditional operator is a handy vehicle for writing more concise and less convoluted code. Assuming one has an array of customers, then you could get null instead of a length if `c...

C# Download all files and subdirectories through FTP

I'm still in the process of learning C#. To help myself out, I'm trying to create a program that will automatically synchronise all of my local projects with a folder on my FTP server. This so that w...

4 Nov at 20:37

Mock IAuthSession.GetOAuthTokens

I have a Service Stack Service that uses the following code ``` public MyResponse Get(MyRequest request){ var authSession = GetSession(); var tokens = authSession.GetOAuthTokens("somekey"); ...

How to remove ContentType requirement from NServiceKit request

I am trying to make a RESTful web service using NServiceKit version 1.0.43. I want this to work without an outside service that is not including a ContentType in their header request. My web service i...

4 May at 18:54

Web API Controller convert MemoryStream into StreamContent

I have a large collection of images stored on a secured server some of which need to be displayed on a world facing portal. The portal's server is inside a DMZ which allows requests in but prevents di...

24 Jun at 01:46

Best practice for constant string for implementations to use

Say I have an interface: ``` public interface IFeature { Task execFeature(); } ``` and two implementations: ``` public class FirstFeature : IFeature { private IWebApi webApi; public F...

How can I create an X509Certificate2 object from an Azure Key Vault KeyBundle

I am using Azure Key Vault to protect our keys and secrets, but I am unsure how I can use the KeyBundle I retrieve using the .net SDK. How can I create an X509Certificate2 object?

4 May at 16:17

ServiceStack RedisServerEvents must start RedisPubSub server even for a client component

[ServiceStack RedisServerEvents](https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack.Server/RedisServerEvents.cs) implementation ties the server component with the client compone...

4 May at 16:11

Adding new namespace in C# Project

I want to add a new namespace to C# project, also number of classes are to be added in that newly created namespace. When I right-click Solution of Project, I didn't find any link to add a new namesp...

7 May at 02:16

WPF - Columns don't hide properly when GridSplitter is moved

I'm trying to hide a column in a `Grid` with a `GridSplitter` when a button is clicked (the button sets the visibility of all items in the third column to collapsed). If I don't move the `GridSplitter...

4 May at 14:27

Servicestack License for Redis framework

I am using AWS Redis (Elastic Cache) for my web site, which is developed using ASP.NET MVC. To connect with Redis i am using ServiceStack.Redis framework. I have moved this to production. But unfortun...

create zip file in .net with password

I'm working on a project that I need to create zip with password protected from file content in c#. Before I've use System.IO.Compression.GZipStream for creating gzip content. Does .net have any func...

19 Jan at 07:35

ServiceStack OrmLite multiple references of same type load

In my ServiceStack app I'm implementing a simple chat where 2 users can have a dialogue. For simplicity, I've just created a TextMessages table, which contains the following Fields: ``` public class ...

ScriptingOptions sql smo does not support scripting data

I'm generating sql database script using c# code. following code works fine for `create table` but when I try to use `scriptOptions.ScriptData = true;` it is throwing following exception. > An unhan...

16 Nov at 15:50

How can I add an IEnumerable<T> to an existing ICollection<T>

Given an existing `ICollection<T>` instance (e.g. `dest`) what is the most efficient and readable way to add items from an `IEnumerable<T>`? In my use case, I have some kind of utility method `Collec...

3 May at 17:39

Column missing from excel spreedshet

I have a list of invoices that and I transferred them to an Excel spreadsheet. [](https://i.stack.imgur.com/yxQpi.png) All the columns are created into the spreadsheet except for the Job Date colum...

10 May at 14:0

What does ==$0 (double equals dollar zero) mean in Chrome Developer Tools?

In Google Chrome's developer tools, when I select an element, I see `==$0` next to the selected element. What does that mean? [](https://i.stack.imgur.com/C2eGI.jpg)

How to install only "devDependencies" using npm

I am trying to install ONLY the "devDependencies" listed in my package.json file. But none of the following commands work as I expect. All of the following commands install the production dependencies...

3 May at 08:41

How can one tell the version of React running at runtime in the browser?

Is there a way to know the runtime version of React in the browser?

3 May at 02:22

Dictionaries and Functions

I have recently begun working with C# and there is something I used to do easily in Python that I would like to achieve in C#. For example, I have a function like: ``` def my_func(): return "Do som...

3 May at 03:55

Retrieve last 100 lines logs

I need to retrieve last 100 lines of logs from the log file. I tried the sed command ``` sed -n -e '100,$p' logfilename ``` Please let me know how can I change this command to specifically retrieve...

6 Aug at 12:10

Where to find "Enable Debugging of Unmanaged Code" to be able to edit the code while the system is running?

In an older version of Visual Studio (Like the one at home, guess 2013), I am able to edit my code while the system is running but I can't continue (and I don't want to continue). While through my co...

How to unmount, unrender or remove a component, from itself in a React/Redux/Typescript notification message

I know this question has been asked a couple of times already but most of the time, the solution is to handle this in the parent, as the flow of responsibility is only descending. However, sometimes, ...

24 Jun at 05:38