示例#1
0
        /// <summary>
        /// Recupera o valor do campo do elemento.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="field"></param>
        /// <returns></returns>
        public string GetFieldValue(Element element, SchemeField field)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            int fieldPosition = 0;

            try
            {
                fieldPosition = _fieldsPosition[field.Name];
            }
            catch (KeyNotFoundException ex)
            {
                throw new Exception(string.Format("Field with name \"{0}\" not exists", field.Name), ex);
            }
            object value = element.Values[fieldPosition];

            if (value is bool)
            {
                return((bool)value ? "true" : "false");
            }
            else if (value is DateTime)
            {
                return(((DateTime)value).ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US")));
            }
            else if (value != null)
            {
                return(Convert.ToString(value, System.Globalization.CultureInfo.GetCultureInfo("en-US")));
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Recupera o valor do objeto do campo.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="field"></param>
        /// <returns></returns>
        public object GetFieldObjectValue(Element element, SchemeField field)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            int fieldPosition = 0;

            try
            {
                fieldPosition = _fieldsPosition[field.Name];
            }
            catch (KeyNotFoundException ex)
            {
                throw new Exception(string.Format("Field with name \"{0}\" not exists", field.Name), ex);
            }
            return(element.Values[fieldPosition]);
        }