Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So firstly, there's probably a few places where these kinds of issues have already been solved - for C#, for example, have a look at <strong>Mono/Xamarin Studio</strong>. But if you're more interested in a general approach (I'll use saving data as the use case for examples):</p> <p>Look at it from the perspective of your shared library - what kind of function calls do you want to make from the shared library into the platform-specific code. This defines the interface from the shared library to the platform-specific code. E.g.</p> <pre><code>Save(data) </code></pre> <p>Once you've got that worked out, it's then a matter of implementing the platform-specific code to fulfil those functions. Since each platform has different mechanisms for any given task, you will probably need some kind of co-ordination layer that understands the sequence of actions needed to enact the desired outcomes on that specific platform. E.g</p> <p><em><strong>Platform A (check permissions + file)</em></strong></p> <pre><code>int Save(byte[] data) { var isAllowed = CheckPermissions(); if(isAllowed) { var dataFile = GetDataFile(); return SaveToFile(dataFile, data); } return -1; } </code></pre> <p><em><strong>Platform B (database)</em></strong></p> <pre><code>int Save(byte[] data) { var database = GetDatabase(); var targetTable = GetTable(database, "temp"); return AppendToTable(database, targetTable, data); } </code></pre> <p>The co-ordination layer could in turn call lower-level libraries to enact the individual actions - this may or may not make sense depending on whether there are lower-level functions that would be shared across various functions at the co-ordination level. E.g. candidates for shared use might be (from above)</p> <p><em><strong>Platform A</em></strong></p> <pre><code>CheckPermissions() GetDataFile() SaveToFile(File file, byte[] data) </code></pre> <p><em><strong>Platform B</em></strong></p> <pre><code>GetDataBase() GetTable(Database database, string tableName) AppendToTable(Database database, Table table, byte[] data) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload