DCSIMG
Unity - אלעד כץ | Elad Katz
Sign in | Join | Help

אלעד כץ | Elad Katz

לגו של גדולים

Browse by Tags

שימוש ב Unity באפליקציית ווב - איך לרשום רכיבים כסינגלטון בצורה נכונה פר בקשת HTTP
17 December 11 04:08 PM | eladkatz | 2 comment(s)
Unity הינו רכיב IOC Container מאוד שימושי, ואחד הדברים הראשונים שעושים באפליקציית asp.net mvc זה להשתמש ב-Unity על מנת לבצע רישום ושימוש ברכיבים שונים. לדוגמא, אם רוצים לרשום DbContext של EntityFramework לשימוש עתידי, אפשר לעשות זאת בשתי דרכים קלאסיות. רישום רגיל: container.RegisterType<DbContext>(); ורישום כסינגלטון: container.RegisterType<DbContext>( new ContainerControlledLifetimeManager()); כך ש-Unity מנהל בצורה שונה את ה”חיים” של הרכיב, וכשמבקשים את הרכיב הנ”ל ע”י: container.Resolve<DbContext>...
תגים:, ,
Mef or Unity?
25 January 11 02:45 AM | eladkatz | 1 comment(s)
  MEF or Unity? Recently I started developing a new Silverlight LOB project which required the assistance of Prism (now that it reached v4 and actually works fairly ok with MVVM I’m using it more often). Prism now supports both Unity and MEF, and very actively refuses to take sides.. MEF and Unity are similar in many ways, and many people like to think of MEF as yet another IOC Container. Although this line of thought helps us to see the big-picture, it is a bit wrong; MEF is targeted mainly...