Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }