Exemplo n.º 1
0
        public override void AfterUpdateEntity(TEntity t)
        {
            Type thisType = GetType();

            PropertyInfo[]   thisProperties   = thisType.GetProperties();
            TranslateService translateService = ServiceProvider.GetService <TranslateService>();

            foreach (var localization in Localizations)
            {
                Type           localization_Type       = localization.GetType();
                PropertyInfo[] localization_Properties = localization_Type.GetProperties();

                foreach (PropertyInfo localization_Property in localization_Properties)
                {
                    if (localization_Property.IsStringProperty())
                    {
                        PropertyInfo thisProperty = thisProperties.FirstOrDefault(w => w.Name == localization_Property.Name);

                        if (thisProperty == null)
                        {
                            continue;
                        }

                        translateService.UpdateTranslation(
                            thisProperty.GetValue(this, null).ToString(),
                            localization_Property.GetValue(localization, null).ToString(),
                            localization.CultureCode);
                    }
                }
            }
        }