public Component Generate(string name, bool isExecute) { Thread.Sleep(100); var rnd = new Random(); var currentComponent = new Component(name, isExecute) { Roles = new string[rnd.Next(1, ComponentRolesMaxCount)], Dependencies = new string[rnd.Next(isExecute ? 1 : 0, ComponentDependenciesMaxCount)] }; if (isExecute) { currentComponent.Roles = null; } else { for (var i = 0; i < currentComponent.Roles.Length; i++) { currentComponent.Roles[i] = "R" + rnd.Next(RolesCount); } } for (var i = 0; i < currentComponent.Dependencies.Length; i++) { currentComponent.Dependencies[i] = "R" + rnd.Next(i, RolesCount); } Console.WriteLine(currentComponent.Name + " Complete"); return currentComponent; }
private void FindDependencies(Component instruction, ref Schema schema) { var dependencies = instruction.Dependencies; foreach (var dependency in dependencies) { var componentTo = FindComponent(dependency); schema.Components.Add(componentTo.Name); schema.AddConnection(instruction.Name, dependency, componentTo.Name); FindDependencies(componentTo, ref schema); } }
public static void SimpleResolved(Component instruction, ref Schema schema) { var dependencies = instruction.Dependencies; foreach (var dependency in dependencies) { var componentTo = FindComponent(dependency); schema.Components.Add(componentTo.Name); schema.AddConnection(instruction.Name, dependency, componentTo.Name); SimpleResolved(componentTo, ref schema); } }