Example #1
0
 /// <summary>
 /// Initializes the installer.
 /// </summary>
 /// <remarks>
 /// This method must be called before creating logger for this class.
 /// </remarks>
 /// <param name="serviceName">Service name.</param>
 /// <param name="installerSettings">Installer settings, can be null
 /// in case of uninstallation but it is necessary for the installation
 /// process</param>
 internal static void Initialize(string serviceName, InstallerSettings installerSettings)
 {
     servicename = serviceName;
     settings = installerSettings;
 }
Example #2
0
        private static XElement SerializeInstallerSettings(InstallerSettings installer)
        {
            XElement xInstaller = new XElement("installer");
            if (installer == null)
            {
                return xInstaller;
            }

            if(!string.IsNullOrEmpty(installer.Description))
            {
                XElement xDescription = new XElement("description");
                xDescription.Value = installer.Description;
                xInstaller.Add(xDescription);
            }

            if(!string.IsNullOrEmpty(installer.StartMode) &&
                installer.StartMode != InstallerSettings.DefaultStartModeValue)
            {
                XElement xStartType = new XElement("start-type");
                xStartType.SetAttributeValue("value", installer.StartMode);
                xInstaller.Add(xStartType);
            }

            if (!string.IsNullOrEmpty(installer.Account) &&
                installer.Account != InstallerSettings.DefaultAccountValue)
            {
                XElement xAccount = new XElement("account");
                xAccount.SetAttributeValue("value", installer.Account);
                if (installer.Account == "User")
                {
                    XElement xUserName = new XElement("username");
                    xUserName.Value = installer.User;
                    xAccount.Add(xUserName);

                    XElement xPassword = new XElement("password");
                    xPassword.Value = installer.Password;
                    xAccount.Add(xPassword);
                }
                xInstaller.Add(xAccount);
            }

            if (installer.RequiredServices.Count() > 0)
            {
                XElement xDependedOn = new XElement("depended-on");
                xDependedOn.Value = string.Join(",", installer.RequiredServices);
                xInstaller.Add(xDependedOn);
            }

            return xInstaller;
        }
Example #3
0
 public ServiceSettings()
 {
     Settings = new Settings();
     InstallerSettings = new InstallerSettings();
     TraceLoggerSettings = new TraceLoggerSettings();
 }
Example #4
0
        private static InstallerSettings DeserializeInstallerSettings(XElement xInstaller)
        {
            InstallerSettings result = new InstallerSettings();

            if (xInstaller == null)
            {
                return result;
            }

            // description
            XElement xDescription = xInstaller.XPathSelectElement("./description");
            if (xDescription != null)
            {
                result.Description = xDescription.Value.Trim();
            }

            // startup-type
            XElement xStartType = xInstaller.XPathSelectElement("./start-type");
            if (xStartType != null)
            {
                result.StartMode = xStartType.Attribute(XName.Get("value")).Value.Trim();
            }

            // account
            XElement xAccount = xInstaller.XPathSelectElement("./account");
            if (xAccount != null)
            {
                result.Account = xAccount.Attribute(XName.Get("value")).Value.Trim();

                if (result.Account == "User")
                {
                    // username
                    XElement xUsername = xAccount.XPathSelectElement("./username");
                    result.User = xUsername.Value.Trim();

                    // password
                    XElement xPassword = xAccount.XPathSelectElement("./password");
                    result.Password = xPassword.Value.Trim();
                }
            }

            // depended-on
            XElement xDependedOn = xInstaller.XPathSelectElement("./depended-on");
            if (xDependedOn != null)
            {
                List<string> dependedNames = new List<string>();
                string[] tokens = xDependedOn.Value.Split(',');
                for (int i = 0; i < tokens.Length; i++)
                {
                    string name = tokens[i].Trim();
                    if (!string.IsNullOrEmpty(name))
                    {
                        dependedNames.Add(name);
                    }
                }

                if (dependedNames.Count > 0)
                {
                    result.RequiredServices = dependedNames;
                }
            }

            return result;
        }