Ejemplo n.º 1
0
        IEnumerable <XamlNodeInfo> GetObjectMemberNodes(XamlObject xobj)
        {
            var xce = GetNodeMembers(xobj, value_serializer_ctx).GetEnumerator();

            while (xce.MoveNext())
            {
                // XamlLanguage.Items does not show up if the content is empty.
                if (xce.Current.Member == XamlLanguage.Items)
                {
                    // FIXME: this is nasty, but this name resolution is the only side effect of this iteration model. Save-Restore procedure is required.
                    NameResolver.Save();
                    try
                    {
                        if (!GetNodes(xce.Current.Member, xce.Current.Value).GetEnumerator().MoveNext())
                        {
                            continue;
                        }
                    }
                    finally
                    {
                        NameResolver.Restore();
                    }
                }

                // Other collections as well, but needs different iteration (as nodes contain GetObject and EndObject).
                if (!xce.Current.Member.IsWritePublic && xce.Current.Member.Type != null && xce.Current.Member.Type.IsCollection)
                {
                    var e = GetNodes(xce.Current.Member, xce.Current.Value).GetEnumerator();
                    // FIXME: this is nasty, but this name resolution is the only side effect of this iteration model. Save-Restore procedure is required.
                    NameResolver.Save();
                    try
                    {
                        if (!(e.MoveNext() && e.MoveNext() && e.MoveNext())) // GetObject, EndObject and more
                        {
                            continue;
                        }
                    }
                    finally
                    {
                        NameResolver.Restore();
                    }
                }

                foreach (var cn in GetMemberNodes(xce.Current, GetNodes(xce.Current.Member, xce.Current.Value)))
                {
                    yield return(cn);
                }
            }
        }