You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to iterate through all the nodes in a group to identify placement information specific to that group it would be very helpful if there was an interface that was used for all elements that have X, Y, Height and Width. As it is now Reflection has to be used to get this information generically and that's a sketchy way to do it.
Getting through Reflection SvgUnit? nodeY = null; SvgUnit? nodeX = null; SvgUnit? nodeHeight = null; SvgUnit? nodeWidth = null; var xProp = node.GetType().GetProperty(nameof(SvgRectangle.X), typeof(SvgUnit)); var yProp = node.GetType().GetProperty(nameof(SvgRectangle.Y), typeof(SvgUnit)); var heightProp = node.GetType().GetProperty(nameof(SvgRectangle.Height), typeof(SvgUnit)); var widthProp = node.GetType().GetProperty(nameof(SvgRectangle.Width), typeof(SvgUnit)); if (xProp != null) nodeX = xProp.GetValue(node) as SvgUnit?; if (yProp != null) nodeY = yProp.GetValue(node) as SvgUnit?; if (heightProp != null) nodeHeight = heightProp.GetValue(node) as SvgUnit?; if (widthProp != null) nodeWidth = widthProp.GetValue(node) as SvgUnit?; //Do Stuff with nodeY, nodeX, nodeHeight and nodeWidth
Getting Through Interface if (node is Svg.ISvgPlacement placement){ //Do Stuff with placement.X, placement.Y, placement.Height and placement.Width }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When trying to iterate through all the nodes in a group to identify placement information specific to that group it would be very helpful if there was an interface that was used for all elements that have X, Y, Height and Width. As it is now Reflection has to be used to get this information generically and that's a sketchy way to do it.
Getting through Reflection
SvgUnit? nodeY = null;
SvgUnit? nodeX = null;
SvgUnit? nodeHeight = null;
SvgUnit? nodeWidth = null;
var xProp = node.GetType().GetProperty(nameof(SvgRectangle.X), typeof(SvgUnit));
var yProp = node.GetType().GetProperty(nameof(SvgRectangle.Y), typeof(SvgUnit));
var heightProp = node.GetType().GetProperty(nameof(SvgRectangle.Height), typeof(SvgUnit));
var widthProp = node.GetType().GetProperty(nameof(SvgRectangle.Width), typeof(SvgUnit));
if (xProp != null) nodeX = xProp.GetValue(node) as SvgUnit?;
if (yProp != null) nodeY = yProp.GetValue(node) as SvgUnit?;
if (heightProp != null) nodeHeight = heightProp.GetValue(node) as SvgUnit?;
if (widthProp != null) nodeWidth = widthProp.GetValue(node) as SvgUnit?;
//Do Stuff with nodeY, nodeX, nodeHeight and nodeWidth
Getting Through Interface
if (node is Svg.ISvgPlacement placement){
//Do Stuff with placement.X, placement.Y, placement.Height and placement.Width
}
Beta Was this translation helpful? Give feedback.
All reactions