Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="odm"></param>
        /// <param name="useSuffix"></param>
        /// <returns></returns>
        public List <OutputDataElement> GetOutputs(OutputDataModel odm, bool useSuffix = true)
        {
            List <OutputDataElement> OutputDataElements = new List <OutputDataElement>();

            string suffix = "";

            if (useSuffix == true)
            {
                suffix = odm.Suffix;
            }

            foreach (OutputDataElement v in odm.OutputDataElements)
            {
                if (v.IsSelected)
                {
                    if (v.PropertyInfo.PropertyType.IsGenericType)
                    {
                        int layerCount = 1;

                        foreach (double d in (IEnumerable <double>)v.PropertyInfo.GetValue(odm.HLController))
                        {
                            OutputDataElement o = Cloner.DeepClone(v);

                            o.Index        = layerCount - 1;
                            o.Name         = v.PropertyInfo.Name + "Layer" + layerCount.ToString() + (suffix == "" ? "" : ("-" + suffix));
                            o.HLController = odm.HLController;
                            o.PropertyInfo = v.PropertyInfo;

                            OutputDataElements.Add(o);
                            layerCount++;
                        }
                    }
                    else
                    {
                        OutputDataElements.Add(v);
                        v.Name         = v.PropertyInfo.Name + (suffix == "" ? "" : ("-" + suffix));
                        v.HLController = odm.HLController;
                    }
                }
            }
            return(OutputDataElements);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public virtual void PrepareVariableNamesForOutput()
        {
            Outputs = new List <OutputDataElement>();

            foreach (OutputDataModel odm in OutputDataModels)
            {
                if (odm.HLController.GetType() != typeof(PesticideObjectController))
                {
                    Outputs.AddRange(GetOutputs(odm, false));
                }
                else
                {
                    Outputs.AddRange(GetOutputs(odm, true));
                }
            }
            foreach (OutputDataElement ode in Outputs)
            {
                OutputDataElement projODE = Sim.Project.OutputDataElements.Where(x => x.Name == ode.Name && x.HLController.Name == ode.HLController.Name).FirstOrDefault();
                ode.IsSelected = projODE.IsSelected;
            }
        }