Skip to content
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

J2N.Text.StringFormatter: Added constructor overload for IFormatProvider #46

Merged
merged 2 commits into from
Dec 26, 2021

Conversation

NightOwl888
Copy link
Owner

This supersedes #44, which targeted the wrong branch.

This adds a constructor overload accepting IFormatProvider to StringFormatter. Note that while StringFormatter is marked as [Serializable], in .NET Core and newer platforms, none of the IFormatProvider implementations are serializable.

Since in Java, Locale is often used as a field and may be a field of a serializable class, we recommend refactoring the class to accept an IFormatProvider as a method argument rather than using a field, where possible. If that is not possible and serialization is required, it is recommended to create a custom IFormatProvider that wraps the .NET type in order to serialize and deserialize its state. Note that the formatProvider field in StringFormatter will automatically be serialized if serialization is supported by the class.

This also removes FEATURE_CULTUREINFO_DEFAULTTHREADCURRENTCULTURE and FEATURE_CULTUREINFO_DEFAULTTHREADCURRENTUICULTURE, as these were not being used, anyway.

…RENTCULTURE and FEATURE_CULTUREINFO_DEFAULTTHREADCURRENTUICULTURE, since they are not supported anyway
…der and deprecated Culture protected property, since it is easily possible to store the CultureInfo reference in a subclass when calling the appropriate constructor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant