This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CreateEdit.cshtml | |
@using (Html.BeginForm("Create", "Licenses", FormMethod.Post, new {role = "form"})) | |
{ | |
@Html.AntiForgeryToken() | |
@Html.ValidationSummary(true, "", new {@class = "text-danger"}) | |
@Html.HiddenFor(m => m.App.Id) | |
<fieldset> | |
<legend>Constraints</legend> | |
@Html.EditorFor(m => m.Constraints.MaxInitialReleaseDateOfMinorVersion, "TextBox") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TaskExtensions | |
{ | |
public static async void ForgetAsync(this Task task) | |
{ | |
try | |
{ | |
await task.ConfigureAwait(false); | |
} | |
catch | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows; | |
using System.Windows.Controls; | |
using JetBrains.Annotations; | |
namespace Foo | |
{ | |
public class MarginSetter | |
{ | |
private static Thickness GetLastItemMargin(Panel obj) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
[ValidateAntiForgeryToken] | |
public async Task<ActionResult> Edit(EditFooVm vm) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
SaveModelState(); | |
return RedirectToAction("Edit", new {id = vm.FooId}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using JetBrains.Annotations; | |
namespace MyExtensions | |
{ | |
public static class NameValueCollectionExtensions | |
{ | |
[CanBeNull] | |
public static string GetWithEnv([NotNull] this NameValueCollection nvc, [NotNull] string name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Specialized; | |
using JetBrains.Annotations; | |
namespace MyExtensions | |
{ | |
public static class NameValueCollectionExtensions | |
{ | |
[CanBeNull] | |
public static string GetWithEnv([NotNull] this NameValueCollection nvc, [NotNull] string name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Restoring packages for 'Loggur.Uwp'. | |
Restoring packages for C:\Repos\Loggur\Loggur.Uwp\project.json... | |
Version conflict detected for System.Collections. | |
Loggur.Uwp (>= 1.0.0) -> Microsoft.AspNetCore.Hosting (>= 1.0.0-rc3-20533) -> Microsoft.AspNetCore.Http.Extensions (>= 1.0.0-rc3-20533) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0-rc3-20533) -> System.Reflection.TypeExtensions (>= 4.1.0-rc2-23931) -> System.Linq (>= 4.1.0-rc2-23931) -> System.Collections (>= 4.0.11-rc2-23931) | |
Loggur.Uwp (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-x64 (>= 1.0.0) -> System.Collections (= 4.0.10). | |
System.Console 4.0.0-rc2-23931 provides a compile-time reference assembly for System.Console on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64. | |
System.Reflection.Extensions 4.0.1-rc2-23931 provides a compile-time reference assembly for System.Reflection.Extensions on UAP,Version=v10.0, but the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Call me on startup, such as in Application_Start() of Global.asax.cs | |
private static void CreateOrMigrateDatabase() | |
{ | |
// Disable automatic migrations as it prevents us from deploying DB changes without breaking the production web instance. | |
Database.SetInitializer<ApplicationDbContext>(null); | |
var migrator = new DbMigrator(new Configuration()); | |
// Order by migration names to get oldest first, such as 201403221133523_AddSetting | |
List<string> pendingMigrations = migrator.GetPendingMigrations().OrderBy(x => x).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <remarks>Inspired by: http://stackoverflow.com/a/22135756/134761 </remarks> | |
public static class PropertyPath<TSource> | |
{ | |
public static string GetString(Expression<Func<TSource, object>> expression, string separator = ".") | |
{ | |
return string.Join(separator, GetPropertyPathSegments(expression)); | |
} | |
public static IReadOnlyList<string> GetPropertyPathSegments(Expression<Func<TSource, object>> expression) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
ElectricCurrent sourceQuantity = ElectricCurrent.Parse("8A"); | |
ElectricCurrentUnit milliAmpsUnit = ElectricCurrent.ParseUnit("mA"); | |
// 8000 | |
double milliAmps = sourceQuantity.As(milliAmpsUnit); | |
// 8,000 mA (current culture, happens to be US English on my Windows) | |
Console.WriteLine(sourceQuantity.ToString(milliAmpsUnit)); |
OlderNewer