Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I "add" static methods to existing class in the .NET API?
    text
    copied!<p>I want to build a <em>Windows Store class library</em> using source code from a regular <em>.NET Framework class library</em>. Ideally, I do not want to modify the original source code files. </p> <p>In some of the source code files from the <em>.NET Framework library</em>, static members are used from a class that is defined in both the regular <em>.NET Framework</em> API and the <em>.NET for Windows Store apps</em> API, but where only a subset of the <em>.NET Framework</em> members are available for <em>Windows Store</em>.</p> <p>One specific example is <a href="http://msdn.microsoft.com/en-us/library/windows/apps/system.io.path.aspx" rel="nofollow">System.IO.Path</a>, where the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/system.io.path.getfullpath.aspx" rel="nofollow">GetFullPath method</a> is not available for <em>Windows Store apps</em>.</p> <p>It is fairly straightforward to incorporate a replacement for this method in my <em>Windows Store class library</em> and have the original source code invoke this method instead. My question is, is there <strong>any</strong> way I can do this without modifying the original source code file?</p> <p>So far, I have not been able to figure out a satisfactory solution to this problem, but I have solved it for my <em>Windows Store class library</em> by implementing e.g. the <code>Path.GetFullPath(string)</code> method in another namespace:</p> <pre><code>namespace WindowsStoreLib.System.IO { public static class Path { public static string GetFullPath(string path) { ... } } } </code></pre> <p>and then adding a preprocessor directive in the original files:</p> <pre><code>#if NETFX_CORE using Path = WindowsStoreLib.System.IO.Path; #endif </code></pre> <p>Is there an alternative solution to this issue that does <strong>not</strong> require modification of the original source code files?</p>
 

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