{"id":5057,"date":"2014-03-30T18:30:09","date_gmt":"2014-03-30T18:30:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/mef-import-resolution-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:30:09","modified_gmt":"2014-03-30T18:30:09","slug":"mef-import-resolution-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/mef-import-resolution-collection-of-common-programming-errors\/","title":{"rendered":"MEF import resolution-Collection of common programming errors"},"content":{"rendered":"<p>Let&#8217;s say that I have a class with a set of fields marked with <code>[Import]<\/code> attributes where all these fields prohibit recomposition.<\/p>\n<p>At some moment this class is instantiated using <code>new MyClassWithInjectedFields(...)<\/code> and all the corresponding dependencies are injected using the <code>MEF<\/code> framework &#8211; nothing serious, only bijective <code>Export-To-Import<\/code> mapping.<\/p>\n<blockquote>\n<ul>\n<li>\n<p>Is it safe to assume that <em>in this case<\/em> the values of injected fields will <strong>remain the same<\/strong> until the class instance is garbage collected?<\/p>\n<\/li>\n<li>\n<p>Or maybe there are some rare \/ obscure cases when they <em>might<\/em> get changed implicitly by <code>MEF<\/code> in runtime? Perhaps, when someone unloads or reloads the assembly used for dependency resolution?<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n<p><em>(I am new to <code>MEF<\/code> and I&#8217;m not really sure if there is a way affect the dependency graph in runtime, but, well, there obviously might be).<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say that I have a class with a set of fields marked with [Import] attributes where all these fields prohibit recomposition. At some moment this class is instantiated using new MyClassWithInjectedFields(&#8230;) and all the corresponding dependencies are injected using the MEF framework &#8211; nothing serious, only bijective Export-To-Import mapping. Is it safe to assume [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5057","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5057"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5057\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}