Exemple #1
0
        /// <inheritdoc/>
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            if (this.custom == null)
            {
                return(string.Empty);
            }

            object valueObject  = null;
            string OutputFormat = format;

            if (string.IsNullOrEmpty(format))
            {
                OutputFormat = "g";
            }

            int intIndex = int.Parse(propertyName);

            if ((this.custom != null) && this.custom.Count > intIndex)
            {
                valueObject = this.custom[intIndex].ToString();
            }

            if (valueObject != null)
            {
                switch (valueObject.GetType().Name)
                {
                case "String":
                    return(PropertyAccess.FormatString((string)valueObject, format));

                case "Boolean":
                    return(PropertyAccess.Boolean2LocalizedYesNo((bool)valueObject, formatProvider));

                case "DateTime":
                case "Double":
                case "Single":
                case "Int32":
                case "Int64":
                    return(((IFormattable)valueObject).ToString(OutputFormat, formatProvider));

                default:
                    return(PropertyAccess.FormatString(valueObject.ToString(), format));
                }
            }
            else
            {
                PropertyNotFound = true;
                return(string.Empty);
            }
        }
Exemple #2
0
        /// <inheritdoc/>
        public virtual string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            if (this.NameValueCollection == null)
            {
                return(string.Empty);
            }

            object valueObject  = this.NameValueCollection[propertyName];
            string OutputFormat = format;

            if (string.IsNullOrEmpty(format))
            {
                OutputFormat = "g";
            }

            if (valueObject != null)
            {
                switch (valueObject.GetType().Name)
                {
                case "String":
                    return(PropertyAccess.FormatString(Convert.ToString(valueObject), format));

                case "Boolean":
                    return(PropertyAccess.Boolean2LocalizedYesNo(Convert.ToBoolean(valueObject), formatProvider));

                case "DateTime":
                case "Double":
                case "Single":
                case "Int32":
                case "Int64":
                    return(((IFormattable)valueObject).ToString(OutputFormat, formatProvider));

                default:
                    return(PropertyAccess.FormatString(valueObject.ToString(), format));
                }
            }
            else
            {
                PropertyNotFound = true;
                return(string.Empty);
            }
        }
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            CultureInfo ci = formatProvider;

            if (propertyName.ToLower() == CultureDropDownTypes.EnglishName.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.EnglishName), format));
            }
            if (propertyName.ToLower() == CultureDropDownTypes.Lcid.ToString().ToLowerInvariant())
            {
                return(ci.LCID.ToString());
            }
            if (propertyName.ToLower() == CultureDropDownTypes.Name.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(ci.Name, format));
            }
            if (propertyName.ToLower() == CultureDropDownTypes.NativeName.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.NativeName), format));
            }
            if (propertyName.ToLower() == CultureDropDownTypes.TwoLetterIsoCode.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(ci.TwoLetterISOLanguageName, format));
            }
            if (propertyName.ToLower() == CultureDropDownTypes.ThreeLetterIsoCode.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(ci.ThreeLetterISOLanguageName, format));
            }
            if (propertyName.ToLower() == CultureDropDownTypes.DisplayName.ToString().ToLowerInvariant())
            {
                return(PropertyAccess.FormatString(ci.DisplayName, format));
            }
            if (propertyName.ToLower() == "languagename")
            {
                if (ci.IsNeutralCulture)
                {
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.EnglishName), format));
                }
                else
                {
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.Parent.EnglishName), format));
                }
            }
            if (propertyName.ToLower() == "languagenativename")
            {
                if (ci.IsNeutralCulture)
                {
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.NativeName), format));
                }
                else
                {
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ci.Parent.NativeName), format));
                }
            }
            if (propertyName.ToLower() == "countryname")
            {
                if (ci.IsNeutralCulture)
                {
                    //Neutral culture do not include region information
                    return("");
                }
                else
                {
                    RegionInfo country = new RegionInfo(new CultureInfo(ci.Name, false).LCID);
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(country.EnglishName), format));
                }
            }
            if (propertyName.ToLower() == "countrynativename")
            {
                if (ci.IsNeutralCulture)
                {
                    //Neutral culture do not include region information
                    return("");
                }
                else
                {
                    RegionInfo country = new RegionInfo(new CultureInfo(ci.Name, false).LCID);
                    return(PropertyAccess.FormatString(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(country.NativeName), format));
                }
            }
            PropertyNotFound = true;
            return(string.Empty);
        }