Esempio n. 1
0
 public XApplication(XAppInfo applicationInfo)
 {
     this.appView = null;
     this.appInfo = applicationInfo;
     this.isDefaultApp = false;
     this.mode = XAppRunningMode.CreateMode(applicationInfo.RunningMode);
 }
Esempio n. 2
0
        private XApplication BuildApplication(XAppInfo info, String appDirNameInAsset)
        {
            XApplication buildingApp = ams.GetAppList().GetAppById(info.AppId);
            if (null != buildingApp)
            {
                buildingApp.UpdateAppInfo(info);
                buildingApp.AppInfo.IsAssets = true;
            }
            else
            {
                buildingApp = XApplicationCreator.Create(info);
                buildingApp.AppInfo.IsAssets = true;
                XApplicationList list = ams.GetAppList();
                list.Add(buildingApp);
                ams.GetAppPersistence().AddAppToConfig(info.AppId, true);
            }

            // �������app.xml copy������Ŀ¼ �Ա�ǵ�һ�������ʱ��ͳһ�ڹ���Ŀ¼�г�ʼ��
            String targetPath = getAppRoot(buildingApp.AppInfo.AppId)
                    + XConstant.APP_CONFIG_FILE_NAME;
            String configFile = appDirNameInAsset + "\\" + XConstant.APP_CONFIG_FILE_NAME;
            string absSourceFileName = XUtils.BuildabsPathOnInstallationFolder(configFile);
            string absdestFileName = XUtils.BuildabsPathOnIsolatedStorage(targetPath);
            try
            {
                File.Copy(absSourceFileName, absdestFileName, true);
            }
            catch (Exception ex)
            {
                if (ex is ObjectDisposedException || ex is FileNotFoundException|| ex is DirectoryNotFoundException ||
                    ex is ArgumentException || ex is IOException || ex is ArgumentOutOfRangeException ||
                    ex is NotSupportedException)
                {
                    XToastPrompt.GetInstance().Toast(xFaceLibResources.Copy_AppConfig_Error);
                    XLog.WriteError(string.Format("Copy xml file {0} to {1} occur Exception {2}", absSourceFileName, absdestFileName, ex.Message));
                    return null;
                }
                throw ex;
            }

            // ���������ݽ�ѹ��workspace
            String dataPackageName = GetPreinsallDataNameInWorkSpace(appDirNameInAsset);
            if (File.Exists(dataPackageName))
            {
                String path = getAppRoot(info.AppId) + XConstant.APP_WORK_DIR_NAME + "\\";
                string abspath = XUtils.BuildabsPathOnIsolatedStorage(path);
                bool flag = XUtils.unZipFile(dataPackageName, abspath);
                if (!flag)
                {
                    XLog.WriteError("unZipFile:" + dataPackageName + "To path:" + abspath + "fail");
                }
            }
            return buildingApp;
        }
Esempio n. 3
0
 /// <summary>
 /// app的图标URL
 /// </summary>
 /// <param name="app"></param>
 /// <returns></returns>
 public string GetIconURL(XAppInfo appInfo)
 {
     string iconfile = XUtils.GenerateAppIconPath(appInfo.AppId, appInfo.Icon);
     if (null == iconfile)
         return "";
     if (appInfo.Icon.Length <= 0)
         return "";
     string abspath = XUtils.BuildabsPathOnIsolatedStorage(iconfile);
     string url = XConstant.FILE_SCHEME + abspath;
     url = url.Replace('\\', '/');
     return url;
 }
Esempio n. 4
0
 public static XApplication Create(XAppInfo info)
 {
     if (info.Type.Equals(XFACE_APP_XAPP) || info.Type.Equals(XFACE_APP_APP))
     {
         XWebApplication app = new XWebApplication(info);
         return app;
     }
     else if (info.Type.Equals(NATIVE_APP_NAPP))
     {
         XNativeApplication app = new XNativeApplication(info);
         return app;
     }
     return null;
 }
