public static void ParseFacts(XDocument report, Instance instance) { var factElements = FindFacts(report); var facts = new FactCollection(instance); foreach (var factElement in factElements) { var name = factElement.Attribute("name").Value; var prefix = name.Split(':').First(); var ns = report.Root.GetNamespaceOfPrefix(prefix).ToString(); var unitRef = factElement.Attribute("unitRef")?.Value; var decimals = factElement.Attribute("decimals")?.Value; var value = factElement.Value; var scale = factElement.Attribute("scale")?.Value; if (!string.IsNullOrWhiteSpace(scale)) { var power = int.Parse(scale); var v = decimal.Parse(value.Replace(" ", "")); var multiplier = (decimal)Math.Pow(10, power); v *= multiplier; value = v.ToString(); } var contextRef = factElement.Attribute("contextRef").Value; var fact = new Fact(name, ns, unitRef, decimals, contextRef, value); facts.Add(fact); } foreach (var fact in facts) { instance.Facts.Add(fact); } }
private void AddFacts(IEnumerable <IFact> facts) { foreach (var fact in facts) { var item = (TElement)fact.Value; _items.Add(item); } }