diff --git a/Components/RulesCollect.cs b/Components/RulesCollect.cs index 3f476ff..b2981da 100644 --- a/Components/RulesCollect.cs +++ b/Components/RulesCollect.cs @@ -112,7 +112,8 @@ protected override void SolveInstance(IGH_DataAccess DA) { var allowedExplicit = allowedOriginalClean .Where(rule => rule.IsExplicit) - .Select(rule => rule.Explicit); + .Select(rule => rule.Explicit) + .ToList(); var allowedTyped = allowedOriginalClean .Where(rule => rule.IsTyped) .Select(rule => rule.Typed); @@ -123,7 +124,8 @@ protected override void SolveInstance(IGH_DataAccess DA) { var disallowedExplicit = disallowedOriginalClean .Where(rule => rule.IsExplicit) - .Select(rule => rule.Explicit); + .Select(rule => rule.Explicit) + .ToList(); var disallowedTyped = disallowedOriginalClean .Where(rule => rule.IsTyped) .Select(rule => rule.Typed); @@ -150,9 +152,7 @@ protected override void SolveInstance(IGH_DataAccess DA) { } } - var finalTyped = new List(); - var finalExplicit = new List(); - + // unwrap disallowed typed rules and add them to disallowedExplicit foreach (var entry in allTypedByType) { var type = entry.Key; var rules = entry.Value; @@ -160,42 +160,46 @@ protected override void SolveInstance(IGH_DataAccess DA) { var rulesExplicit = rules.SelectMany(rule => rule.ToRulesExplicit(rules, modulesClean)); var disallowedRules = disallowedTypedByType[type]; foreach (var rule in rulesExplicit) { - if (!disallowedRules.Any(disallowedRule => + if (disallowedRules.Any(disallowedRule => (disallowedRule.ModuleName == rule.SourceModuleName && disallowedRule.ConnectorIndex == rule.SourceConnectorIndex) || (disallowedRule.ModuleName == rule.TargetModuleName - && disallowedRule.ConnectorIndex == rule.TargetConnectorIndex)) - && !disallowedExplicit.Any(disallowedRule => disallowedRule.Equals(rule))) { - finalExplicit.Add(rule); + && disallowedRule.ConnectorIndex == rule.TargetConnectorIndex))) { + disallowedExplicit.Add(rule); } } - } else { - finalTyped.AddRange(rules); } } + // unwrap all typed rules + foreach (var rule in allTypedRules) { + var rulesExplicit = rule.ToRulesExplicit(allTypedRules, modulesClean); + allowedExplicit.AddRange(rulesExplicit); + } + + var finalExplicit = new List(); + foreach (var rule in allowedExplicit) { if (!disallowedExplicit.Any(disallowedRule => disallowedRule.Equals(rule))) { finalExplicit.Add(rule); } } - var outRules = finalExplicit + var outputRules = finalExplicit .Where(rule => !(rule.SourceModuleName == Config.OUTER_MODULE_NAME && rule.TargetModuleName == Config.OUTER_MODULE_NAME)) - .Select(explicitRule => new Rule(explicitRule)) - .Concat(finalTyped.Select(ruleTyped => new Rule(ruleTyped))) .Distinct() + .Select(explicitRule => new Rule(explicitRule)) .ToList(); - outRules.Sort(); + outputRules.Sort(); - foreach (var rule in outRules) { + foreach (var rule in outputRules) { if (!rule.IsValid) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, rule.IsValidWhyNot); } } - DA.SetDataList(0, outRules); + DA.SetDataList(0, outputRules); } /// diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 3854dcf..202073d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.4.4")] -[assembly: AssemblyFileVersion("1.2.4.4")] +[assembly: AssemblyVersion("1.2.4.5")] +[assembly: AssemblyFileVersion("1.2.4.5")] diff --git a/bin/Monoceros.pdb b/bin/Monoceros.pdb index 966a68d..882feb8 100644 Binary files a/bin/Monoceros.pdb and b/bin/Monoceros.pdb differ