public Variable(XElement xml, LinkPackage parent) { Parent = parent; Name = xml.AttributeValueOrDefault("name"); DefaultValue = xml.AttributeValueOrDefault("default-value"); }
protected Path(XElement xml, LinkPackage root, IPathParent parent) { LinkPackage = root; Parent = parent; Name = xml.AttributeValueOrDefault("name"); Id = xml.AttributeValueOrDefault("id"); Paths = xml.Elements().Select(x => Path.Construct(x, root, this)).ToArray(); }
public static Path Construct(XElement xml, LinkPackage root, IPathParent parent) { var name = xml.Name.ToString(); switch (name) { case VariablePath.ElementName: return new VariablePath(xml, root, parent); case DirectoryPath.ElementName: return new DirectoryPath(xml, root, parent); case FilePath.ElementName: return new FilePath(xml, root, parent); default: throw new ArgumentException("Unknown Path element: " + xml); } }
public static LinkPackage LoadFromFile(string fileName, Action<string> showErrorMessage = null) { try { var startTime = DateTime.Now.Ticks; Debug.WriteLine("Started loading LinkPackage at " + startTime); var doc = XDocument.Load(fileName); var root = doc.Root; if (root == null || root.Name != ElementName) return null; var linkPackage = new LinkPackage(root, fileName); var endTime = DateTime.Now.Ticks; Debug.WriteLine(string.Format("Finished loading LinkPackage at {0} -- took {1}", endTime, endTime - startTime)); return linkPackage; } catch (Exception ex) { Debug.WriteLine("Exception in LinkPackage.LoadFromFile"); Debug.WriteLine(ex.ToString()); if (showErrorMessage != null) showErrorMessage(ex.Message); return null; } }
public VariablePath(XElement xml, LinkPackage root, IPathParent parent) : base(xml, root, parent) { }
public Link(XElement xml, LinkPackage linkPackage) { LinkId = xml.AttributeValueOrDefault("link-id"); TargetId = xml.AttributeValueOrDefault("target-id"); LinkPackage = linkPackage; }
public DirectoryPath(XElement xml, LinkPackage root, IPathParent parent) : base(xml, root, parent) { }