ASP.NET Core - Create custom model validation
In previous versions of ASP.NET MVC the way to add custom validation to your model was by implementing the `IValidatableObject` and implementing your own `Validate()` method. Here's what I have implem...
- Modified
- 14 Mar at 21:20
How to use Data Annotations to validate a nullable int
In an MVC 5 project, I have a model with a nullable int. For reasons that might not be productive to explain, it needs to be an nullable int and cannot be a string. ``` // Value can be null or an int...
- Modified
- 12 Jul at 14:44
Type.IsEnum Property in Portable Class Library
I'm trying to code in a `Portable Class Library` using `ASP.NET Core 1.0`, the following instruction: ``` public static void WriteMessage<T>(T value) { if (typeof(T).IsEnum) { Debug....
- Modified
- 12 Jul at 11:52
C# emulate HID clicker bluetooth
I need some guidance on how or whether this is possible to achieve without a "server" application running on the pc. I have gotten as far as establishing a bluetooth connection to the PC, I would like...
- Modified
- 7 Jan at 02:16
Why click tree throws 'System.Windows.Documents.Run' is not a Visual or Visual3D' InvalidOperationException?
Sometimes right-clicking treeviewitem results unhandled InvalidOperationException. In code behind I select the right clicked row: ``` static TreeViewItem VisualUpwardSearch(DependencyObject source) ...
- Modified
- 12 Jul at 09:39
error TS2339: Property 'x' does not exist on type 'Y'
I don't understand why this code generates a TypeScript error. (It's not the original code and is a bit derived, so please ignore the non-sense in the example): ``` interface Images { [key:string]: ...
- Modified
- 9 Feb at 19:59
How to add claims in a mock ClaimsPrincipal
I am trying to unit test my controller code which gets the information from the ClaimsPrincipal.Current. In the controller code I ``` public class HomeController { public ActionResult GetName() ...
- Modified
- 12 Jul at 08:41
Error: EACCES: permission denied
I run but it throws error. I know it is permission issue but as far as I know, sudo permission is not required for installing node module locally. If I run it with sudo, it gets installed inside ~/n...
Which members of .NET's ConcurrentDictionary are thread-safe?
The MSDN documentation of [System.Collections.Concurrent.ConcurrentDictionary](https://msdn.microsoft.com/en-us/library/dd287191(v=vs.110).aspx) says: > # Thread Safety All public and protected mem...
- Modified
- 12 Jul at 07:54
Why can't I put [assembly:Dependency()] above a class?
I'm trying to implement some platform-specific code in Xamarin, using [this answer](https://stackoverflow.com/questions/28688133/how-to-call-platform-specific-page-from-xamarin-forms), but I ran into ...
- Modified
- 23 May at 11:46
How to I set the Connection : Keep-Alive header to Close in the JsonServiceClient?
On occasion (not consistently), I'm receiving a "" exception thrown by an instance of the JsonServiceClient. I want to set the Http Connection Header to Close. When I attempt "" exception.
- Modified
- 12 Jul at 01:28
Mock IMemoryCache in unit test
I am using asp net core 1.0 and xunit. I am trying to write a unit test for some code that uses `IMemoryCache`. However whenever I try to set a value in the `IMemoryCache` I get an Null reference err...
- Modified
- 2 Feb at 12:54
Compiler Bug when using ?. resulting in a Bad Image that fails PEVerify
I stumbled across something odd: I got a `BadImageFormatException` without knowing what image (assembly) it could possibly refer to. I reduced the solution so that it consists only of a single projec...
- Modified
- 11 Jul at 22:30
Replace parameter type in lambda expression
I am trying to replace the parameter type in a lambda expression from one type to another. I have found other answers on stackoverflow i.e. [this one](https://stackoverflow.com/questions/11159697/rep...
- Modified
- 23 May at 12:32
Use a Identity 2.0 Database to Authenticate a ASP.NET Core 1.0 application
I am trying to a create a new ASP.NET Core 1.0 web application and I want it to use the Authentication tables that I already have set up. These tables were originally created by a ASP.NET 4.6 web app...
- Modified
- 12 Jul at 15:5
"OverflowError: Python int too large to convert to C long" on windows but not mac
I am running the exact same code on both windows and mac, with python 3.5 64 bit. On windows, it looks like this: ``` >>> import numpy as np >>> preds = np.zeros((1, 3), dtype=int) >>> p = [6802256...
- Modified
- 11 Jul at 18:51
Can a string-based Include alternative be created in Entity Framework Core?
On an API I need dynamic include, but EF Core does not support string-based include. Because of this, I created a mapper which maps strings to lambda expressions added to a list as: ``` List<List<Expr...
- Modified
- 4 Jun at 15:57
How to handle currentDomain.UnhandledException in MSTest
I tried to implement solution based on answer [How to handle exceptions raised in other threads when unit testing?](https://stackoverflow.com/a/934604/518530), but I still don't understand what to do ...
- Modified
- 23 May at 11:53
Akka.NET cluster node graceful shutdown
## Background I have a Akka.NET cluster containing a Lighthouse seed node and two other nodes running actor systems. When I attempt to do a graceful shutdown on one of my cluster nodes I want to se...
- Modified
- 27 May at 09:26
What does IAppbuilder.UseWebApi do?
I've recently been working on an MVC site that has an api and in the startup.cs there is a line that says `app.UseWebApi`. I did some searching but I couldn't find a decent answer of what it does. Can...
- Modified
- 11 Jul at 14:0
How to get normal/custom error response for an exception from an Action returning Stream in ServiceStack?
I have been venturing in the ServiceStack's [documentation](https://github.com/ServiceStack/ServiceStack/wiki/Error-Handling) regarding an issue with throwing from an Action that returns a . The iss...
- Modified
- 12 Jul at 06:45
How to implement nhibernate session per request pattern, using Service stack's funq container as a dependency injector
I am getting the session by injecting session to service method in global.asax as 1 ``` protected void Application_Start() { this.RegisterContainer(); } ``` 2 ``` private void RegisterCont...
- Modified
- 11 Jul at 13:31
How to use the new IValueResolver of AutoMapper?
I am at a loss as to how to use the new `IValueResolver` interface in the new version of AutoMapper. Perhaps I used them improperly in the previous versions of AutoMapper... I have a lot of model cla...
- Modified
- 15 Aug at 10:54
What happens when awaiting on already-completed task?
When I construct an instance of a class that I have, I would like to trigger a Token renewal function (`async` method) and let it run in the background (I keep a reference to the returned `Task`). La...
- Modified
- 11 Jul at 12:1