Exemple #1
0
        protected internal virtual void UpdatePageDefinition(PageDefinition pageDefinition, PageTypePropertyDefinition pageTypePropertyDefinition)
        {
            string oldValues = SerializeValues(pageDefinition);

            UpdatePageDefinitionValues(pageDefinition, pageTypePropertyDefinition);

            if (SerializeValues(pageDefinition) != oldValues)
            {
                PageDefinitionFactory.Save(pageDefinition);
            }
        }
Exemple #2
0
        protected internal virtual PageDefinition CreateNewPageDefinition(PageTypePropertyDefinition propertyDefinition)
        {
            PageDefinition pageDefinition = new PageDefinition();

            pageDefinition.PageTypeID  = propertyDefinition.PageType.ID;
            pageDefinition.Name        = propertyDefinition.Name;
            pageDefinition.EditCaption = propertyDefinition.GetEditCaptionOrName();
            SetPageDefinitionType(pageDefinition, propertyDefinition);

            PageDefinitionFactory.Save(pageDefinition);

            return(pageDefinition);
        }
Exemple #3
0
        protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
        {
            var prop =
                pageTypeDefinition.Type.GetProperties().Where(p => p.Name == propertyDefinition.Name).FirstOrDefault
                    ();

            var attributes = prop.GetCustomAttributes(typeof(PropertySettingsAttribute), true);

            foreach (var attribute in attributes)
            {
                PropertySettingsContainer container;

                if (pageDefinition.SettingsID == Guid.Empty)
                {
                    pageDefinition.SettingsID = Guid.NewGuid();
                    PageDefinitionFactory.Save(pageDefinition);
                    container = new PropertySettingsContainer(pageDefinition.SettingsID);
                }
                else
                {
                    if (!_propertySettingsRepository.TryGetContainer(pageDefinition.SettingsID, out container))
                    {
                        container = new PropertySettingsContainer(pageDefinition.SettingsID);
                    }
                }
                var settingsAttribute = (PropertySettingsAttribute)attribute;
                var wrapper           = container.GetSetting(settingsAttribute.SettingType);
                if (wrapper == null)
                {
                    wrapper = new PropertySettingsWrapper();
                    container.Settings.Add(settingsAttribute.SettingType.FullName, wrapper);
                }

                bool settingsAlreadyExists = true;
                if (wrapper.PropertySettings == null)
                {
                    wrapper.PropertySettings = (IPropertySettings)Activator.CreateInstance(settingsAttribute.SettingType);
                    settingsAlreadyExists    = false;
                }

                if (settingsAlreadyExists && !settingsAttribute.OverWriteExistingSettings)
                {
                    return;
                }

                if (settingsAttribute.UpdateSettings(wrapper.PropertySettings) || !settingsAlreadyExists)
                {
                    _propertySettingsRepository.Save(container);
                }
            }
        }