public void CreateFields_ForClass_ReturnsFieldsWithAllProperties()
        {
            TestClass tc     = new TestClass();
            var       fields = new List <Field>(FieldBuilder.CreateFields(tc, "kl", FieldKind.Data));

            Assert.AreEqual(4, fields.Count);
        }
Esempio n. 2
0
        bool evaluate()
        {
            object result   = null;
            string meassage = null;
            bool   res      = false;
            string usings   = String.Empty;
            string code     = codeTextview.Buffer.Text;

            designService.Report.Parameters.Clear();
            designService.Report.DataSource = null;

            if (Compiler.Evaluate(out result, out meassage, new object[] { usings, code }))
            {
                var ds         = (result as object[]);
                var datasource = ds[0];

                Dictionary <string, object> parametersDictionary = ds[1] as Dictionary <string, object>;
                foreach (KeyValuePair <string, object> kvp in parametersDictionary)
                {
                    designService.Report.Parameters.AddRange(FieldBuilder.CreateFields(kvp.Value, kvp.Key, FieldKind.Parameter));
                }

                if (datasource != null)
                {
                    designService.Report.DataSource = datasource;
                    designService.Report.DataScript = codeTextview.Buffer.Text;
                    res = true;
                }
            }

            outputTextview.Buffer.Text = meassage;
            return(res);
        }
        public void CreateFields_ForString_ShouldCreateFieldWithName()
        {
            var fields = FieldBuilder.CreateFields(typeof(string), "sdf", FieldKind.Parameter);

            Assert.IsNotNull(fields);
            Assert.AreEqual(1, fields.Length);
            Assert.IsNotNull(fields[0].Name);
        }
Esempio n. 4
0
        public static void ExportToPdf(this Report report, string path, IDictionary <string, object> parameters)
        {
            report.Parameters.Clear();

            foreach (KeyValuePair <string, object> kvp in parameters)
            {
                report.Parameters.AddRange(FieldBuilder.CreateFields(kvp.Value, kvp.Key, FieldKind.Parameter));
            }


            report.ExportToPdf(path);
        }