Example #1
0
        private async static Task <string> TestNewEditable(Type pType, Dictionary <string, string> Data)
        {
            try
            {
                Console.WriteLine("Test creating a new  BO");
                var obj = await BOFactory.NewBOAsync(pType.ToString(), Data);

                BOFactory.ApplyPreset(obj, Data);

                var saved = await(obj as SPC.Interfaces.IEditable).SaveBOAsync();

                Console.WriteLine("New object Saved: ");

                var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(saved);
                Console.WriteLine(jsonstr);


                return(saved.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(string.Empty);
        }
Example #2
0
        private async static Task TestSingleton(Type pType)
        {
            string editable = pType.ToString();
            var    filters  = new Dictionary <string, string>();
            object theobj   = null;

            if (await BOFactory.IsBOExistsAsync(editable, filters))
            {
                Console.WriteLine("Found runable {0} : {1}", editable, filters.ToParametersString());
                theobj = await BOFactory.GetBOAsync(editable, filters);
            }
            else
            {
                Console.WriteLine("object {0}:{1} does not exists", editable, filters.ToParametersString());
                theobj = await BOFactory.NewBOAsync(editable, filters);
            }


            var jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(theobj);

            Console.WriteLine(jsonstr);
        }