Example #1
0
        /// <summary>
        /// Gets all custom properties.
        /// </summary>
        /// <returns>a dictionary of names and string-values of properties</returns>
        public Dictionary <String, String> GetAllCustomProperties()
        {
            Dictionary <String, String> properties = new Dictionary <String, String>();

            if (xDocumentProperties != null)
            {
                XPropertyContainer customProperties = xDocumentProperties.getUserDefinedProperties();
                if (customProperties != null && customProperties is XPropertySet)
                {
                    if (customProperties != null && customProperties is XPropertySet)
                    {
                        XPropertySetInfo info = ((XPropertySet)customProperties).getPropertySetInfo();
                        if (info != null)
                        {
                            foreach (Property p in info.getProperties())
                            {
                                if (p != null)
                                {
                                    var val = ((XPropertySet)customProperties).getPropertyValue(p.Name);
                                    if (val.hasValue())
                                    {
                                        properties.Add(p.Name, val.Value.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(properties);
        }
Example #2
0
        internal static Dictionary <String, uno.Any> GetAllProperties(Object obj)
        {
            // Debug.GetAllInterfacesOfObject(obj);
            Dictionary <String, uno.Any> props = new Dictionary <string, uno.Any>();

            if (obj != null && obj is XPropertySet)
            {
                XPropertySetInfo bla = ((XPropertySet)obj).getPropertySetInfo();
                if (bla != null)
                {
                    Property[]    properties = bla.getProperties();
                    List <String> storable   = new List <string>();

                    foreach (Property item in properties)
                    {
                        if (item != null)
                        {
                            OO.PropertyAttribute att = ((OO.PropertyAttribute)item.Attributes);
                            //if (item.Attributes == 0) { storable.Add(item.Name); }
                            if (!att.HasFlag(OO.PropertyAttribute.READONLY))
                            {
                                //if (att.HasFlag(OO.PropertyAttribute.MAYBEDEFAULT))
                                //{
                                //}
                                storable.Add(item.Name);
                            }
                        }
                    }

                    try
                    {
                        if (obj is XMultiPropertySet)
                        {
                            var values = ((XMultiPropertySet)obj).getPropertyValues(storable.ToArray());

                            if (values.Length == storable.Count)
                            {
                                for (int i = 0; i < values.Length; i++)
                                {
                                    props.Add(storable[i], values[i]);
                                }
                            }
                            else
                            {
                                // does not get all values
                            }

                            return(props);
                        }
                    }
                    catch (Exception ex) { }
                }
            }
            return(null);
        }