public virtual S4PropWrapper getProperty(string name, Class propertyClass) { if (!this.propValues.containsKey(name)) { string text = this.getInstanceName(); string text2 = new StringBuilder().append("Unknown property '").append(name).append("' ! Make sure that you've annotated it.").toString(); throw new InternalConfigurationException(text, name, text2); } S4PropWrapper s4PropWrapper = (S4PropWrapper)this.registeredProperties.get(name); if (s4PropWrapper == null) { string text3 = this.getInstanceName(); string text4 = new StringBuilder().append("Property is not an annotated property of ").append(this.getConfigurableClass()).toString(); throw new InternalConfigurationException(text3, name, text4); } try { propertyClass.cast(s4PropWrapper.getAnnotation()); } catch (System.Exception ex) { throw new InternalConfigurationException(ex, this.getInstanceName(), name, new StringBuilder().append("Property annotation ").append(s4PropWrapper.getAnnotation()).append(" doesn't match the required type ").append(propertyClass.getName()).toString()); } return(s4PropWrapper); }
public virtual string getString(string name) { S4PropWrapper property = this.getProperty(name, ClassLiteral <S4String> .Value); S4String s4String = (S4String)property.getAnnotation(); if (this.propValues.get(name) == null) { int num = String.instancehelper_equals(s4String.defaultValue(), "nullnullnull") ? 0 : 1; if (s4String.mandatory() && num == 0) { string text = this.getInstanceName(); string text2 = "mandatory property is not set!"; throw new InternalConfigurationException(text, name, text2); } this.propValues.put(name, (num == 0) ? null : s4String.defaultValue()); } string text3 = this.flattenProp(name); List list = Arrays.asList(s4String.range()); if (!list.isEmpty() && !list.contains(text3)) { string text4 = this.getInstanceName(); string text5 = new StringBuilder().append(" is not in range (").append(list).append(')').toString(); throw new InternalConfigurationException(text4, name, text5); } return(text3); }
public virtual double getDouble(string name) { S4PropWrapper property = this.getProperty(name, ClassLiteral <S4Double> .Value); S4Double s4Double = (S4Double)property.getAnnotation(); if (this.propValues.get(name) == null) { int num = (s4Double.defaultValue() != -918273645.12345) ? 1 : 0; if (s4Double.mandatory()) { if (num == 0) { string text = this.getInstanceName(); string text2 = "mandatory property is not set!"; throw new InternalConfigurationException(text, name, text2); } } else if (num == 0) { string text3 = this.getInstanceName(); string text4 = "no default value for non-mandatory property"; throw new InternalConfigurationException(text3, name, text4); } this.propValues.put(name, Double.valueOf(s4Double.defaultValue())); } object obj = this.propValues.get(name); Double @double; if (obj is Double) { @double = (Double)obj; } else if (obj is Number) { @double = Double.valueOf(((Number)obj).doubleValue()); } else { @double = Double.valueOf(this.flattenProp(name)); } double[] array = s4Double.range(); if (array.Length != 2) { string text5 = this.getInstanceName(); string text6 = new StringBuilder().append(Arrays.toString(array)).append(" is not of expected range type, which is {minValue, maxValue)").toString(); throw new InternalConfigurationException(text5, name, text6); } if (@double.doubleValue() < array[0] || @double.doubleValue() > array[1]) { string text7 = this.getInstanceName(); string text8 = new StringBuilder().append(" is not in range (").append(Arrays.toString(array)).append(')').toString(); throw new InternalConfigurationException(text7, name, text8); } return(@double.doubleValue()); }
public virtual int getInt(string name) { S4PropWrapper property = this.getProperty(name, ClassLiteral <S4Integer> .Value); S4Integer s4Integer = (S4Integer)property.getAnnotation(); if (this.propValues.get(name) == null) { int num = (s4Integer.defaultValue() != -918273645) ? 1 : 0; if (s4Integer.mandatory()) { if (num == 0) { string text = this.getInstanceName(); string text2 = "mandatory property is not set!"; throw new InternalConfigurationException(text, name, text2); } } else if (num == 0) { string text3 = this.getInstanceName(); string text4 = "no default value for non-mandatory property"; throw new InternalConfigurationException(text3, name, text4); } this.propValues.put(name, Integer.valueOf(s4Integer.defaultValue())); } object obj = this.propValues.get(name); Integer integer = (!(obj is Integer)) ? Integer.decode(this.flattenProp(name)) : ((Integer)obj); int[] array = s4Integer.range(); if (array.Length != 2) { string text5 = this.getInstanceName(); string text6 = new StringBuilder().append(Arrays.toString(array)).append(" is not of expected range type, which is {minValue, maxValue)").toString(); throw new InternalConfigurationException(text5, name, text6); } if (integer.intValue() < array[0] || integer.intValue() > array[1]) { string text7 = this.getInstanceName(); string text8 = new StringBuilder().append(" is not in range (").append(Arrays.toString(array)).append(')').toString(); throw new InternalConfigurationException(text7, name, text8); } return(integer.intValue()); }
private void registerProperty(string text, S4PropWrapper s4PropWrapper) { if (s4PropWrapper == null || text == null) { string text2 = this.getInstanceName(); string text3 = "property or its value is null"; throw new InternalConfigurationException(text2, text, text3); } if (!this.registeredProperties.containsKey(text)) { this.registeredProperties.put(text, s4PropWrapper); } if (!this.propValues.containsKey(text)) { this.propValues.put(text, null); this.rawProps.put(text, null); } }
public virtual PropertyType getType(string propName) { S4PropWrapper s4PropWrapper = (S4PropWrapper)this.registeredProperties.get(propName); if (s4PropWrapper == null) { string text = this.getInstanceName(); string text2 = new StringBuilder().append(" is not a valid property of").append(this.getConfigurableClass()).toString(); throw new InternalConfigurationException(text, propName, text2); } Annotation annotation = s4PropWrapper.getAnnotation(); if (annotation is S4Component) { return(PropertyType.__COMPONENT); } if (annotation is S4ComponentList) { return(PropertyType.__COMPONENT_LIST); } if (annotation is S4Integer) { return(PropertyType.__INT); } if (annotation is S4Double) { return(PropertyType.__DOUBLE); } if (annotation is S4Boolean) { return(PropertyType.__BOOLEAN); } if (annotation is S4String) { return(PropertyType.__STRING); } string text3 = "Unknown property type"; throw new RuntimeException(text3); }
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); }
public virtual Boolean getBoolean(string name) { S4PropWrapper property = this.getProperty(name, ClassLiteral <S4Boolean> .Value); S4Boolean s4Boolean = (S4Boolean)property.getAnnotation(); if (this.propValues.get(name) == null) { this.propValues.put(name, Boolean.valueOf(s4Boolean.defaultValue())); } object obj = this.propValues.get(name); Boolean result; if (obj is Boolean) { result = (Boolean)obj; } else { result = Boolean.valueOf(this.flattenProp(name)); } return(result); }