Add Copy Constructor for C# YogaNode
Summary: Add Copy Constructor for convenience. YogaNode defaultStyle = new YogaNode { Width = 100, Height = 100, }; YogaNode node0 = new YogaNode(defaultStyle) { FlexDirection = YogaFlexDirection.Row, JustifyContent = YogaJustify.FlexEnd, }; YogaNode node1 = new YogaNode(defaultStyle) { AlignItems = YogaAlign.Center, }; Reviewed By: emilsjolander Differential Revision: D4393234 fbshipit-source-id: b4b73071aab4dc1b3ae422969de659380bd0e3ad
This commit is contained in:
committed by
Facebook Github Bot
parent
0acb620159
commit
78e64e3d5b
@@ -36,6 +36,12 @@ namespace Facebook.Yoga
|
||||
}
|
||||
}
|
||||
|
||||
public YogaNode(YogaNode srcNode)
|
||||
: this()
|
||||
{
|
||||
CopyStyle(srcNode);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_measureFunction = null;
|
||||
|
@@ -276,6 +276,36 @@ namespace Facebook.Yoga
|
||||
Assert.AreEqual(100.Px(), node0.MaxHeight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCopyConstructor()
|
||||
{
|
||||
YogaNode node0 = new YogaNode();
|
||||
node0.MaxWidth = 80;
|
||||
|
||||
YogaNode node1 = new YogaNode(node0);
|
||||
Assert.AreEqual(80.Px(), node1.MaxWidth);
|
||||
|
||||
YogaNode node2 = new YogaNode(node1)
|
||||
{
|
||||
MaxHeight = 90,
|
||||
};
|
||||
Assert.AreEqual(80.Px(), node2.MaxWidth);
|
||||
Assert.AreEqual(90.Px(), node2.MaxHeight);
|
||||
|
||||
YogaNode node3 = new YogaNode(node0)
|
||||
{
|
||||
MaxWidth = 100,
|
||||
};
|
||||
Assert.AreEqual(100.Px(), node3.MaxWidth);
|
||||
|
||||
YogaNode node4 = new YogaNode(node2)
|
||||
{
|
||||
MaxWidth = 100,
|
||||
};
|
||||
Assert.AreEqual(100.Px(), node4.MaxWidth);
|
||||
Assert.AreEqual(90.Px(), node4.MaxHeight);
|
||||
}
|
||||
|
||||
private void ForceGC()
|
||||
{
|
||||
GC.Collect(GC.MaxGeneration);
|
||||
|
Reference in New Issue
Block a user