/// <summary>
        /// Compare to
        /// </summary>
        /// <param name="other">Other</param>
        /// <returns>Result</returns>
        public int CompareTo(IStringTranslationObject other)
        {
            int ret = 1;

            if (other != null)
            {
                ret = StringTranslation.CompareTo(other.StringTranslation);
            }
            return(ret);
        }
예제 #2
0
        private void lstKeys_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstKeys.SelectedItems.Count == 0)
            {
                return;
            }

            var selectedKey = lstKeys.SelectedItems[0].Text;

            if (_lastTranslation != null)
            {
                StoreCurrentData();
            }

            txtOld.Text = _parentLocale != null?_parentLocale.GetString(_collection.Key, selectedKey) : string.Empty;

            try
            {
                txtNew.Text = _collection[selectedKey];
            }
            catch (StringNotFoundException)
            {
                _collection.StringsTable.Add(selectedKey, new StringTranslation(selectedKey, string.Empty));
                txtNew.Text = _collection[selectedKey];
            }

            _lastTranslation = _collection.StringsTable[selectedKey];

            chkDerived.Checked = _lastTranslation.DeriveFromParent;

            if (chkMinorUpdate.Visible)
            {
                if (_forceModified)
                {
                    chkMinorUpdate.Checked = true;
                }
                else
                {
                    chkMinorUpdate.Checked = !_lastTranslation.BumpVersion;
                }
            }
            else if (chkUpToDate.Visible)
            {
                chkUpToDate.Checked = _lastTranslation.BumpVersion;
            }

            ReflectCheckboxes();
        }
예제 #3
0
        private static readonly string[] _truths = new string[] { "true", "yes", "on", "1" }; // TODO Remove duplication with SecurityConfiguration

        private static object ParseArgument(ParameterInfo parameter, XmlElement config)
        {
            Debug.Assert(parameter != null);
            Debug.Assert(config != null);

            string name = parameter.Name;
            Type   type = parameter.ParameterType;
            string text;

            XmlAttribute attribute = config.GetAttributeNode(name);

            if (attribute != null)
            {
                text = attribute.Value;
            }
            else
            {
                XmlElement element = config[name];
                if (element == null)
                {
                    return(null);
                }

                text = element.InnerText;
            }

            if (type == typeof(IContextExpression))
            {
                return(new WebDataBindingExpression(text));
            }

            if (type == typeof(Type))
            {
                return(Type.GetType(text, /* throwOnError */ true, /* ignoreCase */ false));
            }

            if (type == typeof(bool))
            {
                text = text.Trim().ToLower(CultureInfo.InvariantCulture);
                return(Boolean.TrueString.Equals(StringTranslation.Translate(Boolean.TrueString, text, _truths)));
            }

            TypeConverter converter = TypeDescriptor.GetConverter(type);

            return(converter.ConvertFromInvariantString(text));
        }
예제 #4
0
        private static readonly string[] _truths = new[] { "true", "yes", "on", "1" }; // TODO Remove duplication with SecurityConfiguration

        private static object ParseArgument(ParameterInfo parameter, XmlElement config)
        {
            Debug.Assert(parameter != null);
            Debug.Assert(config != null);

            var    name = parameter.Name;
            var    type = parameter.ParameterType;
            string text;

            var attribute = config.GetAttributeNode(name);

            if (attribute != null)
            {
                text = attribute.Value;
            }
            else
            {
                var element = config[name];
                if (element == null)
                {
                    return(null);
                }

                text = element.InnerText;
            }

            if (type == typeof(IContextExpression))
            {
                return(new WebDataBindingExpression(text));
            }

            if (type == typeof(Type))
            {
                return(TypeResolution.GetType(text));
            }

            if (type == typeof(bool))
            {
                text = text.Trim().ToLowerInvariant();
                return(Boolean.TrueString.Equals(StringTranslation.Translate(Boolean.TrueString, text, _truths)));
            }

            var converter = TypeDescriptor.GetConverter(type);

            return(converter.ConvertFromInvariantString(text));
        }