Skip to content

Instantly share code, notes, and snippets.

View lindexi's full-sized avatar

lindexi lindexi

View GitHub Profile
using System;
using System.Diagnostics.CodeAnalysis;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
namespace Common
{
/// <summary>
@lindexi
lindexi / unix timestamp to DateTime.cs
Last active June 21, 2017 01:19
json unix timestamp to dateTime
public class UnixConvert : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var time = ToUnixTimestamp((DateTime) value);
writer.WriteValue(time);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
public class GitControl
{
public GitControl(string fileDirectory)
{
FileDirectory = fileDirectory;
}
/// <summary>
/// git的文件夹
/// </summary>
@lindexi
lindexi / WildcardRegexString
Last active February 8, 2017 06:25
通配符转正则 Wildcard to Regex
public static class WildcardRegexString
{
/// <summary>
/// 通配符转正则
/// </summary>
/// <param name="wildcardStr"></param>
/// <returns></returns>
public static string GetWildcardRegexString(string wildcardStr)
{
Regex replace = //new Regex("[.$^{\\[(|)*+?\\\\]");
@lindexi
lindexi / GetAlltheFileInCsproj
Last active January 10, 2017 04:03
Uwp 获取csproj 所有文件,并获取文件生成选项. Uwp Get all the files in the *.csproj.
/// <summary>
/// 获取csproj 所有文件,并获取文件生成选项
/// Get all the files in the *.csproj
/// </summary>
/// <param name="doc">csproj 文件的XDocument</param>
/// <returns>
/// 文件路径和文件生成选项列表
/// The List that include the file path and it's compile options
/// </returns>
public static List<PrjFile> GetPrjFile(XDocument doc)
@lindexi
lindexi / uwp PasswordBoxHelper
Created December 20, 2016 10:59
Binding PasswordBox
public static class PasswordBoxHelper
{
public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached(
"Password", typeof(string), typeof(PasswordBoxHelper), new PropertyMetadata(default(string),OnPasswordPropertyChanged));
public static void SetPassword(DependencyObject element, string value)
{
element.SetValue(PasswordProperty, value);
}
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
});
/// <summary>
/// 判断私有ip
/// </summary>
/// <param name="myIPAddress"></param>
/// <returns></returns>
public static bool IsPrivateIP(IPAddress myIPAddress)
{
if (IPAddress.IsLoopback(myIPAddress))
{
public static string Md5(string str)
{
HashAlgorithmProvider hashAlgorithm =
HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
CryptographicHash cryptographic = hashAlgorithm.CreateHash();
IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf8);
cryptographic.Append(buffer);
public static class ImageStorage
{
/// <summary>
/// 获取图片
/// 如果本地存在,就获取本地
/// 如果本地不存在,获取网络
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
public static async Task<BitmapImage> GetImage(Uri uri)