Skip to content

Instantly share code, notes, and snippets.

View lindexi's full-sized avatar

lindexi lindexi

View GitHub Profile
@lindexi
lindexi / xml
Created November 24, 2016 14:25
/// <summary>
/// Uses the local list of accounts and returns an XML formatted string representing the list
/// </summary>
/// <returns>XML formatted list of accounts</returns>
public static string SerializeAccountListToXml()
{
XmlSerializer xmlizer = new XmlSerializer(typeof(List<Account>));
StringWriter writer = new StringWriter();
xmlizer.Serialize(writer, AccountList);
// 在用户完成更改并调用CompleteUpdatesAsync之前,阻止对文件的更新
// Before User finished the file Update and call the CompleteUpdatesAsync,it can prevent other updates the file.
CachedFileManager.DeferUpdates(storageFile);
//当完成更改时,其他应用程序才可以对该文件进行更改。
// When the update is complete,the other can update the file
FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(storageFile);
public static class ImageStorage
{
/// <summary>
/// 获取图片
/// 如果本地存在,就获取本地
/// 如果本地不存在,获取网络
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
public static async Task<BitmapImage> GetImage(Uri uri)
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);
/// <summary>
/// 判断私有ip
/// </summary>
/// <param name="myIPAddress"></param>
/// <returns></returns>
public static bool IsPrivateIP(IPAddress myIPAddress)
{
if (IPAddress.IsLoopback(myIPAddress))
{
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
});
@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);
}
@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 / 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("[.$^{\\[(|)*+?\\\\]");
public class GitControl
{
public GitControl(string fileDirectory)
{
FileDirectory = fileDirectory;
}
/// <summary>
/// git的文件夹
/// </summary>