/// <summary> /// Method setProperty /// </summary> /// <param name="propertyName">A string</param> /// <param name="value">A Ferda.Modules.PropertyValue</param> /// <param name="__current">An Ice.Current</param> public override void setProperty(String propertyName, PropertyValue value, Current __current) { if (! (propertyName == "value")) { throw new Ferda.Modules.NameNotExistError(); } if (value!=null && !value.ice_isA(this.propertyClassIceId)) { throw new Ferda.Modules.BadTypeError(); } if(propertyValuePrx != null && propertySetByValue) adapter.remove(propertyValuePrx.ice_getIdentity()); this.propertySetByValue = true; propertyValue = value; propertyValuePrx = this.adapter.addWithUUID(value); }
/// <summary> /// Sets the specified property (<c>propertyName</c>) by /// specified <c>propertyValue</c>. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="propertyValue">The property value.</param> /// <param name="__current">The Ice.Current.</param> /// <exception cref="T:Ferda.Modules.NameNotExistError"> /// Thrown iff there is no property of specified <c>propertyName</c>. /// </exception> /// <exception cref="T:Ferda.Modules.BadTypeError"> /// Thrown iff specified <c>propertyValue</c> is not of the /// specified property data type. See <see cref="T:Ferda.Modules.Serialier.BoxSerializer.Property.TypeClassIceId"/>. /// </exception> /// <exception cref="T:Ferda.Modules.ReadOnlyError"> /// Thrown iff specified property is read only. /// </exception> public override void setProperty(string propertyName, PropertyValue propertyValue, Ice.Current __current) { if (!this.boxInfo.TestPropertyNameExistence(propertyName)) { // there is no property of the specified propertyName throw Ferda.Modules.Exceptions.NameNotExistError(null, null, "BMI25", propertyName); } if (propertyValue != null && !propertyValue.ice_isA(this.boxInfo.GetPropertyDataType(propertyName))) { // bad type of the specified propertyValue Debug.WriteLine("BMI26"); throw new Ferda.Modules.BadTypeError(); } if (this.boxInfo.IsPropertyReadOnly(propertyName)) { // the specified property is readonly Debug.WriteLine("BMI27"); throw new Ferda.Modules.ReadOnlyError(); } // switch data type of the property // check if new propertyValue satisfy restrictions of the property // destroy old propetyValue object`s proxy // add new propertyValue object to the adapter // and save the proxy of added object lock (this) { switch (boxInfo.GetPropertyDataType(propertyName)) { case "::Ferda::Modules::ShortT": PropertyValueRestrictionsHelper.TryIsIntegralPropertyCorrect( this.boxInfo, propertyName, ((ShortT)propertyValue).getShortValue()); break; case "::Ferda::Modules::IntT": PropertyValueRestrictionsHelper.TryIsIntegralPropertyCorrect( this.boxInfo, propertyName, ((IntT)propertyValue).getIntValue()); break; case "::Ferda::Modules::LongT": PropertyValueRestrictionsHelper.TryIsIntegralPropertyCorrect( this.boxInfo, propertyName, ((LongT)propertyValue).getLongValue()); break; case "::Ferda::Modules::FloatT": PropertyValueRestrictionsHelper.TryIsFloatingPropertyCorrect( this.boxInfo, propertyName, ((FloatT)propertyValue).getFloatValue()); break; case "::Ferda::Modules::DoubleT": PropertyValueRestrictionsHelper.TryIsFloatingPropertyCorrect( this.boxInfo, propertyName, ((DoubleT)propertyValue).getDoubleValue()); break; case "::Ferda::Modules::StringT": PropertyValueRestrictionsHelper.TryIsStringPropertyCorrect( this.boxInfo, propertyName, ((StringT)propertyValue).getStringValue()); break; case "::Ferda::Modules::DateTimeT": PropertyValueRestrictionsHelper.TryIsDateTimePropertyCorrect( this.boxInfo, propertyName, (DateTimeT)propertyValue); break; case "::Ferda::Modules::DateT": DateT date = new DateTI(); ((DateT)propertyValue).getDateValue(out date.year, out date.month, out date.day); PropertyValueRestrictionsHelper.TryIsDatePropertyCorrect( this.boxInfo, propertyName, date); break; case "::Ferda::Modules::TimeT": TimeT time = new TimeTI(); ((TimeT)propertyValue).getTimeValue(out time.hour, out time.minute, out time.second); PropertyValueRestrictionsHelper.TryIsTimePropertyCorrect( this.boxInfo, propertyName, time); break; } // proxy of new propertyValue is already saved // save the propertyValue this.properties[propertyName] = propertyValue; } }