 
             let nodeParser = self.parser.resolve(SpectraXMLNodeParser.self, arguments: (tag, key, child, options))!
             
-            // TODO: resolve custom types
-            //            parser.resolve(AnyClass.self, name: self.rawValue)
+            let result = nodeParser(container: container, node: child, key: key, options: options)
+//            let mirror = Mirror(result)
+
+            //TODO: use .dynamicType for meta type at run time
+            // - nvm, "auto-injection" feature won't be in swinject until 2.0.0
             
-            let (nodeResult, klass, meta) = nodeParser(container: container, node: child, key: key, options: options)
-//            let klass: AnyClass = meta["klass"]!
-            let finalResult = nodeResult as klass
             
+            let resultKlass = SpectraXMLNodeType(rawValue: tag)!.nodeFinalType(parser)!
+//            container.register(result.dynamicType, name: tag) { _ in
+//                return result
+//            }
             
             // TODO: use options to set ObjectScope (default to .Container?)
             

import Swinject
import ModelIO

public typealias SpectraXMLNodeTuple = (construct: Any, meta: [String: Any])
// meta is used when the construct returns a monad
// meta should include a function at key: resolve
// - the function should be expected to receive itself as args
// - i.e. meta["resolve"](meta) should resolve to a function to which it can pass the construct function
// - i.e. meta["resolve"](meta)(construct) should return a final object

// meta keys could also include the following for casting:
// - klass: AnyClass?, strukt: Any?, protokol: Any?

// should it be necessary to pass the key here?
public typealias SpectraXMLNodeParser = ((container: Container, node: XMLElement, key: String?, options: [String: Any]) -> SpectraXMLNodeTuple)

public enum SpectraXMLNodeType: String {
    case World = "world"

    case TextureSampler = "texture-sampler"
    case Light = "light"
    
    public func nodeParser(node: XMLElement, key: String, options: [String: Any] = [:]) -> SpectraXMLNodeParser? {
        
        switch self {
        case .World:
            return {(container, node, key, options) in
                return "a world"
            }
        case .Camera:
            return {(container, node, key, options) in
                return "a camera"
            }
        case .VertexAttribute:
            return {(container, node, key, options) in
                let vertexAttr = SpectraXMLVertexAttributeNode().parse(container, elem: node, options: options)
                return vertexAttr
            }
        case .VertexDescriptor:
            return {(container, node, key, options) in
                let vertexDesc = SpectraXMLVertexDescriptorNode().parse(container, elem: node, options: options)
                return vertexDesc
            }
        default: return nil
        }
