15 Aug

Sharing Code with Linked Files

This is a multipart series on how to share code between .Net platforms.  All the examples will be showing how to share between Windows 8 Store applications and Windows Phone 8 application, but the techniques are useful for sharing code between any .Net/Xamarin platforms.

  1. Linked Files
  2. Conditional Compilation
  3. Partial Classes
  4. Inheritance
  5. Dependency Injection

 What are Linked Files?

Linked files are a way for two or more projects to both reference the same file.  One project generally keeps that file under it’s file structure, other projects reference the file there.  You can open the file from any of the projects as you normally would and edit it.  All changes are saved to the one file.

Be Aware

  • You need to manually link the files.  If you have 50 code files you want to share between project, you need to add those 50 files as links individually.
  • If you rename a file that has been shared, you need to delete the old link and add the new link.

How do I do it?

Go through the regular process for adding an existing file, but after you’ve selected the file you need to select “Add as Link” from the dropdown at the bottom.

Link Files Dialog

2 thoughts on “Sharing Code with Linked Files

  1. Pingback: Compiler Directives | FinerCode

  2. Do you want to copy posts from other sources rewrite them
    in seconds and post on your website or use for contextual backlinks?
    You can save a lot of writing work, just search in gogle:
    rheumale’s rewriter

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>