-
Notifications
You must be signed in to change notification settings - Fork 427
Some style rule updates with fixes to existing violations #4395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
160f542
73c78a3
a765111
d210981
c77b3dc
195f180
e68f8a0
4564e20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,4 +367,3 @@ public void SetVibration(int left, int right) | |
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
|
||
namespace BizHawk.Client.Common | ||
{ | ||
public interface IConfigPersist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this new approach also suffer from #3337? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
{ | ||
public class Provider | ||
{ | ||
private Dictionary<string, object> _data; | ||
|
||
public Provider(Dictionary<string, object> data) | ||
{ | ||
_data = data; | ||
} | ||
|
||
public bool Get<T>(string name, ref T value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't Also call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should have mentioned, using If we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That sounds reasonable to me. The I think the proper way to do fire-and-forget would be a |
||
{ | ||
if (_data.TryGetValue(name, out var val)) | ||
{ | ||
if (val is string str && typeof(T) != typeof(string)) | ||
{ | ||
// if a type has a TypeConverter, and that converter can convert to string, | ||
// that will be used in place of object markup by JSON.NET | ||
|
||
// but that doesn't work with $type metadata, and JSON.NET fails to fall | ||
// back on regular object serialization when needed. so try to undo a TypeConverter | ||
// operation here | ||
var converter = TypeDescriptor.GetConverter(typeof(T)); | ||
val = converter.ConvertFromString(null, CultureInfo.InvariantCulture, str); | ||
} | ||
else if (val is not bool && typeof(T).IsPrimitive) | ||
{ | ||
// numeric constants are similarly hosed | ||
val = Convert.ChangeType(val, typeof(T), CultureInfo.InvariantCulture); | ||
} | ||
|
||
value = (T)val; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Load the provided configuration. | ||
/// </summary> | ||
void LoadConfig(Provider provider); | ||
|
||
/// <summary> | ||
/// Return a dictionary representing the current configuration. | ||
/// </summary> | ||
Dictionary<string, object> SaveConfig(); | ||
YoshiRulz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace BizHawk.Client.Common | ||
{ | ||
/// <summary> | ||
/// When the implementing class also implements <see cref="IToolFormAutoConfig"/>, this interface's method is called when the generated <c>Restore Defaults</c> menu item is clicked. | ||
/// </summary> | ||
public interface IRestoreDefaults | ||
{ | ||
void RestoreDefaults(); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.