Exemplo n.º 1
0
        /// <summary>
        /// Get rule value for an attribute that belongs to the given entity
        /// </summary>
        /// <param name="NameOrAlias"></param>
        /// <param name="AttributeName"></param>
        /// <returns></returns>
        public string GetRuleValue(string NameOrAlias, string AttributeName, bool IsMain = false)
        {
            VirtualRule Rule = Rules.First(R => R.SourceERElement.Name == NameOrAlias || R.Alias == NameOrAlias);

            if (Rule != null)
            {
                return(Rule.Rules.First(R => R.Key == AttributeName).Value);
            }
            else
            {
                throw new RuleNotFoundException($"No map rule found for ER Element [{NameOrAlias}]");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates a VirtualMap instance from a ModelMapping instance
        /// </summary>
        /// <param name="ModelMap"></param>
        /// <returns></returns>
        public static VirtualMap FromModelMap(ModelMapping ModelMap)
        {
            // Create list of virtual rules
            List <VirtualRule> VirtualRules = new List <VirtualRule>();

            // Iterate ModelMap rules
            foreach (MapRule Rule in ModelMap.Rules)
            {
                VirtualRule ConvertedRule = new VirtualRule(Rule.Source);
                ConvertedRule.Rules = Rule.Rules;

                VirtualRules.Add(ConvertedRule);
            }

            return(new VirtualMap(VirtualRules));
        }