Beispiel #1
0
        public virtual Class getComponentClass(string propName)
        {
            Class result;

            if (this.propValues.get(propName) != null)
            {
                try
                {
                    Class @class = Class.forName((string)this.propValues.get(propName), PropertySheet.__GetCallerID());
                    result = @class.asSubclass(ClassLiteral <Configurable> .Value);
                }
                catch (ClassNotFoundException)
                {
                    goto IL_40;
                }
                return(result);

IL_40:
                PropertySheet propertySheet = this.cm.getPropertySheet(this.flattenProp(propName));
                result = propertySheet.ownerClass;
            }
            else
            {
                S4Component s4Component = (S4Component)((S4PropWrapper)this.registeredProperties.get(propName)).getAnnotation();
                result = s4Component.defaultClass();
                if (s4Component.mandatory())
                {
                    result = null;
                }
            }
            return(result);
        }
Beispiel #2
0
        private Configurable getComponentFromAnnotation(string text, S4Component s4Component)
        {
            Class @class = s4Component.defaultClass();

            if (Object.instancehelper_equals(@class, ClassLiteral <Configurable> .Value) && s4Component.mandatory())
            {
                string text2 = this.getInstanceName();
                string text3 = "mandatory property is not set!";

                throw new InternalConfigurationException(text2, text, text3);
            }
            if (Modifier.isAbstract(@class.getModifiers()) && s4Component.mandatory())
            {
                string text4 = this.getInstanceName();
                string text5 = new StringBuilder().append(@class.getName()).append(" is abstract!").toString();

                throw new InternalConfigurationException(text4, text, text5);
            }
            if (Object.instancehelper_equals(@class, ClassLiteral <Configurable> .Value))
            {
                if (s4Component.mandatory())
                {
                    string text6 = this.getInstanceName();
                    string text7 = new StringBuilder().append(this.instanceName).append(": no default class defined for ").append(text).toString();

                    throw new InternalConfigurationException(text6, text, text7);
                }
                return(null);
            }
            else
            {
                Configurable instance = ConfigurationManager.getInstance(@class);
                if (instance == null)
                {
                    string text8 = this.getInstanceName();
                    string text9 = "instantiation of referenenced configurable failed";

                    throw new InternalConfigurationException(text8, text, text9);
                }
                return(instance);
            }
        }
Beispiel #3
0
        public virtual Configurable getComponent(string name)
        {
            S4PropWrapper property     = this.getProperty(name, ClassLiteral <S4Component> .Value);
            Configurable  configurable = null;
            S4Component   s4Component  = (S4Component)property.getAnnotation();
            Class         @class       = s4Component.type();
            object        obj          = this.propValues.get(name);

            if (obj != null && obj is Configurable)
            {
                return((Configurable)obj);
            }
            if (obj != null && obj is string)
            {
                PropertySheet propertySheet = this.cm.getPropertySheet(this.flattenProp(name));
                if (propertySheet == null)
                {
                    string text  = this.getInstanceName();
                    string text2 = new StringBuilder().append("component '").append(this.flattenProp(name)).append("' is missing").toString();

                    throw new InternalConfigurationException(text, name, text2);
                }
                configurable = propertySheet.getOwner();
            }
            if (configurable != null && [email protected](configurable))
            {
                string text3 = this.getInstanceName();
                string text4 = "mismatch between annotation and component type";

                throw new InternalConfigurationException(text3, name, text4);
            }
            if (configurable != null)
            {
                this.propValues.put(name, configurable);
                return(configurable);
            }
            configurable = this.getComponentFromAnnotation(name, s4Component);
            this.propValues.put(name, configurable);
            return(configurable);
        }