Skip to content

Instantly share code, notes, and snippets.

View Konard's full-sized avatar
🖥️
Watch how I code at https://www.youtube.com/c/КонстантинДьяченко

Konstantin Dyachenko Konard

🖥️
Watch how I code at https://www.youtube.com/c/КонстантинДьяченко
View GitHub Profile
@Konard
Konard / DbCommandExtensions
Created May 8, 2013 03:03
DbCommandExtensions is a class containing extension-methods for System.Data.IDbCommand interface.
using System.Data;
namespace Helpers
{
public static class DbCommandExtensions
{
public static void AddParameter(this IDbCommand cmd, string parameterName)
{
IDbDataParameter parameter = cmd.CreateParameter();
parameter.ParameterName = parameterName;
@Konard
Konard / RuntimeHelpers
Created May 8, 2013 03:05
RuntimeHelpers is a class containing methods for doing checks at runtime.
using System;
namespace Helpers
{
public static class RuntimeHelpers
{
public static bool IsRunningOnMono()
{
return Type.GetType("Mono.Runtime") != null;
}
@Konard
Konard / ServiceControllerExtensions
Created May 8, 2013 03:06
ServiceControllerExtensions is a class containg extension-methods for System.ServiceProcess.ServiceController class.
using System.ServiceProcess;
using System.Threading;
namespace Helpers
{
public static class ServiceControllerExtensions
{
public static void StopAndWait(this ServiceController service)
{
if (service.Status != ServiceControllerStatus.Stopped)
@Konard
Konard / StringExtensions.cs
Created May 8, 2013 03:09
StringExtensions is a static class (module) containing extension-methods for System.String class.
using System;
using System.Globalization;
namespace Helpers
{
public static class StringExtensions
{
public static bool IsInt16(this string s)
{
Int16 result; return Int16.TryParse(s, out result);
@Konard
Konard / ThreadArrayExtensions.cs
Last active December 17, 2015 02:39
ThreadArrayExtensions is static class (module) containing extension-methods for System.Threading.Thread[] type.
using System;
using System.Threading;
namespace Helpers
{
public static class ThreadArrayExtensions
{
public static Thread[] StartAll(this Thread[] threads, params object[] values)
{
if (values.Length == 0)
@Konard
Konard / ThreadHelpers.cs
Created May 8, 2013 03:12
ThreadHelpers is a static class (module) containing utility methods to deal with System.Threading.Thread class.
using System.Threading;
namespace Helpers
{
public static class ThreadHelpers
{
public static Thread[] CreateThreads(ThreadStart action, int amount, int maxStackSize)
{
Thread[] threads = new Thread[amount];
for (int i = 0; i < threads.Length; i++)
@Konard
Konard / Windows8.xaml
Last active December 20, 2015 02:59
WPF default tempaltes (Windows 8 style).
<Style TargetType="{x:Type RadioButton}">
<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
Resharper suggestions
1
.Where(x => x.ErrorContent is string).Select(x => (string)x.ErrorContent)
заменять на
.Select(x => x.ErrorContent).OfType<string>()
2
xcopy $(SolutionDir)lib\CefSharp $(TargetDir) /s /y
void window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F11)
{
Window.ResizeMode = ResizeMode.NoResize;
Window.WindowState = WindowState.Normal;
Window.WindowStyle = WindowStyle.None;
Window.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;