-
Notifications
You must be signed in to change notification settings - Fork 201
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
base: master
Are you sure you want to change the base?
Зубакин Ренат #170
Conversation
public Result<Color> GetTagColor(Tag tag) | ||
{ | ||
var color =Color.FromArgb(Random.Next(256), Random.Next(256), Random.Next(256)); | ||
return Result.Result.Ok(color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неудобно так писать, да?
Порешать проблему может implicit operator в резалте, тогда шарп сам будет оборачивать в резалт
TagsCloud/App/App.cs
Outdated
layouter.CreateTagCloud(wordsProvider.GetWords().GetValueOrThrow()); | ||
painter.DrawCloud(layouter.GetTagsCollection().GetValueOrThrow(),layouter.GetImageSize().GetValueOrThrow()); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тогда при подходе который я вышел показал, здесь можно будет не бросать ошибку, а вернуть result с ошибкой, которая выведется на консоль и пользователю будет понятно, что пошло не так
TagsCloud/App/App.cs
Outdated
if (!result.IsSuccess) | ||
{ | ||
Console.WriteLine(result.Error); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно написать еще один экстеншн метод в резалт, который при наличии ошибки будет ее печатать
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ты же добавил implicit operator, можно просто
return color;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну и собственно везде в проекте
TagsCloud/Program.cs
Outdated
var options = CommandLine.Parser.Default.ParseArguments<Options>(args).Value; | ||
var container = ContainerConfig.Configure(options); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как будто отдельный метод напрашивается... Возможно даже extension
@69raccoon96