// --- Reflection mechanisms --------------------------------

            static public bool StorePropertiesAndFields(DistEvent e, object obj, bool allProperties = false)
            {
                foreach (System.Reflection.PropertyInfo prop in obj.GetType().GetProperties())
                {
                    if (allProperties || Attribute.IsDefined(prop, typeof(DistProperty)))
                    {
                        if (!e.SetAttributeValue(prop.Name, DynamicType.CreateDynamicType(prop.GetValue(obj), allProperties)))
                        {
                            return(false);
                        }
                    }
                }

                foreach (System.Reflection.FieldInfo field in obj.GetType().GetFields())
                {
                    if (allProperties || Attribute.IsDefined(field, typeof(DistProperty)))
                    {
                        if (!e.SetAttributeValue(field.Name, DynamicType.CreateDynamicType(field.GetValue(obj), allProperties)))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }