Exemplo n.º 1
0
        protected override void OnBegin()
        {
            ObservableWWW.Get("http://liangxiegame.com/demo/get_all_demo_info").Subscribe(response =>
            {
                var responseJson        = JObject.Parse(response);
                JArray packageInfosJson = responseJson ["all_demo_info"] as JArray;

                var packageDatas = new List <PackageData> ();
                foreach (var demoInfo in packageInfosJson)
                {
                    var name = demoInfo ["name"].Value <string> ();

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

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

                        packageDatas.Add(package);
                    }

                    var version     = demoInfo ["version"].Value <string> ();
                    var url         = demoInfo ["download_url"].Value <string> ();
                    var installPath = demoInfo ["install_path"].Value <string> ();

                    package.PackageVersions.Add(new PackageVersion()
                    {
                        Version     = version,
                        DownloadUrl = url,
                        InstallPath = installPath
                    });
                }

                packageDatas.ForEach(packageData => packageData.PackageVersions.Sort((a, b) => GetVersionNumber(b.Version) - GetVersionNumber(a.Version)));

                mOnGet.InvokeGracefully(packageDatas);

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

                Finished = true;
            }, e =>
            {
                mOnGet.InvokeGracefully(null);
                Log.E(e);
            });
        }
Exemplo n.º 2
0
        protected override void OnBegin()
        {
            Dictionary <string, string> headers = null;

            if (User.Logined)
            {
                headers = new Dictionary <string, string>()
                {
                    { "Authorization", "Token " + User.Token }
                };
            }

            ObservableWWW.Get("http://liangxiegame.com/api/packages/", headers).Subscribe(response =>
            {
                var responseJson     = JArray.Parse(response);
                var packageInfosJson = responseJson;

                var packageDatas = new List <PackageData> ();
                foreach (var packageInfo in packageInfosJson)
                {
                    var name = packageInfo["name"].Value <string>();

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

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

                        packageDatas.Add(package);
                    }

                    var version      = packageInfo["version"].Value <string>();
                    var url          = packageInfo["file"].Value <string>();           // download_url
                    var installPath  = packageInfo["install_path"].Value <string>();
                    var release_note = packageInfo["release_note"].Value <string>();

                    var releaseItem     = new ReleaseItem(version, release_note, "liangxie", "now");
                    var typeName        = packageInfo["type"].Value <string>();
                    var accessRightName = packageInfo["access_right"].Value <string>();

                    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;
                    }

                    var accessRight = PackageAccessRight.Public;

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

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

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

                    package.readme.AddReleaseNote(releaseItem);
                }

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

                mOnGet.InvokeGracefully(packageDatas);

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

                Finished = true;
            }, e =>
            {
                mOnGet.InvokeGracefully(null);
                Log.E(e);
            });
        }
Exemplo n.º 3
0
 public InstallPackage(PackageData requestPackageData)
 {
     mRequestPackageData = requestPackageData;
 }