Skip to content

Instantly share code, notes, and snippets.

@rpgmaker
rpgmaker / gist:3123280
Created July 16, 2012 15:17
Initial XmlSerializer Generator
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
using System.IO;
@rpgmaker
rpgmaker / gist:3123301
Created July 16, 2012 15:22
C# Code for XmlSerializer Generator
public static string Serialize<T>(T obj) {
var sb = new StringBuilder(DEFAULT_SB_CAPACITY);
using (var writer = XmlWriter.Create(sb,
new XmlWriterSettings() { OmitXmlDeclaration = true })) {
WriteObject(obj, Normalize(obj.GetType().Name), writer);
writer.Flush();
return sb.ToString();
}
}
@rpgmaker
rpgmaker / gist:3136941
Created July 18, 2012 15:30
XmlSerializer Generator (Contain Serialize logic, missing deserialize logic)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
using System.IO;
using System.Collections;
@rpgmaker
rpgmaker / gist:3140937
Created July 19, 2012 05:21
XmlSerializer Generator (Everything(include deserialize classes with properties) work except for Deserializing List/Dictionary/Array
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Concurrent;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
using System.IO;
using System.Collections;
@rpgmaker
rpgmaker / gist:3170276
Created July 24, 2012 14:35
XmlSerializer Generator (Final - I think)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
namespace PServiceBus.Serializer.Xml {
@rpgmaker
rpgmaker / gist:3172264
Created July 24, 2012 20:02
StringBuilder vs XmlWriter Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Xml;
namespace SbVsXmlWriter {
class Program {
@rpgmaker
rpgmaker / gist:3183199
Created July 26, 2012 16:55
XmlSerializer Generator (Almost Final)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
using System.Xml;
namespace PServiceBus.Serializer.Xml {
@rpgmaker
rpgmaker / gist:3205192
Created July 30, 2012 05:56
XmlReaderEx (Initial Draft)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace PServiceBus.Serializer.Xml {
public unsafe class XmlReaderEx : IDisposable {
@rpgmaker
rpgmaker / gist:3213638
Created July 31, 2012 04:32
XmlReaderEx (Working Draft)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace PServiceBus.Serializer.Xml {
public unsafe class XmlReaderEx : IDisposable {
@rpgmaker
rpgmaker / gist:3217778
Created July 31, 2012 15:22
Test Similar Loops
static void DoSomething() {
while (true) {
var id = _rand.Next();
if (id == 0) break;
if (id > 1) {
id += 1;
Console.Write(id);
break;
}
}