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

Зубакин Ренат #170

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SolarHunger
Copy link

public Result<Color> GetTagColor(Tag tag)
{
var color =Color.FromArgb(Random.Next(256), Random.Next(256), Random.Next(256));
return Result.Result.Ok(color);

Choose a reason for hiding this comment

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

Неудобно так писать, да?
Порешать проблему может implicit operator в резалте, тогда шарп сам будет оборачивать в резалт

Comment on lines 22 to 23
layouter.CreateTagCloud(wordsProvider.GetWords().GetValueOrThrow());
painter.DrawCloud(layouter.GetTagsCollection().GetValueOrThrow(),layouter.GetImageSize().GetValueOrThrow());

Choose a reason for hiding this comment

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

Посмотри как тут устроен метод PrepareFileToSend вот хотелось бы что-то типа такого увидеть

public Result<Dictionary<string, int>> GetWords()
{
if (!File.Exists(filename))
throw new FileNotFoundException(filename);

Choose a reason for hiding this comment

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

Тогда при подходе который я вышел показал, здесь можно будет не бросать ошибку, а вернуть result с ошибкой, которая выведется на консоль и пользователю будет понятно, что пошло не так

Comment on lines 28 to 31
if (!result.IsSuccess)
{
Console.WriteLine(result.Error);
}

Choose a reason for hiding this comment

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

Можно написать еще один экстеншн метод в резалт, который при наличии ошибки будет ее печатать

Choose a reason for hiding this comment

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

точнее даже не так, передавать в метод действие, которое необходимо сделать с ошибкой, если она есть

public Result<Color> GetTagColor(Tag tag)
{
var color =Color.FromArgb(Random.Next(256), Random.Next(256), Random.Next(256));
return Result.Ok(color);

Choose a reason for hiding this comment

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

ты же добавил implicit operator, можно просто
return color;

Choose a reason for hiding this comment

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

Ну и собственно везде в проекте

Comment on lines 12 to 13
var options = CommandLine.Parser.Default.ParseArguments<Options>(args).Value;
var container = ContainerConfig.Configure(options);

Choose a reason for hiding this comment

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

А если с аргументами что-то не так?

using (Graphics g = Graphics.FromImage(new Bitmap(1, 1)))
{
var sizeF = g.MeasureString(tag.Key, tag.Value);
rectangle.Size = new Size((int)Math.Ceiling(sizeF.Width), (int)Math.Ceiling(sizeF.Height));

Choose a reason for hiding this comment

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

Как будто отдельный метод напрашивается... Возможно даже extension

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.

2 participants