对于MyColor中构造函数的简化 #53
Closed
whitecat346
started this conversation in
想法 | Ideas
Replies: 1 comment 1 reply
-
0.0 无人问津 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
MyColor中构造函数有些过于的繁杂了,例如:
public MyColor(float r, float g, float b)
方法和public MyColor(float a, float r, float g, float b)
方法就有些重复,可以使用带默认参数的构造函数以简化;public MyColor(Brush brush)
方法中将brush转为了SolidColorBrush,这个可以委托到public MyColor(SolidColorBrush brush)
方法,然后public MyColor(SolidColorBrush brush)
方法获取了brush的Color属性,这个属性是个Avalonia.Media.Color
,这样可以委托到public MyColor(Color color)
方法。通过这样的方法可以大幅度简化构造函数的复杂度,下面给出我所做的优化:
Beta Was this translation helpful? Give feedback.
All reactions