Exemplo n.º 1
0
        static public IEnumerable <Referenceable> GetLocalReferenceables(this Scope item, string id)
        {
            FieldInfoEX field;

            if (item.GetFilteredInstanceFields(
                    Filterer_FieldInfo.CanBeTreatedAs <IDictionary <string, List <Referenceable> > >(),
                    Filterer_FieldInfo.HasCustomAttributeOfType <ScopeMapAttribute>()
                    ).TryGetFirst(out field))
            {
                IDictionary <string, List <Referenceable> > dictionary = field.GetValue <IDictionary <string, List <Referenceable> > >(item);

                if (dictionary == null)
                {
                    dictionary = new Dictionary <string, List <Referenceable> >();

                    item.GetLocalReferenceables().Process(r => dictionary.Add(r.GetId(), r));
                    field.SetValue(item, dictionary);
                }

                return(dictionary.GetValues(id));
            }

            return(item.GetLocalReferenceables()
                   .Narrow(r => id == r.GetId()));
        }
Exemplo n.º 2
0
 static public bool TryGetHoldingContainerField <P>(this Holdable <P> item, out FieldInfoEX field_info)
 {
     return(item.GetFilteredInstanceFields(
                Filterer_FieldInfo.CanBeTreatedAs <HoldingContainer <P> >(),
                Filterer_FieldInfo.HasCustomAttributeOfType <HoldingContainerAttribute>()
                ).TryGetFirst(out field_info));
 }
Exemplo n.º 3
0
 static public bool LoadAsConfigurationInto(this LookupSet <string, string> item, object target, bool strict = false)
 {
     return(target.GetFilteredInstanceFields(
                Filterer_FieldInfo.HasCustomAttributeOfType <ConfigurationVariableAttribute>()
                ).ProcessAND(
                f => f.GetCustomAttributeOfType <ConfigurationVariableAttribute>(false).TryHydrateSetting(item, target, f, strict)
                ));
 }
Exemplo n.º 4
0
        protected override bool TryHydrateSettingInternal(string option_string, Type option_type, out object option_value)
        {
            FieldInfo field = Fields.GetFilteredStaticFields(
                Filterer_FieldInfo.CanBeTreatedAs(option_type),
                Filterer_FieldInfo.HasCustomAttributeOfType(attribute_type)
                ).FindFirst(f => f.GetCustomAttributeOfSubType <ConfigurationValueAttribute>(attribute_type, false)
                            .CheckOptionString(option_string)
                            );

            if (field != null)
            {
                option_value = field.GetValue(null);
                return(true);
            }

            option_value = null;
            return(false);
        }