AddPreInstallAction() public method

public AddPreInstallAction ( string item ) : Package
item string
return Package
Beispiel #1
0
 private static Package read(string file, string json)
 {
     try {
         var data = JObject.Parse(json);
         var os   = new List <string>();
         data["os"].Children().ToList()
         .ForEach(x => os.Add(x.ToString()));
         var package =
             new Package(
                 os.ToArray(),
                 data["target"].ToString(),
                 data["id"].ToString(),
                 data["version"].ToString(),
                 data["command"].ToString(),
                 data["name"].ToString(),
                 data["description"].ToString());
         var language = data["language"];
         if (language != null)
         {
             package.Language = language.ToString();
         }
         package.File = file;
         if (data["pre-install-actions"] != null)
         {
             data["pre-install-actions"].Children().ToList()
             .ForEach(x => {
                 var action = parseAction(x);
                 package.AddPreInstallAction(action.Action, action.Global);
             });
         }
         if (data["dependencies"] != null)
         {
             data["dependencies"].Children().ToList()
             .ForEach(x =>
                      package.AddDependency(
                          x["id"].ToString(),
                          x["versions"].Children()
                          .Select(y => y.ToString())));
         }
         if (data["post-install-actions"] != null)
         {
             data["post-install-actions"].Children().ToList()
             .ForEach(x => {
                 var action = parseAction(x);
                 package.AddPostInstallAction(action.Action, action.Global);
             });
         }
         if (data["pre-uninstall-actions"] != null)
         {
             data["pre-uninstall-actions"].Children().ToList()
             .ForEach(x => {
                 var action = parseAction(x);
                 package.AddPreUninstallAction(action.Action, action.Global);
             });
         }
         if (data["post-uninstall-actions"] != null)
         {
             data["post-uninstall-actions"].Children().ToList()
             .ForEach(x => {
                 var action = parseAction(x);
                 package.AddPostUninstallAction(action.Action, action.Global);
             });
         }
         if (package.IsValid())
         {
             return(package);
         }
     } catch (Exception ex) {
         Logger.Write(ex);
     }
     return(null);
 }
Beispiel #2
0
 private static Package read(string file, string json)
 {
     try {
         var data = JObject.Parse(json);
         var os = new List<string>();
         data["os"].Children().ToList()
                 .ForEach(x => os.Add(x.ToString()));
         var package =
             new Package(
                 os.ToArray(),
                 data["target"].ToString(),
                 data["id"].ToString(),
                 data["version"].ToString(),
                 data["command"].ToString(),
                 data["name"].ToString(),
                 data["description"].ToString());
         var language = data["language"];
         if (language != null)
             package.Language = language.ToString();
         package.File = file;
         if (data["pre-install-actions"] != null) {
             data["pre-install-actions"].Children().ToList()
                 .ForEach(x => package.AddPreInstallAction(x.ToString()));
         }
         if (data["dependencies"] != null) {
             data["dependencies"].Children().ToList()
                 .ForEach(x =>
                     package.AddDependency(
                         x["id"].ToString(),
                         x["versions"].Children()
                             .Select(y => y.ToString())));
         }
         if (data["post-install-actions"] != null) {
             data["post-install-actions"].Children().ToList()
                 .ForEach(x => package.AddPostInstallAction(x.ToString()));
         }
         if (package.IsValid())
             return package;
     } catch (Exception ex) {
         Logger.Write(ex);
     }
     return null;
 }