示例#1
0
        public Form1()
        {
            InitializeComponent();

            grdRecords.AutoGenerateColumns = false;
            // configure assembler using mapping in mapping.otis.xml
            m_cfg.AddAssemblyResources(Assembly.GetExecutingAssembly(), "otis.xml");

            // retrieve list of users from somewhere
            IMusicService svc = new MusicService();

            Artist[] artists = svc.GetAllArtists();

            // get the assembler for User->UserInfo transformation
            IAssembler <ArtistInfo, Artist> asm = m_cfg.GetAssembler <ArtistInfo, Artist>();

            // transform array of User instances to a list of UserInfo instances
            // and initialize BindingList with it
            m_userData = new BindingList <ArtistInfo>(asm.ToList(artists));

            // setup data source for combo box
            cboUsers.DataSource    = m_userData;
            cboUsers.DisplayMember = "Description";
            cboUsers.ValueMember   = "Id";
        }
        public void Enumerable_Can_Convert_To_Collection()
        {
            ICollection <AttributedUserDTO> dtos = m_assembler.ToList(m_source);
            int i = 0;

            foreach (AttributedUserDTO dto in dtos)
            {
                Assert.AreEqual(m_source[i].FirstName + " " + m_source[i].LastName, dto.FullName);
                i++;
            }
        }