Now that I've created a Shared Project, how to I use it?

  • Thread starter Thread starter Rod at Work
  • Start date Start date
R

Rod at Work

Guest
We've had a practice of duplicating a lot of code in some of our WPF apps (I suspect MVC apps as well). I recently learned about Shared Projects, so I proposed to my manager that we utilize a Shared Project to help reduce duplication of code. So, I created a Shared Project I called CoreShared. Within CoreShared I duplicated the folder structure of one of our WPF apps, into which I copied XAML and .cs files into the various folders. For example, in the original project there's a folder named Assets. Within Assets is a resource dictionary file named ButtonListResources.xaml. When I reviewed ButtonListResources.xaml I didn't see anything that was dependent upon something specific from the original project, so I copied it into CoreShared | Assets.

Likewise, there's another folder in the original project, named Common, which has a lot of .cs files in it. I reviewed them all and when I identified files that don't appear to me to be unique to the original project, I copied those .cs files out of the original project, into a folder I created in CoreShared, named Common. Of course, I changed the namespace from the original project to CoreShared, both for all of the .xaml and .cs files I copied from the original project, to the CoreShared project, taking into account the folder in CoreShared that I placed that file.

Next I added the Shared Project, to the solution.

Now that I've done all that work, I want to change the original project's reliance upon the .xaml and .cs files to those same files, but in CoreShared. Only, I'm not sure how to go about doing this. For example, here's a reference to one of the .xaml files in the original project, which references ButtonListResources.xaml. Right now it's referencing ButtonListResources.xaml:

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ButtonListResources.xaml" />
</ResourceDictionary.MergedDictionaries>


How do I make it point to ButtonListResources.xaml from in the Assets folder of CoreShared?




Rod

Continue reading...
 
Back
Top