public static RulesCache LoadRulesSync(IRulesLoader rulesLoader)
        {
            RulesCache cache = new RulesCache(new ConcurrentDictionary <string, RuleEngine>(), new ConcurrentDictionary <string, string>());

            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(FlowActivity)).Assembly;

            string[] embeddedResources = GetResourceNames(assembly);

            Dictionary <string, string> rules = embeddedResources
                                                .Where(f => f.EndsWith(".module"))
                                                .ToDictionary(f => GetKey(f).ToLowerInvariant());

            Dictionary <string, string> resources = embeddedResources
                                                    .Where(f => f.EndsWith(".resources"))
                                                    .ToDictionary(f => GetKey(f).ToLowerInvariant());

            foreach (var key in rules.Keys)
            {
                rulesLoader.LoadRules
                (
                    new RulesModuleModel
                {
                    Name            = key,
                    ResourceSetFile = GetBytes(resources[key], assembly),
                    RuleSetFile     = GetBytes(rules[key], assembly)
                },
                    cache
                );
            }

            return(cache);

            string GetKey(string fullResourceName)
            => Path.GetExtension(Path.GetFileNameWithoutExtension(fullResourceName)).Substring(1);
        }
        public void LoadRules(RulesModuleModel module, RulesCache cache)
        {
            string  moduleName = module.Name.ToLowerInvariant();
            RuleSet ruleSet    = module.DeserializeRuleSetFile();

            if (ruleSet == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.invalidRulesetFormat, moduleName));
            }

            cache.RuleEngines.Add(moduleName, new RuleEngine(ruleSet, RulesSerializer.GetValidation(ruleSet)));

            using (IResourceReader reader = new ResourceReader(new MemoryStream(module.ResourceSetFile)))
            {
                reader.OfType <DictionaryEntry>()
                .ToList()
                .ForEach(entry => cache.ResourceStrings.Add((string)entry.Key, (string)entry.Value));
            }
        }