Search Results

Search found 2 results on 1 pages for 'newdi'.

Page 1/1 | 1 

  • Repeated properties design pattern

    - by Mark
    I have a DownloadManager class that manages multiple DownloadItem objects. Each DownloadItem has events like ProgressChanged and DownloadCompleted. Usually you want to use the same event handler for all download items, so it's a bit annoying to have to set the event handlers over and over again for each DownloadItem. Thus, I need to decide which pattern to use: Use one DownloadItem as a template and clone it as necessary var dm = DownloadManager(); var di = DownloadItem(); di.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); di.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); DownloadItem newDi; newDi = di.Clone(); newDi.Uri = "http://google.com"; dm.Enqueue(newDi); newDi = di.Clone(); newDi.Uri = "http://yahoo.com"; dm.Enqueue(newDi); Set the event handlers on the DownloadManager instead and have it copy the events over to each DownloadItem that is enqeued. var dm = DownloadManager(); dm.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); dm.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); dm.Enqueue(new DownloadItem("http://google.com")); dm.Enqueue(new DownloadItem("http://yahoo.com")); Or use some kind of factory var dm = DownloadManager(); var dif = DownloadItemFactory(); dif.ProgressChanged += new DownloadProgressChangedEventHandler(di_ProgressChanged); dif.DownloadCompleted += new DownloadProgressChangedEventHandler(di_DownloadCompleted); dm.Enqueue(dif.Create("http://google.com")); dm.Enqueue(dif.Create("http://yahoo.com")); What would you recommend?

    Read the article

  • Gone fishing, because i like it

    - by NewDi
    Integer orci risus, vestibulum et pharetra in, accumsan sit amet diam. Praesent rutrum faucibus tellus, at ullamcorper ligula vestibulum non. Nam felis tortor, tempor nec tincidunt vel, porta a nisi. Cras dictum, orci vitae varius feugiat, lorem nisi euismod nisi, vel sodales ante ipsum ut sapien. Praesent varius, ligula sit amet laoreet mattis, nulla nisi tincidunt urna, at placerat libero leo id mauris. Fusce pretium facilisis quam, nec vulputate nulla faucibus non. Donec sodales iaculis dui in gravida. Sed consequat scelerisque eros, quis pulvinar ipsum auctor ac. Sed odio felis, euismod at tincidunt in, sagittis vel lacus. Praesent vitae nisi non augue fringilla ornare. Phasellus interdum tellus quis elit blandit mattis eu id sapien. Duis at augue libero, quis mattis lorem. Morbi ut mauris ligula, nec dapibus quam. Suspendisse et ipsum enim. Suspendisse vel erat lorem. Sed id velit risus, porttitor pharetra urna. Fusce vestibulum elementum turpis in vehicula. Nullam eu nulla ipsum. Ut viverra diam quis urna congue in ullamcorper massa hendrerit. Curabitur convallis tempor ipsum et condimentum. Suspendisse eget enim tellus. Cras id sapien elit, sit amet rutrum tortor. Quisque ac odio tortor, et vestibulum turpis. Integer et magna in erat placerat placerat. Proin ac dapibus leo. Sed fringilla cursus quam quis ornare. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In nec diam sapien. Mauris ac enim dolor, a fringilla lorem. Nulla facilisi. Fusce bibendum quam vitae lorem placerat imperdiet. Phasellus molestie quam vehicula dolor auctor a dapibus lorem rhoncus. Fusce non arcu augue. Aliquam mollis placerat molestie. Duis quis diam vel erat porta bibendum vel id lacus. Quisque nec purus id magna imperdiet adipiscing non dictum sem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec enim metus, tincidunt quis eleifend at, tristique in sem. In elit elit, lobortis cursus lobortis eu, scelerisque vel mi. Fusce at leo ac mi porta feugiat. Etiam nec facilisis sem. Pellentesque bibendum, felis sit amet vehicula convallis, libero dolor venenatis sapien, in pretium nulla odio quis dolor. Praesent mollis porttitor quam, in elementum odio condimentum at. Sed elit odio, aliquam nec molestie in, tempor eget felis. Suspendisse lobortis magna lorem. Suspendisse nisl risus, sollicitudin non imperdiet eu, vestibulum sit amet elit. Praesent vulputate molestie ante, sit amet sagittis enim egestas a. Vestibulum ultrices iaculis dolor eget pharetra. Nam purus velit, sodales eu facilisis at, imperdiet at mauris. Nulla et enim vitae nulla luctus gravida a a dui. Pellentesque sollicitudin, libero nec scelerisque bibendum, ipsum tortor vehicula ipsum, at ultricies massa nisi in nibh. Suspendisse vel pharetra odio. Fusce neque sapien, commodo in interdum nec, scelerisque vitae nunc. Nunc eu sapien ac justo placerat cursus in eu felis. Maecenas ultrices vestibulum iaculis. Proin vel risus erat, nec consectetur turpis. Etiam odio erat, placerat quis porta vel, euismod vel nibh. Nulla tristique molestie lacinia. Pellentesque molestie enim vel enim condimentum eu imperdiet nulla pellentesque. Ut arcu lectus, sodales eget varius ac, pharetra quis mauris. Quisque odio est, posuere vel auctor ut, elementum nec.

    Read the article

1