// Return the TypeDeclaration instance associated with a given XML type declaration, // or a newly created one that is added to the dictionary if it doesn't exist private static TypeDeclaration GetInstance(XElement elem, Container <Declaration> super, TypeScriptDefContext context) { Type typeDeclarationClass = TypeDeclaration.GetClass(elem); string typeDeclarationName = TypeDeclaration.GetFullName(elem); try { var inst = TypeDeclaration.Instances[typeDeclarationName]; // We update the declaration's Super if it wasn't specified previously // (needed for type declarations instanciated because of a variable of that type) if (inst.Super == null) { inst.Super = super; } return(inst); } catch (KeyNotFoundException) { var inst = (TypeDeclaration)Activator.CreateInstance(typeDeclarationClass, elem, super, context); TypeDeclaration.Instances[typeDeclarationName] = inst; // We add content after updating the dictionary to avoid cycles // when declarations refer to their ancestors if (inst is Container <Declaration> ) { ((Container <Declaration>)inst).AddContent(elem, context); } return(inst); } }
public TypeDeclaration(XElement elem, Container <Declaration> super, TypeScriptDefContext context) : this(super) { ((TSType)this).Name = TypeDeclaration.GetFullName(elem); }