This file contains hidden or 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.ComponentModel; | |
using System.Windows; | |
using System.Windows.Interactivity; | |
[TypeConstraint(typeof(FrameworkElement))] | |
public class UpdateTargetAction : TriggerAction<FrameworkElement> | |
{ | |
public static readonly DependencyProperty PropertyNameProperty = | |
DependencyProperty.Register(nameof(PropertyName), typeof(string), typeof(UpdateTargetAction)); |
This file contains hidden or 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.Reflection; | |
using System.Reflection.Emit; | |
public static class DynamicActivatorFactory | |
{ | |
private static readonly AssemblyBuilder AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly( | |
new AssemblyName("DynamicActivator"), | |
AssemblyBuilderAccess.Run); |
This file contains hidden or 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
<Window x:Class="WpfApp.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:local="clr-namespace:WpfApp" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="350" Width="525"> | |
<StackPanel> | |
<Label Content="{Binding Path=Content.(local:ViewProperty.Title), Mode=OneWay, Source={x:Reference Container}}"/> |
This file contains hidden or 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 unsafe byte[] Fill(this byte[] array, int offset, int length, byte value) | |
{ | |
if ((length <= 0) || (array == null)) | |
{ | |
return array; | |
} | |
fixed (byte* pSrc = &array[offset]) | |
{ | |
*pSrc = value; |
This file contains hidden or 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 class LowercaseControllerModelConvention : IControllerModelConvention | |
{ | |
public void Apply(ControllerModel controller) | |
{ | |
controller.ControllerName = controller.ControllerName.ToLower(); | |
foreach (var action in controller.Actions) | |
{ | |
action.ActionName = action.ActionName.ToLower(); | |
} | |
} |
This file contains hidden or 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
// Good | |
public static async Task<T> UseTemporary<T>(Func<string, Task<T>> func) | |
{ | |
var path = Path.GetTempFileName(); | |
try | |
{ | |
return await func(path); | |
} | |
finally | |
{ |
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using BenchmarkDotNet.Attributes; | |
[Config(typeof(BenchmarkConfig))] | |
public class ConvertEnumerableBenchmark | |
{ |
This file contains hidden or 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; | |
public interface IPolicy | |
{ | |
string ToName(string source); | |
} | |
public sealed class DefaultPolicy : IPolicy | |
{ | |
public string ToName(string source) => source; |
This file contains hidden or 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 class AppViewModelBase<T> : ViewModelBase | |
where T : AppViewModelBase<T> | |
{ | |
public static T DesignInstance { get; } = null; // For design | |
} |
This file contains hidden or 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
############################### | |
# Core EditorConfig Options # | |
############################### | |
root = true | |
# All files | |
[*] | |
indent_style = space |
OlderNewer