private void button1_Click(object sender, EventArgs e)
        {
            JavaMapping jm = new JavaMapping();

            jm.SqlType  = "varchar";
            jm.JavaType = "String";
            IList <JavaMapping> list = new List <JavaMapping>();

            list.Add(jm);
            XmlHelper.SaveConfig(list, "JavaMapping.xml");
        }
示例#2
0
        //Converts potential sequences into item lists, while flattening to a single dimension
        private static IEnumerable <Item> GetItems(object obj)
        {
            //It it a Node?
            Node.Node node = obj as Node.Node;
            if (node != null)
            {
                return(new[] { node.ANode });
            }

            //Is it a Database?
            Database database = obj as Database;

            if (database != null)
            {
                return(database.Documents.Select(d => d.ANode).Cast <Item>());
            }

            //Is it enumerable (list, array, etc. - but not a string!)
            //This is recursive and results in flattening any nested sequences
            IEnumerable enumerable = obj as IEnumerable;

            if (!(obj is string) && enumerable != null)
            {
                return(enumerable.Cast <object>().Select(GetItems).SelectMany(x => x));
            }

            // Clean up non-.NET values
            if (obj is Decimal)
            {
                obj = new BigDecimal(obj.ToString());
            }
            else if (obj is DateTime)
            {
                obj = DatatypeFactory.newInstance().newXMLGregorianCalendar(
                    ((DateTime)obj).ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"));
            }
            else if (obj is TimeSpan)
            {
                obj = DatatypeFactory.newInstance().newDuration(
                    Convert.ToInt64(((TimeSpan)obj).TotalMilliseconds));
            }
            else if (obj is XmlQualifiedName)
            {
                XmlQualifiedName qname = (XmlQualifiedName)obj;
                obj = new QName(qname.Namespace, qname.Name);
            }

            //Get the item
            return(new [] { JavaMapping.type(obj).cast(obj, null) });
        }