Skip to content

Instantly share code, notes, and snippets.

View liulixiang1988's full-sized avatar

Lixiang Liu liulixiang1988

View GitHub Profile
//http://stackoverflow.com/questions/852181/c-printing-all-properties-of-an-object
foreach(PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj))
{
string name=descriptor.Name;
object value=descriptor.GetValue(obj);
Console.WriteLine("{0}={1}",name,value);
}
@liulixiang1988
liulixiang1988 / FileHelper.cs
Created December 10, 2014 00:54
C#-FileHelper
public class FileHelper
{
/// <summary>
/// 返回文件扩展名
/// </summary>
public static string GetExtension(string path)
{
return Path.GetExtension(path);
}
@liulixiang1988
liulixiang1988 / Config.cs
Created December 10, 2014 01:02
C# Config
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using Newtonsoft.Json;
namespace Liulx.Util
{
public class Config: INotifyPropertyChanged
{
@liulixiang1988
liulixiang1988 / Log.cs
Created December 10, 2014 01:05
C# Log.cs
using System;
using System.Collections.Concurrent;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Liulx.Util
{
public class Log
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
using Nancy.Responses;
using Nancy.Responses.Negotiation;
namespace ByteArrayDemo
{
using System;
using System.Collections.Generic;
namespace MimeTypes
{
public static class MimeTypeMap
{
private static readonly IDictionary<string, string> _mappings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) {
#region Big freaking list of mime types
using System;
using System.Security.Cryptography;
using System.Text;
namespace MD5Sample
{
class Program
{
static void Main(string[] args)
{
@liulixiang1988
liulixiang1988 / CalculateMd5.cs
Created May 12, 2015 02:55
Calculate File's Md5 计算文件的MD5
//It's very simple:
using (var md5 = MD5.Create())
{
using (var stream = File.OpenRead(filename))
{
return md5.ComputeHash(stream);
}
}
//(I believe that actually the MD5 implementation used doesn't need to be disposed, but I'd probably still do so anyway.)
public HttpResponseMessage Post(string version, string environment, string filetype)
{
var path = @"C:\Temp\test.exe";
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
var stream = new FileStream(path, FileMode.Open);
result.Content = new StreamContent(stream);
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>