public DataCenter(DataCenterRaw lowLevel) { _strings = lowLevel.Strings.CollectionToDictionary(x => x.Key, x => x.Value); _names = new[] { "__placeholder__" }.Concat(lowLevel.Names.Select(x => x.Value)).ToArray(); _values = new SegmentAddressDictionary<DataCenterValueRaw>(lowLevel.Values, lowLevel.Values.Last().Key); _elements = new SegmentAddressDictionary<DataCenterElementRaw>(lowLevel.Elements, lowLevel.Elements.Last().Key); Revision = lowLevel.Revision; var referencedObjects = _elements.Values.SelectMany(x => x.SubAddresses()); if (!_elements.Keys.Except(referencedObjects).ToList().SequenceEqual(new[] { new SegmentAddress() })) throw new Exception("Only the first object should be unreferenced"); }
public DataCenter(DataCenterRaw lowLevel) { _strings = lowLevel.Strings.CollectionToDictionary(x => x.Key, x => x.Value); _names = new[] { "__placeholder__" }.Concat(lowLevel.Names.Select(x => x.Value)).ToArray(); _values = new SegmentAddressDictionary <DataCenterValueRaw>(lowLevel.Values, lowLevel.Values.Last().Key); _elements = new SegmentAddressDictionary <DataCenterElementRaw>(lowLevel.Elements, lowLevel.Elements.Last().Key); Revision = lowLevel.Revision; var referencedObjects = _elements.Values.SelectMany(x => x.SubAddresses()); if (!_elements.Keys.Except(referencedObjects).ToList().SequenceEqual(new[] { new SegmentAddress() })) { throw new Exception("Only the first object should be unreferenced"); } }