Example #1
0
        public Variable(XElement xml, LinkPackage parent)
        {
            Parent = parent;

            Name = xml.AttributeValueOrDefault("name");
            DefaultValue = xml.AttributeValueOrDefault("default-value");
        }
Example #2
0
        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();
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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;
            }
        }
Example #5
0
 public VariablePath(XElement xml, LinkPackage root, IPathParent parent)
     : base(xml, root, parent)
 {
 }
Example #6
0
 public Link(XElement xml, LinkPackage linkPackage)
 {
     LinkId = xml.AttributeValueOrDefault("link-id");
     TargetId = xml.AttributeValueOrDefault("target-id");
     LinkPackage = linkPackage;
 }
Example #7
0
 public DirectoryPath(XElement xml, LinkPackage root, IPathParent parent)
     : base(xml, root, parent)
 {
 }