Skip to content

Instantly share code, notes, and snippets.

View poulfoged's full-sized avatar

Poul Foged Nielsen poulfoged

View GitHub Profile
alert('ja')
@poulfoged
poulfoged / designer.html
Last active August 29, 2015 14:17
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-ajax/core-ajax.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
internal static class ReflectiveEnumerator
{
public static IEnumerable<Type> GetEnumerableOfType<T>() where T : class
{
var objects = Assembly
.GetAssembly(typeof (T))
.GetTypes()
.Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof (T)))
.ToList();
internal class TemporaryFile : IDisposable
{
private readonly FileInfo _fileInfo;
private bool _disposed;
public TemporaryFile(string extension = "tmp")
{
_fileInfo = CreateFilename(extension);
}
internal class TemporaryDirectory : IDisposable
{
private readonly DirectoryInfo _directoryInfo;
private bool _disposed;
public TemporaryDirectory()
{
_directoryInfo = new DirectoryInfo(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N")));
_directoryInfo.Create();
}
public class StreamFormatter : MediaTypeFormatter
{
private readonly MediaTypeHeaderValue _mediaType;
/// <summary>
/// Default constructor
/// </summary>
/// <param name="mediaType"></param>
public StreamFormatter(MediaTypeHeaderValue mediaType)
{
internal static class StringExtensions
{
public static string ReplaceCaseInsensitive(this string source, object replacements)
{
replacements
.GetType()
.GetProperties()
.Select(p => new {p.Name, Value = p.GetValue(replacements) as string ?? ""})
.ToList()
.ForEach(p => { source = ReplaceCaseInsensitive(source, string.Format("{{{0}}}", p.Name), p.Value); });
internal class ShortNameSerializationBinder<TBase> : DefaultSerializationBinder where TBase : class
{
private static Dictionary<string, Type> types;
public ShortNameSerializationBinder()
{
types = ReflectiveEnumerator.GetEnumerableOfType<TBase>().ToDictionary(i => i.Name, i => i);
}
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
using System.IO;
namespace Streams
{
/// <summary>
/// Just a basis class that makes it easy to overwrite what you want
/// </summary>
public abstract class StreamDecoratorBase : Stream
{
/// <summary>