// domain mode logic if selectable 
        // no flag simple = formal = true 
        // "simple" simple = true, formal = false
        // "formal" simple = false, formal = true
        // any other value simple = formal = false

        private static bool GetDomainModel(object value, DomainModelType model) {
            switch (ConfiguredDomainModelType) {
                case DomainModelType.Selectable: {
                    var s = value as string;
                    if (value == null) return true;
                    return (s == model.ToString().ToLower());
                }
                case DomainModelType.None:
                    return false;
                default:
                    return ConfiguredDomainModelType == model;
            }
        }
示例#2
0
        public static DomainModel LoadDomainModelTemplate()
        {
            ConfigSection configSection = new Config(@"MoreComplexExamples\WrappingConfigurationIntoALoader\wrapping.config", "domainModelTemplate").GetSection("model");

            DomainModel model = new DomainModel();

            model.Name = configSection.Name;

            bool canExecute;

            model.CanExecute = bool.TryParse(configSection["ShouldExecute"], out canExecute) && canExecute;

            if (!string.IsNullOrEmpty(configSection["description"]))
            {
                model.Description = configSection["description"];
            }

            int noUnits;

            model.NumberUnits = Int32.TryParse(configSection["noUnits"], out noUnits) ? noUnits : 0;


            try
            {
                DomainModelType modelType = (DomainModelType)Enum.Parse(typeof(DomainModelType), configSection["domainType"]);
                model.ModelType = modelType;
            }
            catch
            {
                model.ModelType = DomainModelType.MyType;
            }

            if (configSection.ContainsSubCollections)
            {
                if (configSection.Collections.ContainsKey("Contacts"))
                {
                    ConfigSection contacts = configSection.Collections.GetCollection("Contacts");
                    foreach (string contactName in contacts.ValuesAsDictionary.Values)
                    {
                        model.Contacts.Add(new DomainContact {
                            Name = contactName
                        });
                    }
                }
            }

            return(model);
        }
示例#3
0
        // domain mode logic if selectable
        // no flag simple = formal = true
        // "simple" simple = true, formal = false
        // "formal" simple = false, formal = true
        // any other value simple = formal = false

        private static bool GetDomainModel(object value, DomainModelType model)
        {
            switch (ConfiguredDomainModelType)
            {
            case DomainModelType.Selectable: {
                var s = value as string;
                if (value == null)
                {
                    return(true);
                }
                return(s == model.ToString().ToLower());
            }

            case DomainModelType.None:
                return(false);

            default:
                return(ConfiguredDomainModelType == model);
            }
        }