public static ExtensionDeclaration FromXElement(XElement elem, ModuleDeclaration module) { var decl = new ExtensionDeclaration(); decl.Module = module; decl.ExtensionOnTypeName = (string)elem.Attribute("onType"); if (elem.Element("members") != null) { var members = from mem in elem.Element("members").Elements() select Member.FromXElement(mem, module, null) as Member; decl.Members.AddRange(members); foreach (var member in decl.Members) { member.ParentExtension = decl; } } if (elem.Element("inherits") != null) { var inherits = from inherit in elem.Element("inherits").Elements() select SwiftReflector.SwiftXmlReflection.Inheritance.FromXElement(inherit) as Inheritance; decl.Inheritance.AddRange(inherits); } return(decl); }
public ExtensionDeclaration(ExtensionDeclaration other) : this() { Inheritance.AddRange(other.Inheritance); Members.AddRange(other.Members); ExtensionOnTypeName = other.ExtensionOnTypeName; Module = other.Module; }
public static ModuleDeclaration FromXElement(XElement elem) { ModuleDeclaration decl = new ModuleDeclaration { Name = (string)elem.Attribute("name"), SwiftCompilerVersion = new Version((string)elem.Attribute("swiftVersion") ?? "3.1") }; // non extensions foreach (var child in elem.Elements()) { if (child.Name == "extension") { decl.Extensions.Add(ExtensionDeclaration.FromXElement(child, decl)); } else { decl.Declarations.Add(BaseDeclaration.FromXElement(child, decl, null)); } } return(decl); }