如何从对象列表中打印实际数据?

时间:2017-06-04 08:47:43

标签: java list hibernate

我需要从下面的对象列表中打印实际值。这可以从这个列表中获得实际值吗?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);

            Rect.rectangles = doc.Descendants().Where(x => x.Name.LocalName == "rect").Select(x => new Rect()
            {
                style = Rect.GetStyle((string)x.Attribute("style")),
                id = (string)x.Attribute("id"),
                width = (double)x.Attribute("width"),
                height = (double)x.Attribute("width"),
                x = (double?)x.Attribute("width"),
                y = (double?)x.Attribute("width"),
                transform = x.Attribute("transform") == null ? null : (object)Rect.GetTransform((string)x.Attribute("transform"))
            }).ToList();


        }
    }
    public class Rect
    {
        public static List<Rect> rectangles { get; set; }
        public Dictionary<string, string> style { get; set; }
        public string id { get; set; }
        public double width { get; set; }
        public double height { get; set; }
        public double? x { get; set; }
        public double? y { get; set; }
        public object transform { get; set; }

        public static Dictionary<string, string> GetStyle(string styles)
        {
            string pattern = @"(?'name'[^:]+):(?'value'.*)";
            string[] splitArray = styles.Split(new char[] { ';' });
            Dictionary<string, string> style = splitArray.Select(x => Regex.Match(x, pattern))
                .GroupBy(x => x.Groups["name"].Value, y => y.Groups["value"].Value)
                .ToDictionary(x => x.Key, y => y.FirstOrDefault());
            return style;
        }
        public static KeyValuePair<double, double> GetTransform(string matrix)
        {
            string pattern = @"[-+]?\d+\.\d+";
            MatchCollection matches = Regex.Matches(matrix, pattern);
            KeyValuePair<double, double> kp = new KeyValuePair<double, double>(
                double.Parse(matches[0].Value),
                double.Parse(matches[0].Value)
                );

            return kp;
        }
    }
}

我低于输出。不是实际的密码和用户名

  

Ljava.lang.Object; @ 2c36b22d

0 个答案:

没有答案