示例#1
0
        public Style Add(string formatName, string styleClassName, Style style)
        {
            if (StyleBuilder.CanBuildStyle(style))
            {
                style.Id = Guid.NewGuid();

                if (ExistsKeyInStyleClassAndFormat(formatName, styleClassName, style))
                {
                    DeleteStylesSharingKey(formatName, styleClassName, style);
                    StyleRepository.Add(style);
                }
                else
                {
                    style.Format     = FormatRepository.GetByName(formatName);
                    style.StyleClass = StyleClassRepository.GetByName(styleClassName);

                    StyleRepository.Add(style);
                }

                return(style);
            }
            else
            {
                throw new InvalidStyleException("This style has an invalid format.");
            }
        }
        private IEnumerable <Style> GetStylesWithInheritance(StyleClass styleClass, Format format)
        {
            List <StyleClass> inheritedClasses = new List <StyleClass>();
            StyleClass        selectedClass    = styleClass;

            while (selectedClass != null)
            {
                inheritedClasses.Add(selectedClass);
                selectedClass = selectedClass.BasedOn;
            }
            List <Style> inheritedStyles = new List <Style>();

            for (int i = inheritedClasses.Count - 1; i >= 0; i--)
            {
                StyleClass   inheritedClass      = inheritedClasses.ElementAt(i);
                List <Style> selectedClassStyles = StyleRepository.GetStyles(inheritedClass.Name, format.Name).ToList();
                foreach (Style style in selectedClassStyles)
                {
                    if (inheritedStyles.Exists(s => s.Key.Equals(style.Key)))
                    {
                        inheritedStyles.RemoveAll(s => s.Key.Equals(style.Key));
                    }
                    inheritedStyles.Add(style);
                }
            }
            return(inheritedStyles.AsEnumerable());
        }
示例#3
0
 public List <Style> Get()
 {
     //return styleRepository.GetAllStyles();
     using (var db = new Database1Entities())
     {
         StyleRepository style = new StyleRepository();
         return(style.GetAllStyles(db).ToList());
     }
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmConfiguration"/> class.
 /// </summary>
 internal DotvvmConfiguration()
 {
     DefaultCulture = CultureInfo.CurrentCulture.Name;
     Markup         = new DotvvmMarkupConfiguration();
     RouteTable     = new DotvvmRouteTable(this);
     Resources      = new DotvvmResourceRepository();
     Security       = new DotvvmSecurityConfiguration();
     Runtime        = new DotvvmRuntimeConfiguration();
     Styles         = new StyleRepository(this);
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmConfiguration"/> class.
 /// </summary>
 internal DotvvmConfiguration()
 {
     DefaultCulture = CultureInfo.CurrentCulture.Name;
     Markup         = new DotvvmMarkupConfiguration(new Lazy <JavascriptTranslatorConfiguration>(() => ServiceLocator.GetService <IOptions <JavascriptTranslatorConfiguration> >().Value));
     RouteTable     = new DotvvmRouteTable(this);
     Resources      = new DotvvmResourceRepository();
     Security       = new DotvvmSecurityConfiguration();
     Runtime        = new DotvvmRuntimeConfiguration();
     Styles         = new StyleRepository(this);
 }
示例#6
0
 public void Delete(Guid styleId)
 {
     if (StyleRepository.ExistsById(styleId))
     {
         Style styleToDelete = StyleRepository.GetById(styleId);
         StyleRepository.Delete(styleToDelete);
     }
     else
     {
         throw new MissingStyleException("This style is not in the database");
     }
 }
示例#7
0
        private void DeleteStylesSharingKey(string formatName, string styleClassName, Style style)
        {
            List <Style> allStylesInFormat = GetAll(formatName, styleClassName).ToList();

            foreach (Style styleInFormat in allStylesInFormat)
            {
                if (styleInFormat.Key.Equals(style.Key))
                {
                    StyleRepository.Delete(styleInFormat);
                }
            }
        }
示例#8
0
 public XmlRepositoryItem(StyleRepository repository)
 {
     this.key         = repository.Key;
     this.displayName = repository.Name;
     this.itemType    = repository.ItemType;
     foreach (PropertySetting setting in repository.Settings)
     {
         bool flag = false;
         foreach (string badItem in XmlRepositoryItem.badItems)
         {
             if (badItem == setting.Name)
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             string fullName;
             if (!string.IsNullOrEmpty(setting.FullName))
             {
                 fullName = setting.FullName;
             }
             else if (setting.Property != null)
             {
                 fullName = setting.Property.FullName;
             }
             else
             {
                 continue;
             }
             if (setting.EndValue != null)
             {
                 XmlAnimatedPropertySetting animatedPropertySetting = new XmlAnimatedPropertySetting();
                 animatedPropertySetting.Property = fullName;
                 animatedPropertySetting.Value    = setting.Value;
                 animatedPropertySetting.EndValue = setting.EndValue;
                 this.Add((XmlPropertySetting)animatedPropertySetting);
             }
             else
             {
                 this.Add(new XmlPropertySetting()
                 {
                     Property = fullName,
                     Value    = setting.Value
                 });
             }
         }
     }
 }
示例#9
0
 public StylingVisitor(StyleRepository styleRepo) : this(styleRepo.CreateMatcher())
 { }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryStyleController"/> class.
 /// </summary>
 public CategoryStyleController()
 {
     this.categoryRepository = new CategoryRepository();
     this.styleRepository    = new StyleRepository();
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmConfiguration"/> class.
 /// </summary>
 internal DotvvmConfiguration()
 {
     DefaultCulture = Thread.CurrentThread.CurrentCulture.Name;
     Markup = new DotvvmMarkupConfiguration();
     RouteTable = new DotvvmRouteTable(this);
     Resources = new DotvvmResourceRepository();
     Security = new DotvvmSecurityConfiguration();
     Runtime = new DotvvmRuntimeConfiguration();
     Debug = true;
     Styles = new StyleRepository();
 }
示例#12
0
 public StyleController()
 {
     this.styleRepository = new StyleRepository();
 }
示例#13
0
 public IEnumerable <Style> GetAll(string formatName, string styleClassName)
 {
     return(StyleRepository.GetStyles(styleClassName, formatName));
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CategoryStyleController"/> class.
 /// </summary>
 public CategoryStyleController()
 {
     this.categoryRepository = new CategoryRepository();
     this.styleRepository = new StyleRepository();
 }