Exemplo n.º 1
0
        private string GetFormatedValue(Cabwiz.RegistryValueTypes type, string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            switch (type)
            {
            case Cabwiz.RegistryValueTypes.SZ:
            case Cabwiz.RegistryValueTypes.MULTI_SZ:
                return(value);

            case Cabwiz.RegistryValueTypes.DWORD:
            {
                int nValue;

                var invariant = System.Globalization.CultureInfo.InvariantCulture;

                var cultures = new System.IFormatProvider[] {
                    System.Globalization.CultureInfo.CurrentUICulture,
                    invariant
                };

                foreach (var culture in cultures)
                {
                    if (int.TryParse(value, System.Globalization.NumberStyles.Integer, culture, out nValue))
                    {
                        return(nValue.ToString(invariant));
                    }
                }

                // If we have reached this point, no parse was successful. Whine a bit.
                throw new FormatException("The value could not a well-formatted 32-bit integer.");
            }

            case Cabwiz.RegistryValueTypes.BINARY:
            {
                throw new NotSupportedException("BINARY data types are not yet supported by the visual editor.");
            }

            default:
            {
                throw new ArgumentOutOfRangeException("type");
            }
            }
        }
Exemplo n.º 2
0
        private Cabwiz.RegistryValueTypes GetValueType()
        {
            var types = new Cabwiz.RegistryValueTypes[] {
                Cabwiz.RegistryValueTypes.String,
                Cabwiz.RegistryValueTypes.BINARY,
                Cabwiz.RegistryValueTypes.DWORD,
                Cabwiz.RegistryValueTypes.MULTI_SZ
            };

            if (this.comboBox1.SelectedIndex > -1 && this.comboBox1.SelectedIndex < types.Length)
            {
                return(types[this.comboBox1.SelectedIndex]);
            }
            else
            {
                return(default(Cabwiz.RegistryValueTypes));
            }
        }
Exemplo n.º 3
0
        private Cabwiz.RegistryValueTypes GetValueType()
        {
            var types = new Cabwiz.RegistryValueTypes[] {
                Cabwiz.RegistryValueTypes.String,
                Cabwiz.RegistryValueTypes.BINARY,
                Cabwiz.RegistryValueTypes.DWORD,
                Cabwiz.RegistryValueTypes.MULTI_SZ
            };

            if (this.comboBox1.SelectedIndex > -1 && this.comboBox1.SelectedIndex < types.Length)
            {
                return types[this.comboBox1.SelectedIndex];
            }
            else
            {
                return default(Cabwiz.RegistryValueTypes);
            }
        }