refactor: 枚举移入Models目录,命名空间更新为Rainbow.Entity.Models
大石头 authored at 2026-07-02 12:54:58
859.00 B
RainbowBridge
using System;
using System.Runtime.InteropServices;

namespace Rainbow.Services;

/// <summary>适配器工厂。根据当前操作系统自动选择适配器</summary>
public static class AdapterFactory
{
    private static IOSAdapter? _adapter;

    /// <summary>获取当前平台的适配器实例(单例)</summary>
    public static IOSAdapter Create()
    {
        if (_adapter != null) return _adapter;

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            _adapter = new DebianAdapter();
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            _adapter = new WindowsAdapter();
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            _adapter = new MacAdapter();
        else
            _adapter = new WindowsAdapter(); // 未知平台回退

        return _adapter;
    }
}