Пример #1
0
        private AppDesiredState AppDesiredStateFromJson(string pkgFamilyId, JToken jValueToken)
        {
            if (!(jValueToken is JObject))
            {
                return(null);
            }
            JObject jValueObject = (JObject)jValueToken;

            string version = (string)jValueObject.GetValue("version");

            AppDesiredState.DesiredState desiredState = AppDesiredState.DesiredState.Reported;
            if (version == "?")
            {
                desiredState = AppDesiredState.DesiredState.Reported;
            }
            else if (version == "not installed")
            {
                desiredState = AppDesiredState.DesiredState.NotInstalled;
            }
            else
            {
                desiredState = AppDesiredState.DesiredState.Installed;
            }

            AppDesiredState.StartupState startupState = AppDesiredState.StartupState.None;
            string startUp = (string)jValueObject.GetValue("startUp");

            if (startUp == "none")
            {
                startupState = AppDesiredState.StartupState.None;
            }
            else if (startUp == "foreground")
            {
                startupState = AppDesiredState.StartupState.Foreground;
            }
            else if (startUp == "background")
            {
                startupState = AppDesiredState.StartupState.Background;
            }

            string dependencies = (string)jValueObject.GetValue("depsSources");

            string[] dependenciesList = dependencies.Split(';');

            AppDesiredState appDesiredState = new AppDesiredState(
                (string)jValueObject.GetValue("pkgFamilyName"),
                desiredState,
                version,
                startupState,
                (string)jValueObject.GetValue("appxSource"),
                dependenciesList[0],
                dependenciesList.Length > 1 ? dependenciesList[1] : "empty",
                (string)jValueObject.GetValue("certSource"),
                (string)jValueObject.GetValue("certStore"));

            return(appDesiredState);
        }
Пример #2
0
        public void FromJson(JObject jRoot)
        {
            JToken jAppsToken = jRoot.SelectToken("properties.desired.windows.apps");

            if (jAppsToken == null || !(jAppsToken is JObject))
            {
                return;
            }
            JObject jAppsObject = (JObject)jAppsToken;

            List <AppDesiredState> apps = new List <AppDesiredState>();

            foreach (JProperty property in jAppsObject.Children())
            {
                AppDesiredState appDesiredState = AppDesiredStateFromJson(property.Name, property.Value);
                if (appDesiredState != null)
                {
                    apps.Add(appDesiredState);
                }
            }
            AppsConfigurations = apps;
        }