public static IList <LocalizableComponentPropertiesValues> GetEntityComponentsLocalizableProperties(this CommercePipelineExecutionContext context, Type type)
        {
            var result = new List <LocalizableComponentPropertiesValues>();
            var localizeEntityPolicy = LocalizeEntityPolicy.GetPolicyByType(context.CommerceContext, type);

            if (localizeEntityPolicy?.ComponentsPolicies == null || !localizeEntityPolicy.ComponentsPolicies.Any())
            {
                return(result);
            }

            foreach (var componentsPolicy in localizeEntityPolicy.ComponentsPolicies)
            {
                if (componentsPolicy.Properties == null || !componentsPolicy.Properties.Any())
                {
                    continue;
                }

                var componentProperties = new LocalizableComponentPropertiesValues();
                result.Add(componentProperties);
                componentProperties.Path           = componentsPolicy.Path;
                componentProperties.PropertyValues = new List <LocalizablePropertyValues>();
                foreach (var componentsPolicyProperty in componentsPolicy.Properties)
                {
                    componentProperties.PropertyValues.Add(new LocalizablePropertyValues
                    {
                        PropertyName = componentsPolicyProperty
                    });
                }
            }

            return(result);
        }
        public virtual LocalizableComponentPropertiesValues Map(ILanguageEntity languageEntity, LocalizableComponentPropertiesValues localizableComponentPropertiesValues)
        {
            Type t = typeof(T);

            var component = Activator.CreateInstance(t) as T;

            MapLocalizeValues(component);

            if (localizableComponentPropertiesValues == null)
            {
                var entityComponentsLocalizableProperties =
                    LocalizablePropertyListManager.GetEntityComponentProperties(ComponentHandler.GetEntityType(),
                                                                                Context);

                if (entityComponentsLocalizableProperties == null || !entityComponentsLocalizableProperties.Any())
                {
                    return(null);
                }

                var path = GetLocalizableComponentPath(component);

                var componentProperties =
                    entityComponentsLocalizableProperties.FirstOrDefault(x =>
                                                                         x.Path.Equals(path, StringComparison.OrdinalIgnoreCase));

                if (componentProperties == null || !componentProperties.PropertyValues.Any())
                {
                    return(null);
                }

                localizableComponentPropertiesValues = componentProperties.Clone();
            }


            var properties = TypePropertyListManager.GetProperties(t);

            foreach (var localizablePropertyValues in localizableComponentPropertiesValues.PropertyValues)
            {
                if (!string.IsNullOrEmpty(localizablePropertyValues.PropertyName))
                {
                    var propertyInfo = properties.FirstOrDefault(x =>
                                                                 x.Name.Equals(localizablePropertyValues.PropertyName, StringComparison.OrdinalIgnoreCase));
                    if (propertyInfo != null)
                    {
                        var propertyValue = propertyInfo.GetValue(component);
                        var parameter     = localizablePropertyValues.Parameters.FirstOrDefault(x =>
                                                                                                x.Key.Equals(languageEntity.Language, StringComparison.OrdinalIgnoreCase));

                        if (parameter == null)
                        {
                            parameter = new Parameter {
                                Key = languageEntity.Language, Value = null
                            };
                            localizablePropertyValues.Parameters.Add(parameter);
                        }

                        parameter.Value = propertyValue;
                    }
                }
            }

            return(localizableComponentPropertiesValues);
        }