Ejemplo n.º 1
0
        /// <summary>
        /// Removes the dummy options from model.
        /// </summary>
        /// <param name="val">The val.</param>
        /// <returns></returns>
        public static string RemoveDummyOptionsFromModel(StringBuilder val)
        {
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            var tmp = val.Replace(@"""EvaluationFn"":""Choose...""", @"""EvaluationFn"":""Choose""");

            // Hydrate and remove Choose options ;)

            try
            {
                Dev2DecisionStack dds = compiler.ConvertFromJsonToModel <Dev2DecisionStack>(tmp);

                if (dds.TheStack != null)
                {
                    IList <Dev2Decision> toKeep = dds.TheStack.Where(item => item.EvaluationFn != enDecisionType.Choose).ToList();

                    dds.TheStack = toKeep;
                }

                tmp = compiler.ConvertModelToJson(dds);
            }
            catch (Exception ex)
            {
                Dev2Logger.Log.Error("Dev2DecisionStack", ex);
                // Best effort ;)
            }


            return(tmp.ToString());
        }