Exemple #1
0
        private static string InvariantToString(object obj)
        {
            if (Reflector.HasToString(obj))
            {
                var objStr = string.Format(CultureInfo.InvariantCulture, @"{0}", obj);
                var type   = obj.GetType();
                if (type == typeof(bool) || type == typeof(int))
                {
                    return(AuditLogParseHelper.GetParseString(ParseStringType.primitive, objStr));
                }
                else if (type == typeof(float) || type == typeof(double))
                {
                    return(AuditLogParseHelper.GetParseString(ParseStringType.primitive,
                                                              string.Format(CultureInfo.InvariantCulture, Program.FunctionalTest ? @"{0:G15}" : @"{0:R}",
                                                                            obj)));
                }
                else if (type.IsEnum)
                {
                    return(LogMessage.Quote(AuditLogParseHelper.GetParseString(ParseStringType.enum_fn, type.Name + '_' + objStr)));
                }
                return(LogMessage.Quote(objStr));
            }

            return(null);
        }
Exemple #2
0
        private static string InvariantToString(object obj, int?decimalPlaces)
        {
            if (Reflector.HasToString(obj))
            {
                var objStr = string.Format(CultureInfo.InvariantCulture, @"{0}", obj);
                var type   = obj.GetType();
                if (type == typeof(bool) || type == typeof(int))
                {
                    return(AuditLogParseHelper.GetParseString(ParseStringType.primitive, objStr));
                }
                else if (type == typeof(float) || type == typeof(double))
                {
                    string format = @"R";
                    if (decimalPlaces.HasValue)
                    {
                        format = @"0." + new string('#', decimalPlaces.Value);
                    }

                    string replacementText = string.Format(@"{{0:{0}}}", format);
                    string decimalText     = string.Format(CultureInfo.InvariantCulture, replacementText, obj);

                    return(AuditLogParseHelper.GetParseString(ParseStringType.primitive, decimalText));
                }
                else if (type.IsEnum)
                {
                    return(LogMessage.Quote(AuditLogParseHelper.GetParseString(ParseStringType.enum_fn, type.Name + '_' + objStr)));
                }
                return(LogMessage.Quote(objStr));
            }

            return(null);
        }
Exemple #3
0
        protected EditDescription EditColumnDescription(string propertyName, object value)
        {
            var    columnCaption       = DataSchema.GetColumnCaption(DataSchema.DefaultUiMode, GetType(), propertyName);
            string auditLogParseString = AuditLogParseHelper.GetParseString(ParseStringType.column_caption,
                                                                            columnCaption.GetCaption(DataSchemaLocalizer.INVARIANT));

            return(new EditDescription(columnCaption, auditLogParseString, GetElementRef(), value));
        }
Exemple #4
0
        public string GetElementName()
        {
            var name = PropertyName;

            if (PropertyInfo.DeclaringType != null)
            {
                name = PropertyInfo.DeclaringType.Name + '_' + name;
            }

            // if resource manager doesnt have resource
            var hasName = PropertyElementNames.ResourceManager.GetString(name) != null;

            if (hasName)
            {
                return(AuditLogParseHelper.GetParseString(ParseStringType.property_element_names, name));
            }

            return(null);
        }
Exemple #5
0
        public string GetName(ObjectInfo <object> objectInfo)
        {
            var name = PropertyName;

            if (PropertyInfo.DeclaringType != null)
            {
                name = PropertyInfo.DeclaringType.Name + '_' + name;
            }

            var localizer = CustomLocalizer;

            if (localizer != null)
            {
                name = localizer.Localize(objectInfo);
                if (PropertyInfo.DeclaringType != null)
                {
                    name = PropertyInfo.DeclaringType.Name + '_' + name;
                }
            }


            return(AuditLogParseHelper.GetParseString(ParseStringType.property_names, name));
        }
Exemple #6
0
 /// <summary>
 /// Returns an EditDescription object for setting a particular column to a particular value.
 /// </summary>
 /// <param name="column">The unlocalized (invariant) name of the column.</param>
 /// <param name="value">The new value that the user changed the property to.</param>
 public static EditDescription SetColumn(string column, object value)
 {
     return(new EditDescription(new ColumnCaption(column),
                                AuditLogParseHelper.GetParseString(ParseStringType.column_caption, column), null, value));
 }