예제 #1
0
        public void Execute()
        {
            MobeelizerConfigurationSection section = (MobeelizerConfigurationSection)ConfigurationManager.GetSection("mobeelizer-configuration");
            String propUrl = null;

            String mode = null;

            try
            {
                propUrl = section.AppSettings[META_URL].Value;
            }
            catch (KeyNotFoundException) { }

            try
            {
                mode = section.AppSettings[META_MODE].Value;
            }
            catch (KeyNotFoundException) { }

            StringBuilder baseUrlBuilder = new StringBuilder();

            if (propUrl == null)
            {
                baseUrlBuilder.Append(Resources.Config.c_apiURL_host);
            }
            else
            {
                baseUrlBuilder.Append(propUrl);
            }

            baseUrlBuilder.Append(Resources.Config.c_apiURL_path);

            if ("test".Equals(mode.ToLower()))
            {
                baseUrlBuilder.Append("?test=true");
            }
            else
            {
                baseUrlBuilder.Append("?test=false");
            }
            baseUrlBuilder.Append("&disablecache=" + Guid.NewGuid());

            Uri url = new Uri(baseUrlBuilder.ToString());

            request = WebRequest.Create(url);
            request.BeginGetResponse(OnBeginGetResponse, null);
        }
예제 #2
0
        internal static MobeelizerApplication CreateApplication()
        {
            MobeelizerApplication application = new MobeelizerApplication();

            application.tombstoningManager = new MobeelizerTombstoningManager(application);
            MobeelizerConfigurationSection section = (MobeelizerConfigurationSection)ConfigurationManager.GetSection("mobeelizer-configuration");

            if (section == null)
            {
                throw new ConfigurationException("'mobeelizer-configuration' section not found in app.config file. Check if app.config is not missing and if file Build Action is set to Content.");
            }

            String device;
            String entityPackage;
            String definitionXml;
            String developmentRole;
            String url;
            String stringMode;
            int    databaseVersion = 1;

            try
            {
                device = section.AppSettings[META_DEVICE].Value;
            }
            catch (KeyNotFoundException)
            {
                throw new ConfigurationException(META_DEVICE + " must be set in app.config file.");
            }

            try
            {
                entityPackage = section.AppSettings[META_PACKAGE].Value;
            }
            catch (KeyNotFoundException)
            {
                throw new ConfigurationException(META_PACKAGE + " must be set in app.config file.");
            }

            try
            {
                definitionXml = section.AppSettings[META_DEFINITION_ASSET].Value;
            }
            catch (KeyNotFoundException) { definitionXml = "application.xml"; }

            try
            {
                developmentRole = section.AppSettings[META_DEVELOPMENT_ROLE].Value;
            }
            catch (KeyNotFoundException) { developmentRole = null; }

            try
            {
                String strDatabaseVersion = section.AppSettings[META_DATABASE_VERSION].Value;
                if (!Int32.TryParse(strDatabaseVersion, out databaseVersion))
                {
                    throw new ConfigurationException(META_DATABASE_VERSION + " must be natural number.");
                }
            }
            catch (KeyNotFoundException) { databaseVersion = 1; }

            try
            {
                url = section.AppSettings[META_URL].Value;
            }
            catch (KeyNotFoundException) { url = null; }

            try
            {
                stringMode = section.AppSettings[META_MODE].Value;
            }
            catch (KeyNotFoundException)
            {
                throw new ConfigurationException(META_MODE + " must be set in app.config file.");
            }

            application.initApplication(device, entityPackage, developmentRole, definitionXml, databaseVersion, url, stringMode);
            return(application);
        }