Created
March 14, 2015 00:49
-
-
Save stdray/dfbf05b8f3f64f6457cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def makeDeserializer(types) | |
| { | |
| def mapRef = <[ $("map" : usesite)]>; | |
| def mapExprs = types.Map(t => <[ $mapRef.Add($(t.Name), typeof($(ExpandFullName(t.FullName)))); ]>); | |
| <[decl: | |
| public module Deserializer | |
| { | |
| private map : Lazy[Dictionary[string, Type]] = Lazy(getMap, System.Threading.LazyThreadSafetyMode.PublicationOnly); | |
| private getMap() : Dictionary[string, Type] | |
| { | |
| def $mapRef = Dictionary(); | |
| {..$mapExprs} | |
| $mapRef | |
| } | |
| public Deserialize(name : string, content : System.Xml.Linq.XDocument) : object | |
| { | |
| XmlHelper.XDeserialize(content, map.Value[name]); | |
| } | |
| public DeserializeDocument(content : System.Xml.Linq.XDocument) : object | |
| { | |
| Deserialize(content.Root.Name.LocalName, content); | |
| } | |
| } | |
| ]> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment