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

Introduces registry for localisers & exposes them via Configurator #243

Closed
wants to merge 11 commits into from

Conversation

MehdiK
Copy link
Member

@MehdiK MehdiK commented Apr 25, 2014

Based on #227, that fixes #150 and #218, I made some changes to the signature of the factories based on the discussions we had over at #227, added missing xml documentations to fix the build & fixed the broken tests due to Serbian formatter gone missing on the rebase.

I'd appreciate your review and feedback /cc @justin-edwards @hazzik @mexx

@mexx
Copy link
Collaborator

mexx commented Apr 25, 2014

Looking good 👍

{
_defaultLocaliser = MakeLazy(defaultLocaliser);
_localisers = new Dictionary<string, Lazy<T>>();
foreach (var localiser in localisers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use ToDictionary?

@hazzik
Copy link
Member

hazzik commented Apr 25, 2014

LGTM

@MehdiK
Copy link
Member Author

MehdiK commented Apr 25, 2014

Whoa!! You guys are pretty quick.

I had an idea right after I created the PR and didn't think you'd review this fast! I made a few more changes that simplifies the registration and cleans up registry's constructors a bit. I'd appreciate another review. Sorry :p

@@ -679,6 +680,11 @@ ByteSize.Parse("1.55 tB");
ByteSize.Parse("1.55 tb");
```

##<a id="configuration">Configuration</a>

Custom factories for `Formatter`s, `NumberToWordsConverter`s, and `Ordinalizer`s may be added or updated via `FormatterFactoryManager`, `NumberToWordsConverterFactoryManager`, and `OrdinalizerFactoryManager` using the `SetFactory` method.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I should apply the changes to readme too if you guys are happy with this API.

@justin-edwards
Copy link
Contributor

Writing this on my phone so sorry if the formatting comes out poorly.
I'm still so-so on forcing laziness. I know it makes the code cleaner but it limits how crafty (abusive) users can get. By storing an actual Func<> you allow for users to do (definitely ugly but potentially useful) things like blow over the built in set of localizers with a method that returns a localizer based on entirely different criteria, ignoring CurrentUICulture in favor of some piece of internal state or something entirely different.

That definitely may fall under YAGNI/don't care, though, and if it becomes an issue, as long as the public signature remains Func<>(or an overload taking a one is added at some point), it's something that could be added down the line.

I actually woke up with the idea of offering 2 overloads for my Set, one similar to your method with the new constraint and one that took an instance.

At this point, I'd say FISI and revisit if it becomes an issue.

@MehdiK
Copy link
Member Author

MehdiK commented Apr 25, 2014

@hazzik - thanks for the review. Why do you not like Activator.CreateInstance? I don't mind it tbh. It's implementation details.

@justin-edwards - thanks for the feedback. I think summing up your and @hazzik's feedbacks perhaps we could just add an overload with Func<> too. Thoughts?

@MehdiK
Copy link
Member Author

MehdiK commented Apr 26, 2014

Thanks for the feedback guys. I added a few more commits to address the issues. What do you think?

@justin-edwards
Copy link
Contributor

:shipit: IMO.

@hazzik hazzik changed the title introduces registry for localisers & exposes them via Configurator Introduces registry for localisers & exposes them via Configurator Apr 27, 2014
@MehdiK
Copy link
Member Author

MehdiK commented Apr 27, 2014

Merged now. Thanks for your input guys & thanks for the great effort @justin-edwards.

@MehdiK MehdiK closed this Apr 27, 2014
@MehdiK MehdiK deleted the factories branch April 27, 2014 04:34
MehdiK added a commit that referenced this pull request Apr 27, 2014
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.

Make Configurator.FormatterFactories public
4 participants