Esempio n. 1
0
        public static string GetPropertyValue(this Microsoft.Deployment.WindowsInstaller.Session session, string propName, string featureName, bool tryWithoutFeature)
        {
            string featurePropName = propName;

            if (
                !string.IsNullOrEmpty(featureName) && // if belongs to a feature
                propName.Equals(propName.ToUpper())    // if it is a public property (upper case)
                )
            {
                featurePropName = string.Format("{0}_{1}", propName, featureName);
            }

            Func <string, string> valueGetter = (name) =>
            {
                if (session.IsInDeferredMode())
                {
                    return(session.CustomActionData[name]);
                }
                else
                {
                    return(session[name]);
                }
            };
            var ret = valueGetter(featurePropName);

            if (string.IsNullOrEmpty(ret) && !featurePropName.Equals(propName))
            {
                ret = valueGetter(propName);
            }
            return(ret);
        }
Esempio n. 2
0
 public static void ShowErrorMessage(this Microsoft.Deployment.WindowsInstaller.Session session, Exception ex)
 {
     Microsoft.Deployment.WindowsInstaller.Record record = new Microsoft.Deployment.WindowsInstaller.Record();
     record.FormatString = ex.ToString();
     session.Message(
         Microsoft.Deployment.WindowsInstaller.InstallMessage.Error | (Microsoft.Deployment.WindowsInstaller.InstallMessage)System.Windows.Forms.MessageBoxButtons.OK | (Microsoft.Deployment.WindowsInstaller.InstallMessage)System.Windows.Forms.MessageBoxIcon.Error,
         record);
 }
Esempio n. 3
0
        public static bool GetBooleanPropertyValue(this Microsoft.Deployment.WindowsInstaller.Session session, string propName, string featureName, bool tryWithoutFeature)
        {
            var  stringValue = GetPropertyValue(session, propName, featureName, tryWithoutFeature);
            bool ret;

            bool.TryParse(stringValue, out ret);
            return(ret);
        }
Esempio n. 4
0
 public static void SetPropertyValue(this Microsoft.Deployment.WindowsInstaller.Session session, string propName, string propValue)
 {
     if (session.IsInDeferredMode())
     {
         session.CustomActionData[propName] = propValue;
     }
     else
     {
         session[propName] = propValue;
     }
 }
Esempio n. 5
0
        public static WindowHandleWrapper InstallerWindowWrapper(this Microsoft.Deployment.WindowsInstaller.Session session)
        {
            var title = session.GetPropertyValue(PropertyNames.ProductName);
            var ret   = new WindowHandleWrapper(title + " Setup");

            if (ret.Handle == IntPtr.Zero)
            {
                ret = new WindowHandleWrapper(title);
            }
            return(ret);
        }
Esempio n. 6
0
        public static Version GetDetectedOlderVersion(this Microsoft.Deployment.WindowsInstaller.Session session)
        {
            var olderVersionProductCodeProp = session.GetPropertyValue(PropertyNames.OlderVersionDetected);

            if (!string.IsNullOrEmpty(olderVersionProductCodeProp))
            {
                var productCodes = olderVersionProductCodeProp.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                var versions     = from code in productCodes
                                   join prod in Microsoft.Deployment.WindowsInstaller.ProductInstallation.AllProducts.AsQueryable() on code equals prod.ProductCode
                                   select prod.ProductVersion;
                if (versions.Count() > 0)
                {
                    return(versions.Max());
                }
            }
            return(null);
        }
Esempio n. 7
0
 public SessionWrapper(Microsoft.Deployment.WindowsInstaller.Session session)
 {
     this._session = session;
 }
Esempio n. 8
0
 public static InstallUILevel UiLevel(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     return((InstallUILevel)int.Parse(session.GetPropertyValue("UILevel")));
 }
Esempio n. 9
0
 public static string GetInstallDirProperty(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     return(CprBroker.Utilities.Strings.EnsureDirectoryEndSlash(session.GetPropertyValue(PropertyNames.InstallDir)));
 }
Esempio n. 10
0
 public static bool GetBooleanPropertyValue(this Microsoft.Deployment.WindowsInstaller.Session session, string propName, string featureName)
 {
     return(GetBooleanPropertyValue(session, propName, featureName, false));
 }
Esempio n. 11
0
 public static string GetPropertyValue(this Microsoft.Deployment.WindowsInstaller.Session session, string propName)
 {
     return(GetPropertyValue(session, propName, ""));
 }
Esempio n. 12
0
 public static bool IsOlderVersionDetected(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     return(!string.IsNullOrEmpty(session.GetPropertyValue(PropertyNames.OlderVersionDetected)));
 }
Esempio n. 13
0
 public static bool IsPatching(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     return(!string.IsNullOrEmpty(session.GetPropertyValue(PropertyNames.Patch)));
 }
Esempio n. 14
0
 public static bool IsInDeferredMode(this Microsoft.Deployment.WindowsInstaller.Session session)
 {
     return(session.GetMode(Microsoft.Deployment.WindowsInstaller.InstallRunMode.Scheduled) || session.GetMode(Microsoft.Deployment.WindowsInstaller.InstallRunMode.Rollback) || session.GetMode(Microsoft.Deployment.WindowsInstaller.InstallRunMode.Commit));
 }