Ejemplo n.º 1
0
        static public void GetProps(ObjectWrapper wrapper, XmlElement parent_elem)
        {
            ClassDescriptor klass = wrapper.ClassDescriptor;

            foreach (ItemGroup group in klass.ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }
                    prop = prop.GladeProperty;
                    if (prop.GladeName == null)
                    {
                        continue;
                    }
                    if (!prop.VisibleFor(wrapper.Wrapped))
                    {
                        continue;
                    }

                    string val = PropToString(wrapper, prop);
                    if (val == null)
                    {
                        continue;
                    }

                    XmlElement prop_elem = parent_elem.OwnerDocument.CreateElement("property");
                    prop_elem.SetAttribute("name", prop.GladeName);
                    if (val.Length > 0)
                    {
                        prop_elem.InnerText = val;
                    }

                    if (prop.Translatable && prop.IsTranslated(wrapper.Wrapped))
                    {
                        prop_elem.SetAttribute("translatable", "yes");
                        if (prop.TranslationContext(wrapper.Wrapped) != null)
                        {
                            prop_elem.SetAttribute("context", "yes");
                            prop_elem.InnerText = prop.TranslationContext(wrapper.Wrapped) + "|" + prop_elem.InnerText;
                        }
                        if (prop.TranslationComment(wrapper.Wrapped) != null)
                        {
                            prop_elem.SetAttribute("comments", prop.TranslationComment(wrapper.Wrapped));
                        }
                    }

                    parent_elem.AppendChild(prop_elem);
                }
            }
        }