Exemple #1
0
 /// <summary>
 /// Stores the "EcellObject" 4 the "Stepper".
 /// </summary>
 /// <param name="simulator">The simulator</param>
 /// <param name="dmm">The "DynamicModuleManager"</param>
 /// <param name="ecellObject">The stored "Stepper"</param>
 internal static void DataStored4Stepper(
     WrappedSimulator simulator,
     DMDescriptorKeeper dmm,
     EcellObject ecellObject)
 {
     string key = Constants.xpathStepper + Constants.delimiterColon + Constants.delimiterColon + ecellObject.Key;
     List<EcellData> stepperEcellDataList = new List<EcellData>();
     IList<string> wrappedPolymorph = null;
     //
     // Property List
     //
     try
     {
         wrappedPolymorph = simulator.GetStepperPropertyList(ecellObject.Key);
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.StackTrace);
         return;
     }
     //
     // Sets the class name.
     //
     if (string.IsNullOrEmpty(ecellObject.Classname))
     {
         ecellObject.Classname = simulator.GetStepperClassName(ecellObject.Key);
     }
     //
     // Checks the stored "EcellData"
     //
     Dictionary<string, EcellData> storedEcellDataDic = new Dictionary<string, EcellData>();
     if (ecellObject.Value != null && ecellObject.Value.Count > 0)
     {
         foreach (EcellData storedEcellData in ecellObject.Value)
         {
             storedEcellDataDic[storedEcellData.Name] = storedEcellData;
             stepperEcellDataList.Add(storedEcellData);
         }
     }
     //
     // Stores the "EcellData"
     //
     foreach (string name in wrappedPolymorph)
     {
         string entityPath = key + Constants.delimiterColon + name;
         PropertyAttributes flag = simulator.GetStepperPropertyAttributes(ecellObject.Key, name);
         if (!flag.Gettable)
         {
             continue;
         }
         EcellValue value = null;
         try
         {
             object property = simulator.GetStepperProperty(ecellObject.Key, name);
             value = new EcellValue(property);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex);
             value = GetValueFromDMM(dmm, ecellObject.Type, ecellObject.Classname, name);
         }
         EcellData ecellData = CreateEcellData(name, value, entityPath, flag);
         if (storedEcellDataDic.ContainsKey(name))
         {
             if (value.IsString && value.ToString().Equals(""))
             {
                 continue;
             }
             else
             {
                 stepperEcellDataList.Remove(storedEcellDataDic[name]);
             }
         }
         stepperEcellDataList.Add(ecellData);
     }
     ecellObject.SetEcellDatas(stepperEcellDataList);
 }
 /// <summary>
 /// Get PropertyDescriptors
 /// </summary>
 /// <param name="sim">the curremt simulator.</param>
 /// <param name="stepper">the stepper name.</param>
 /// <returns></returns>
 private static Dictionary<string, PropertyDescriptor> GetStepperPropertyDescriptors(WrappedSimulator sim, string stepper)
 {
     // Get default property values.
     Dictionary<string, PropertyDescriptor> pdescs = new Dictionary<string, PropertyDescriptor>();
     foreach (string propName in sim.GetStepperPropertyList(stepper))
     {
         PropertyAttributes attrs = sim.GetStepperPropertyAttributes(stepper, propName);
         EcellValue defaultValue = null;
         if (attrs.Gettable)
         {
             try
             {
                 defaultValue = new EcellValue(sim.GetStepperProperty(stepper, propName));
             }
             catch (Exception)
             {
                 Trace.WriteLine(string.Format("    Failed to get default value of property, {0}:{1}.", stepper, propName));
             }
         }
         // Set default value.
         if (defaultValue == null)
             defaultValue = new EcellValue(0.0d);
         bool logable = defaultValue.IsDouble;
         pdescs[propName] = new PropertyDescriptor(
             propName,
             attrs.Settable, // settable
             attrs.Gettable, // gettable
             attrs.Loadable, // loadable
             attrs.Savable,  // saveable
             attrs.Dynamic,  // dynamic
             logable, // logable
             defaultValue
         );
     }
     return pdescs;
 }