Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private string StartupStateToString(AppDesiredState.StartupState startupState)
        {
            string s = "<unknown>";

            switch (startupState)
            {
            case AppDesiredState.StartupState.None:
                s = "none";
                break;

            case AppDesiredState.StartupState.Foreground:
                s = "foreground";
                break;

            case AppDesiredState.StartupState.Background:
                s = "background";
                break;
            }
            return(s);
        }