Esempio n. 1
0
        private NativeApiInfo ResolveNativeApiInfo(MahuaPlatform mahuaPlatform)
        {
            string filename;

            switch (mahuaPlatform)
            {
            case MahuaPlatform.Cqp:
                filename = "../Newbe.Mahua/NativeApi/ICqpApi.cs";
                break;

            case MahuaPlatform.Mpq:
                filename = "../Newbe.Mahua/NativeApi/IMpqApi.cs";
                break;

            case MahuaPlatform.CleverQQ:
                filename = "../Newbe.Mahua/NativeApi/ICleverQQApi.cs";
                break;

            case MahuaPlatform.QQLight:
                filename = "../Newbe.Mahua/NativeApi/IQQLightApi.cs";
                break;

            case MahuaPlatform.Amanda:
            default:
                throw new ArgumentOutOfRangeException(nameof(mahuaPlatform), mahuaPlatform, null);
            }

            var apiSourceFile = File.ReadAllText(filename);
            var nativeApiInfo = _nativeApiInfoResolver.GetMahuaApiInfo(apiSourceFile);

            return(nativeApiInfo);
        }
        internal static void DeleteOtherPlatformFile(string dir, MahuaPlatform keepedMahuaPlatform)
        {
            var othersFiles = MahuaPlatforms.Where(x => x != keepedMahuaPlatform).Select(x => $"Newbe.Mahua.{x:G}.*")
                              .ToArray();

            foreach (var othersFile in othersFiles)
            {
                foreach (var file in Directory.GetFiles(dir, othersFile))
                {
                    File.Delete(file);
                }
            }
        }
        public IMahuaPluginPacker Create(MahuaPlatform mahuaPlatform)
        {
            switch (mahuaPlatform)
            {
            case MahuaPlatform.Cqp:
                return(new CqpMahuaPluginPacker(_log));

            case MahuaPlatform.Mpq:
                break;

            case MahuaPlatform.Amanda:
                return(new AmandaMahuaPluginPacker(_log));

            default:
                throw new ArgumentOutOfRangeException(nameof(mahuaPlatform), mahuaPlatform, null);
            }
            throw new ArgumentOutOfRangeException(nameof(mahuaPlatform), mahuaPlatform, null);
        }
Esempio n. 4
0
        private NativeApiInfo ResolveNativeApiInfo(MahuaPlatform mahuaPlatform)
        {
            var basePath = _sourceFileProvider.GetBasePath();
            var filePath = mahuaPlatform switch
            {
                MahuaPlatform.Cqp => "Newbe.Mahua/NativeApi/ICqpApi.cs",
                MahuaPlatform.Mpq => "Newbe.Mahua/NativeApi/IMpqApi.cs",
                MahuaPlatform.QQLight => "Newbe.Mahua/NativeApi/IQQLightApi.cs",
                MahuaPlatform.Amanda => throw new NotSupportedException(),
                      MahuaPlatform.CleverQQ => throw new NotSupportedException(),
                            _ => throw new ArgumentOutOfRangeException(nameof(mahuaPlatform), mahuaPlatform, null)
            };

            var filename = Path.Combine(basePath, filePath);

            var apiSourceFile = File.ReadAllText(filename);
            var nativeApiInfo = _nativeApiInfoResolver.GetMahuaApiInfo(apiSourceFile);

            return(nativeApiInfo);
        }
    }
Esempio n. 5
0
        public NativeApiInfo Get(MahuaPlatform mahuaPlatform)
        {
            var re = Cache.GetOrAdd(mahuaPlatform, ResolveNativeApiInfo);

            return(re);
        }
Esempio n. 6
0
 public static void RegisterPlatformApiHandler <T>(this ContainerBuilder builder, MahuaPlatform mahuaPlatform)
     where T : IPlatformMahuaApiHandler
 {
     Logger.Info($"register {typeof(T).Name} for {mahuaPlatform}");
     builder.RegisterType <T>().Keyed <IPlatformMahuaApiHandler>(mahuaPlatform);
 }