Esempio n. 5
0
        public XNativeApplication(XAppInfo applicationInfo)
            : base(applicationInfo)
        {

        }
        /// <summary>
        /// 从ApplicationSettings中获取所有已安装应用的相关信息,从对应的app.xml获取详细信息.
        /// </summary>
        /// <param name="appList">用于存储已安装应用相关信息的app list</param>
        /// <returns>成功读取app信息并添加到appList中时返回YES,否则返回NO</returns>
        public bool readAppsFromConfig(XApplicationList appList)
        {
            bool ret = false;

            string defaultAppid = getDefaultAppId();
            appList.MarkAsDefaultApp(defaultAppid);

            List<PersistenceAppItem> apps = new List<PersistenceAppItem>();
            if (IsolatedStorageSettings.ApplicationSettings.Contains(USER_APPS))
            {
                apps = IsolatedStorageSettings.ApplicationSettings[USER_APPS] as List<PersistenceAppItem>;
            }

            foreach (PersistenceAppItem persistenceapp in apps)
            {
                string appInstallDir = XSystemConfiguration.GetInstance().AppInstallationDir;
                //~\xFace\apps\appId\app.xml
                string appConfigPath = appInstallDir + persistenceapp.AppId + "\\" + "app.xml";
                ret = File.Exists(XUtils.BuildabsPathOnIsolatedStorage(appConfigPath));
                if (!ret)
                {
                    break;
                }
                XAppInfo appInfo = new XAppInfo().init(appConfigPath);
                if (null == appInfo)
                {
                    ret = false;
                    break;
                }
                else
                {
                    appInfo.IsAssets = persistenceapp.IsAssets;
                    XApplication app = XApplicationCreator.Create(appInfo);
                    appList.Add(app);
                }
            }

            return ret;
        }
Esempio n. 7
0
 /// <summary>
 /// app.xml解析器的构造方法
 /// </summary>
 /// <param name="appXml">待解析的app.xml内容</param>
 public XAppConfigParser(string appXml)
 {
     this.doc = XDocument.Parse(appXml);
     this.appInfo = new XAppInfo();
 }
        private XApplication CreateDefaultApp()
        {
            //读取 player 包中 defaultapp 配置 app.xml
            //xFace_Player/apps/app/app.xml

            string appRoot = XSystemConfiguration.GetInstance().AppInstallationDir + XConstant.DEFAULT_APP_ID_FOR_PLAYER;
            string appConfigPath = appRoot + "\\" + XConstant.APP_CONFIG_FILE_NAME;
            XAppInfo appInfo = new XAppInfo().init(appConfigPath);

            if (null == appInfo)
            {
                appInfo = new XAppInfo();
                appInfo.IsSingleFileUsed = false;
                appInfo.IsEncrypted = false;
                appInfo.Entry = XConstant.DEFAULT_START_PAGE_NAME;
                appInfo.IsAssets = false;
                appInfo.Type = XConstant.APP_TYPE_XAPP;
                appInfo.Name = "Default";
                appInfo.EngineVersion = XSystemConfiguration.GetInstance().XFaceVersion;
            }
            //player 模式默认使用 DEFAULT_APP_ID_FOR_PLAYER
            appInfo.AppId = XConstant.DEFAULT_APP_ID_FOR_PLAYER;
            XApplication app = XApplicationCreator.Create(appInfo);
            return app;
        }
Esempio n. 9
0
 /// <summary>
 /// 设置应用配置信息
 /// </summary>
 /// <param name="appInfo">应用配置信息</param>
 public void UpdateAppInfo(XAppInfo appInfo)
 {
     this.appInfo = appInfo;
 }
Esempio n. 10
0
 public XWebApplication(XAppInfo applicationInfo)
     : base(applicationInfo)
 {
     this.jsEvaluator = new XJavaScriptEvaluator(this);
     this.datas = new Dictionary<string, Object>();
 }