mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Code quality changes [skip ci]
This commit is contained in:
parent
61cfe004c5
commit
798ca503a5
108 changed files with 1981 additions and 2258 deletions
|
@ -89,11 +89,11 @@ namespace Greenshot.IniFile {
|
|||
/// <summary>
|
||||
/// Initialize the ini config
|
||||
/// </summary>
|
||||
/// <param name="applicationName"></param>
|
||||
/// <param name="appName"></param>
|
||||
/// <param name="configName"></param>
|
||||
public static void Init(string appName, string confName) {
|
||||
public static void Init(string appName, string configName) {
|
||||
applicationName = appName;
|
||||
configName = confName;
|
||||
IniConfig.configName = configName;
|
||||
Reload();
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ namespace Greenshot.IniFile {
|
|||
/// <param name="sectionName"></param>
|
||||
/// <returns></returns>
|
||||
public static IniSection GetIniSection(string sectionName) {
|
||||
IniSection returnValue = null;
|
||||
IniSection returnValue;
|
||||
sectionMap.TryGetValue(sectionName, out returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
@ -369,11 +369,10 @@ namespace Greenshot.IniFile {
|
|||
/// </summary>
|
||||
/// <param name="section"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> PropertiesForSection(IniSection section) {
|
||||
Type iniSectionType = section.GetType();
|
||||
public static IDictionary<string, string> PropertiesForSection(IniSection section) {
|
||||
string sectionName = section.IniSectionAttribute.Name;
|
||||
// Get the properties for the section
|
||||
Dictionary<string, string> properties = null;
|
||||
IDictionary<string, string> properties;
|
||||
if (sections.ContainsKey(sectionName)) {
|
||||
properties = sections[sectionName];
|
||||
} else {
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace Greenshot.IniFile {
|
|||
/// Fill the section with the supplied properties
|
||||
/// </summary>
|
||||
/// <param name="properties"></param>
|
||||
public void Fill(Dictionary<string, string> properties) {
|
||||
public void Fill(IDictionary<string, string> properties) {
|
||||
Type iniSectionType = GetType();
|
||||
|
||||
// Iterate over the members and create IniValueContainers
|
||||
|
|
|
@ -229,9 +229,8 @@ namespace Greenshot.IniFile {
|
|||
/// Set the value to the value in the ini file, or default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void SetValueFromProperties(Dictionary<string, string> properties) {
|
||||
public void SetValueFromProperties(IDictionary<string, string> properties) {
|
||||
string propertyName = attributes.Name;
|
||||
string defaultValue = attributes.DefaultValue;
|
||||
string propertyValue = null;
|
||||
if (properties.ContainsKey(propertyName) && properties[propertyName] != null) {
|
||||
propertyValue = containingIniSection.PreCheckValue(propertyName, properties[propertyName]);
|
||||
|
@ -273,7 +272,7 @@ namespace Greenshot.IniFile {
|
|||
object dictionary = Activator.CreateInstance(valueType);
|
||||
MethodInfo addMethodInfo = valueType.GetMethod("Add");
|
||||
bool addedElements = false;
|
||||
Dictionary<string, string> properties = IniConfig.PropertiesForSection(containingIniSection);
|
||||
IDictionary<string, string> properties = IniConfig.PropertiesForSection(containingIniSection);
|
||||
foreach (string key in properties.Keys) {
|
||||
if (key != null && key.StartsWith(propertyName + ".")) {
|
||||
// What "key" do we need to store it under?
|
||||
|
@ -354,6 +353,7 @@ namespace Greenshot.IniFile {
|
|||
/// </summary>
|
||||
/// <param name="valueType">Type to convert tp</param>
|
||||
/// <param name="valueString">string to convert from</param>
|
||||
/// <param name="separator"></param>
|
||||
/// <returns>Value</returns>
|
||||
private static object ConvertStringToValueType(Type valueType, string valueString, string separator) {
|
||||
if (valueString == null) {
|
||||
|
@ -460,7 +460,8 @@ namespace Greenshot.IniFile {
|
|||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
} else if (valueType == typeof(object)) {
|
||||
}
|
||||
if (valueType == typeof(object)) {
|
||||
// object to String, this is the hardest
|
||||
// Format will be "FQTypename[,Assemblyname]:Value"
|
||||
|
||||
|
@ -478,12 +479,11 @@ namespace Greenshot.IniFile {
|
|||
if (assemblyName.StartsWith("Green")) {
|
||||
assemblyName = assemblyName.Substring(0, assemblyName.IndexOf(','));
|
||||
}
|
||||
return String.Format("{0},{1}:{2}", valueTypeName, assemblyName, ourValue);
|
||||
} else {
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(valueType);
|
||||
if (converter != null) {
|
||||
return converter.ConvertToInvariantString(valueObject);
|
||||
}
|
||||
return string.Format("{0},{1}:{2}", valueTypeName, assemblyName, ourValue);
|
||||
}
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(valueType);
|
||||
if (converter != null) {
|
||||
return converter.ConvertToInvariantString(valueObject);
|
||||
}
|
||||
// All other types
|
||||
return valueObject.ToString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue