Exemplo n.º 1
0
            public static void Modify(object instance, string propertyName, object value, bool logDetails = false)
            {
                Log.Debug($"Modify - {propertyName} to {value}");
                PropertyModDetails propertyModDetails = BasePropertyChanger.GetPropertyModDetails(instance, propertyName, logDetails);

                if (propertyModDetails == null || !propertyModDetails.Found)
                {
                    if (logDetails)
                    {
                        Log.Error($"{propertyName} not found in instance.");
                    }
                    return;
                }
                BasePropertyChanger propertyChanger = PropertyChangerFactory.CreateFromModDetails(propertyModDetails, logDetails);

                if (propertyChanger != null)
                {
                    propertyChanger.ValueOverride = value;
                    propertyChanger.ModifyPropertyWithDetails(propertyModDetails);
                }
                else if (logDetails)
                {
                    if (propertyModDetails.attachedPropertyType != null)
                    {
                        Log.Error($"propertyChanger ({propertyName} to {value} of type {propertyModDetails.attachedPropertyType.Name}) is null!");
                    }
                    else
                    {
                        Log.Error($"propertyChanger ({propertyName} to {value}) is null!");
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Call after deserialization...
        /// </summary>
        public void RebuildProperties()
        {
            //Talespire.Log.Indent();
            //LogThis();

            if (Props != null)
            {
                properties = new List <BasePropertyChanger>();

                foreach (PropertyChangerDto propertyChangerDto in Props)
                {
                    if (string.IsNullOrWhiteSpace(propertyChangerDto.FullPropertyPath))
                    {
                        Talespire.Log.Error($"propertyChangerDto.FullPropertyPath for type {propertyChangerDto.Type} with value {propertyChangerDto.Value} is null or empty!");
                        continue;
                    }
                    Talespire.Log.Debug($"{propertyChangerDto.FullPropertyPath}: {propertyChangerDto.Type};");
                    BasePropertyChanger changer = PropertyChangerFactory.CreateFrom(propertyChangerDto);
                    if (changer != null)
                    {
                        Talespire.Log.Debug($"Found property changer ({propertyChangerDto.Type})!");
                        changer.FullPropertyPath = propertyChangerDto.FullPropertyPath;
                        changer.Value            = propertyChangerDto.Value;
                        properties.Add(changer);
                    }
                }
            }

            if (Children != null)
            {
                foreach (CompositeEffect compositeEffect in Children)
                {
                    compositeEffect.RebuildProperties();
                }
            }

            //Talespire.Log.Unindent();
        }