Closed sdcb closed 4 months ago
Suggested implementation:
public unsafe partial class ID2D1SvgElement : IEnumerable<ID2D1SvgElement> { public IEnumerator<ID2D1SvgElement> GetEnumerator() { ID2D1SvgElement? child = GetFirstChild(); while (child != null) { yield return child; child = child.GetNextChild(child); } } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<ID2D1SvgElement> DescendantsAndSelf() { yield return this; foreach (ID2D1SvgElement child in this) { foreach (ID2D1SvgElement descendant in child.DescendantsAndSelf()) { yield return descendant; } } } public IEnumerable<ID2D1SvgElement> Descendants() { foreach (ID2D1SvgElement child in this) { yield return child; foreach (ID2D1SvgElement grandchild in child.Descendants()) { yield return grandchild; } } } public IEnumerable<string> AttributeNames { get { int count = GetSpecifiedAttributeCount(); for (int i = 0; i < count; i++) { GetSpecifiedAttributeNameLength(i, out int nameLength, out _); IntPtr namePtr = Marshal.AllocHGlobal(nameLength); try { bool success = GetSpecifiedAttributeName(i, namePtr, nameLength); if (!success) continue; string attributeName = Marshal.PtrToStringUni(namePtr, nameLength)!; yield return attributeName; } finally { Marshal.FreeHGlobal(namePtr); } } } } public string TagName {get;} // from GetTagName/GetTagNameLength public string TextValue {get;} // from GetTextValue/GetTextValueLength }
I wants to do PR, however for reason unknown code doesn't compile in my local machine, please try help.
Some improvements landed here:
https://github.com/amerkoleci/Vortice.Windows/commit/fc1540a9d82cc60e49224225a43eaa4007ecd6b7
Fixed by https://github.com/amerkoleci/Vortice.Windows/commit/47c698455bea71896f717bcb19e553d6a95518a7
Suggested implementation:
I wants to do PR, however for reason unknown code doesn't compile in my local machine, please try help.