/// <summary> /// private Constructor for deserialization /// </summary> /// <param name="type"></param> /// <param name="message"></param> /// <param name="time"></param> private Log9KEntry(LogEntryTypes type, string message, Log9KTime time) { Message = message; Type = type; Time = time; TypeString = type.ToString(); }
/// <summary> /// /// <remark> /// <para>Do not create entry with type CUSTOM using this constructor, ArgumentException will be raised</para> /// <para>Use constructor for custom type instead</para> /// </remark> /// </summary> /// <param name="type"></param> /// <param name="message"></param> /// <param name="level"></param> public Log9KEntry(LogEntryTypes type, string message, Levels level = Levels.PRIMARY) { if (type == LogEntryTypes.CUSTOM) { throw new ArgumentException( "Данный конструктор не предназначен для создания пользовательских логов" ); } Message = message; Type = type; TypeString = type.ToString(); Time = GetCurrentLog9KTime(); Level = level; if (!IsInnerLog()) { Counter++; ID = Counter; } }
/// <summary> /// Change brush/color for given log entry type /// </summary> /// <param name="type"></param> /// <param name="brush"></param> public bool ChangeTypeColor(LogEntryTypes type, Brush brush) { if (brush == null) { return(false); } string typeNameWithBrush = type.ToString().ToLower().Trim('_') + "brush"; PropertyInfo[] properties = GetType().GetProperties(); foreach (PropertyInfo propertyInfo in properties) { string propertyNameString = propertyInfo.Name.ToLower(); if (propertyNameString == typeNameWithBrush) { if (propertyInfo.PropertyType == typeof(Brush)) { propertyInfo.SetValue(this, brush, null); return(true); } } } return(false); }
/// <summary> /// Get tab by given entry type /// </summary> /// <param name="tabType"></param> /// <returns></returns> private Log9KTab GetTab(LogEntryTypes tabType) { string tabTypeString = tabType.ToString(); return(GetTab(tabTypeString)); }