플랫폼 종속적 인 내용을 인터페이스에 캡슐화하지 않은 다음 왜 현재 플랫폼에 대한 "올바른"구현을 얻는 지 알 수 있습니다. 그런 다음 호출 코드가 blithely를 사용할 수 있으며 원할 때 Mono를 실행할 비트를 점진적으로 채울 수 있습니다. 나는 것 이상 희망 당신도 P/호출 비트를 포함하는 클래스를로드하지 않을 경우, 당신은 괜찮을해야은 ...
편집 :
내가 볼 수없는 이유는이 방법은 안 비록 당신이 공장을 필요로하지 않을지라도. 여기에 내가 할 줄 작업은 다음과 같습니다
MainForm.cs :
PlatformServicesFacade.InitializeSystemMenu();
IPlatformServices.cs :
public interface IPlatformServices
{
void InitializeSystemMenu();
}
MonoPlatformServices.cs :
public class MonoPlatformServices : IPlatformServices
{
// Prevent early type initialization
static WindowsPlatformServices() {}
public void InitializeSystemMenu()
{
// Maybe log what you would have done?
}
}
WindowsPlatformServices.cs :
public class WindowsPlatformServices : IPlatformServices
{
// Prevent early type initialization
static WindowsPlatformServices() {}
public const Int32 SystemMenuAboutSWikiId = 1000;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
private static extern bool InsertMenu(IntPtr hMenu, Int32 wPosition,
Int32 wFlags, Int32 wIDNewItem,
string lpNewItem);
public void InitializeSystemMenu()
{
const Int32 MF_SEPARATOR = 0x800;
const Int32 MF_BYPOSITION = 0x400;
IntPtr systemMenuPtr = GetSystemMenu(Handle, false);
InsertMenu(systemMenuPtr, 5, MF_BYPOSITION | MF_SEPARATOR, 0, "");
InsertMenu(systemMenuPtr, 6, MF_BYPOSITION, SystemMenuAboutSWikiId,
"About SWiki...");
}
}
PlatformServicesFacade.cs :
public class PlatformServicesFacade
{
private static readonly IPlatformServices services;
static PlatformServiceFacade()
{
services = RunningOnWindows() ? new WindowsPlatformServices()
: (IPlatformServices) new MonoPlatformServices();
}
public static void InitializeSystemMenu()
{
services.InitializeSystemMenu();
}
}
나는 그것을하지 않는 경우, 잘못된 무슨 일이 일어나고 있는지 :)
Swiki가 이미 위키 소프트웨어의 이름이라는 것을 알고 있습니까? http://en.wikipedia.org/wiki/Swiki –
이미 등록을 마친 후에야 조회수가 증가하고 있습니다. 현재 1.0 용으로 이름을 바꾸는 것을 고려하고 있습니다. –