Exemplo n.º 1
0
        /// <summary>
        /// Populates already <see cref="Construct(SerializeNode)"/>-ed <see cref="SerializeNode"/>s using the available <see cref="Consumers"/>, from the bottom of the graph upwards.
        /// </summary>
        /// <param name="startNode"></param>
        private void Populate(SerializeNode startNode)
        {
            if (!populating.Contains(startNode))
            {
                try
                {
                    populating.Add(startNode);
                    if (dependencyMap.ContainsKey(startNode) &&
                        dependencyMap[startNode].Any())
                    {
                        foreach (var dep in dependencyMap[startNode])
                        {
                            Populate(dep.EndNode);
                        }

                        //// Populate all remaining dependencies.
                        Consumers.PopulateObject(
                            startNode.Value,
                            dependencyMap[startNode].ToDictionary(d => d.DependencyId, d => d.EndNode.Value));

                        dependencyMap[startNode].Clear();
                    }
                }
                catch (Exception ex)
                {
                    throw new SerializationException($"Populating {GetPath(startNode)} failed.", ex);
                }
            }
        }