void OnResponseV5(EditorHttpResponse response, Action <List <PackageRepository>, List <string> > onResponse)
        {
            if (response.Type == ResponseType.SUCCEED)
            {
                var responseJson =
                    JsonUtility.FromJson <QFrameworkServerResultFormat <ListPackageResponseResult> >(response.Text);

                if (responseJson.code == 1)
                {
                    var listPackageResponseResult = responseJson.data;


                    var packageTypeConfigModel = PackageKitArchitectureConfig.GetModel <IPackageTypeConfigModel>();
                    foreach (var packageRepository in listPackageResponseResult.repositories)
                    {
                        packageRepository.type = packageTypeConfigModel.GetFullTypeName(packageRepository.type);
                    }

                    new PackageInfosRequestCache()
                    {
                        PackageRepositories = listPackageResponseResult.repositories
                    }.Save();

                    onResponse(listPackageResponseResult.repositories, listPackageResponseResult.categories);
                }
            }
            else
            {
                onResponse(null, null);
            }
        }
Пример #2
0
        void OnResponseV5(EditorHttpResponse response, Action <List <PackageRepository>, List <string> > onResponse)
        {
            if (response.Type == ResponseType.SUCCEED)
            {
                var responseJson =
                    JsonUtility.FromJson <QFrameworkServerResultFormat <ListPackageResponseResult> >(response.Text);

                if (responseJson.code == 1)
                {
                    var listPackageResponseResult = responseJson.data;

                    onResponse(listPackageResponseResult.repositories, listPackageResponseResult.categories);
                }
            }
            else
            {
                onResponse(null, null);
            }
        }
Пример #3
0
        void OnResponse(EditorHttpResponse response, Action <List <PackageData> > onResponse)
        {
            if (response.Type == ResponseType.SUCCEED)
            {
                var responseJson =
                    JsonUtility.FromJson <QFrameworkServerResultFormat <List <ResultPackage> > >(response.Text);

                if (responseJson != null && responseJson.code == 1)
                {
                    var packageInfosJson = responseJson.data;

                    var packageDatas = new List <PackageData>();
                    foreach (var packageInfo in packageInfosJson)
                    {
                        var name = packageInfo.name;

                        var package = packageDatas.Find(packageData => packageData.Name == name);

                        if (package == null)
                        {
                            package = new PackageData()
                            {
                                Name = name,
                            };

                            packageDatas.Add(package);
                        }

                        var id              = packageInfo.id;
                        var version         = packageInfo.version;
                        var url             = packageInfo.downloadUrl;
                        var installPath     = packageInfo.installPath;
                        var releaseNote     = packageInfo.releaseNote;
                        var createAt        = packageInfo.createAt;
                        var creator         = packageInfo.username;
                        var releaseItem     = new ReleaseItem(version, releaseNote, creator, DateTime.Parse(createAt), id);
                        var accessRightName = packageInfo.accessRight;
                        var typeName        = packageInfo.type;

                        var packageType = PackageType.FrameworkModule;

                        switch (typeName)
                        {
                        case "fm":
                            packageType = PackageType.FrameworkModule;
                            break;

                        case "s":
                            packageType = PackageType.Shader;
                            break;

                        case "agt":
                            packageType = PackageType.AppOrGameDemoOrTemplate;
                            break;

                        case "p":
                            packageType = PackageType.Plugin;
                            break;

                        case "master":
                            packageType = PackageType.Master;
                            break;
                        }

                        var accessRight = PackageAccessRight.Public;

                        switch (accessRightName)
                        {
                        case "public":
                            accessRight = PackageAccessRight.Public;
                            break;

                        case "private":
                            accessRight = PackageAccessRight.Private;
                            break;
                        }

                        package.PackageVersions.Add(new PackageVersion()
                        {
                            Id          = id,
                            Version     = version,
                            DownloadUrl = url,
                            InstallPath = installPath,
                            Type        = packageType,
                            AccessRight = accessRight,
                            Readme      = releaseItem,
                        });

                        package.readme.AddReleaseNote(releaseItem);
                    }

                    packageDatas.ForEach(packageData =>
                    {
                        packageData.PackageVersions.Sort((a, b) =>
                                                         b.VersionNumber - a.VersionNumber);
                        packageData.readme.items.Sort((a, b) =>
                                                      b.VersionNumber - a.VersionNumber);
                    });

                    onResponse(packageDatas);

                    new PackageInfosRequestCache()
                    {
                        PackageDatas = packageDatas
                    }.Save();
                }
            }
            else
            {
                onResponse(null);
            }
        }