mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Merge remote-tracking branch 'remotes/origin/master' into release/1.2.9
This commit is contained in:
commit
0323705513
276 changed files with 5382 additions and 3666 deletions
|
@ -28,7 +28,7 @@ using log4net;
|
|||
|
||||
namespace Greenshot.IniFile {
|
||||
public class IniConfig {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(IniConfig));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(IniConfig));
|
||||
private const string INI_EXTENSION = ".ini";
|
||||
private const string DEFAULTS_POSTFIX = "-defaults";
|
||||
private const string FIXED_POSTFIX = "-fixed";
|
||||
|
@ -36,22 +36,22 @@ namespace Greenshot.IniFile {
|
|||
/// <summary>
|
||||
/// A lock object for the ini file saving
|
||||
/// </summary>
|
||||
private static object iniLock = new object();
|
||||
private static readonly object iniLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// As the ini implementation is kept someone generic, for reusing, this holds the name of the application
|
||||
/// </summary>
|
||||
private static string applicationName = null;
|
||||
private static string applicationName;
|
||||
|
||||
/// <summary>
|
||||
/// As the ini implementation is kept someone generic, for reusing, this holds the name of the configuration
|
||||
/// </summary>
|
||||
private static string configName = null;
|
||||
private static string configName;
|
||||
|
||||
/// <summary>
|
||||
/// A Dictionary with all the sections stored by section name
|
||||
/// </summary>
|
||||
private static Dictionary<string, IniSection> sectionMap = new Dictionary<string, IniSection>();
|
||||
private static readonly Dictionary<string, IniSection> sectionMap = new Dictionary<string, IniSection>();
|
||||
|
||||
/// <summary>
|
||||
/// A Dictionary with the properties for a section stored by section name
|
||||
|
@ -61,17 +61,17 @@ namespace Greenshot.IniFile {
|
|||
/// <summary>
|
||||
/// A Dictionary with the fixed-properties for a section stored by section name
|
||||
/// </summary>
|
||||
private static Dictionary<string, Dictionary<string, string>> fixedProperties = null;
|
||||
private static Dictionary<string, Dictionary<string, string>> fixedProperties;
|
||||
|
||||
/// <summary>
|
||||
/// Stores if we checked for portable
|
||||
/// </summary>
|
||||
private static bool portableCheckMade = false;
|
||||
private static bool portableCheckMade;
|
||||
|
||||
/// <summary>
|
||||
/// Is the configuration portable (meaning we don't store it in the AppData directory)
|
||||
/// </summary>
|
||||
private static bool portable = false;
|
||||
private static bool portable;
|
||||
public static bool IsPortable {
|
||||
get {
|
||||
return portable;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
@ -28,7 +28,7 @@ namespace Greenshot.IniFile {
|
|||
private const string SECTION_START = "[";
|
||||
private const string SECTION_END = "]";
|
||||
private const string COMMENT = ";";
|
||||
private static char[] ASSIGNMENT = new char[] { '=' };
|
||||
private static readonly char[] ASSIGNMENT = new[] { '=' };
|
||||
|
||||
/**
|
||||
* Read an ini file to a Dictionary, each key is a section and the value is a Dictionary with name and values.
|
||||
|
|
|
@ -34,9 +34,9 @@ namespace Greenshot.IniFile {
|
|||
protected static ILog LOG = LogManager.GetLogger(typeof(IniSection));
|
||||
|
||||
[NonSerialized]
|
||||
private IDictionary<string, IniValue> values = new Dictionary<string, IniValue>();
|
||||
private readonly IDictionary<string, IniValue> values = new Dictionary<string, IniValue>();
|
||||
[NonSerialized]
|
||||
private IniSectionAttribute iniSectionAttribute = null;
|
||||
private IniSectionAttribute iniSectionAttribute;
|
||||
public IniSectionAttribute IniSectionAttribute {
|
||||
get {
|
||||
if (iniSectionAttribute == null) {
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace Greenshot.IniFile {
|
|||
/// A container to be able to pass the value from a IniSection around.
|
||||
/// </summary>
|
||||
public class IniValue {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(IniValue));
|
||||
private PropertyInfo propertyInfo;
|
||||
private FieldInfo fieldInfo;
|
||||
private IniSection containingIniSection;
|
||||
private IniPropertyAttribute attributes;
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(IniValue));
|
||||
private readonly PropertyInfo propertyInfo;
|
||||
private readonly FieldInfo fieldInfo;
|
||||
private readonly IniSection containingIniSection;
|
||||
private readonly IniPropertyAttribute attributes;
|
||||
|
||||
public IniValue(IniSection containingIniSection, PropertyInfo propertyInfo, IniPropertyAttribute iniPropertyAttribute) {
|
||||
this.containingIniSection = containingIniSection;
|
||||
|
@ -216,7 +216,7 @@ namespace Greenshot.IniFile {
|
|||
// Get all the values.
|
||||
while ((bool)moveNext.Invoke(enumerator, null)) {
|
||||
var key = current.Invoke(enumerator, null);
|
||||
var valueObject = item.GetValue(myValue, new object[] { key });
|
||||
var valueObject = item.GetValue(myValue, new[] { key });
|
||||
// Write to ini file!
|
||||
writer.WriteLine("{0}.{1}={2}", attributes.Name, ConvertValueToString(valueType1, key, attributes.Separator), ConvertValueToString(valueType2, valueObject, attributes.Separator));
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ namespace Greenshot.IniFile {
|
|||
LOG.Warn(ex);
|
||||
//LOG.Error("Problem converting " + stringValue + " to type " + type2.FullName, e);
|
||||
}
|
||||
addMethodInfo.Invoke(dictionary, new object[] { newValue1, newValue2 });
|
||||
addMethodInfo.Invoke(dictionary, new[] { newValue1, newValue2 });
|
||||
addedElements = true;
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ namespace Greenshot.IniFile {
|
|||
string arraySeparator = separator;
|
||||
object list = Activator.CreateInstance(valueType);
|
||||
// Logic for List<>
|
||||
string[] arrayValues = valueString.Split(new string[] { arraySeparator }, StringSplitOptions.None);
|
||||
string[] arrayValues = valueString.Split(new[] { arraySeparator }, StringSplitOptions.None);
|
||||
if (arrayValues == null || arrayValues.Length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ namespace Greenshot.IniFile {
|
|||
LOG.Warn("Problem converting " + arrayValue + " to type " + valueType.FullName, ex);
|
||||
}
|
||||
if (newValue != null) {
|
||||
addMethodInfo.Invoke(list, new object[] { newValue });
|
||||
addMethodInfo.Invoke(list, new[] { newValue });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ namespace Greenshot.IniFile {
|
|||
//LOG.Debug("No convertor for " + fieldType.ToString());
|
||||
if (valueType == typeof(object) && valueString.Length > 0) {
|
||||
//LOG.Debug("Parsing: " + valueString);
|
||||
string[] values = valueString.Split(new Char[] { ':' });
|
||||
string[] values = valueString.Split(new[] { ':' });
|
||||
//LOG.Debug("Type: " + values[0]);
|
||||
//LOG.Debug("Value: " + values[1]);
|
||||
Type fieldTypeForValue = Type.GetType(values[0], true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue