Exemple #1
0
        public static string GetBody(RenderContext context, Models.Style style)
        {
            if (style == null || string.IsNullOrEmpty(style.Body))
            {
                return(null);
            }

            if (style.Extension == null || style.Extension == "css" || style.Extension == ".css")
            {
                return(style.Body);
            }
            else
            {
                var styleEngines = Kooboo.Sites.Engine.Manager.GetStyle();

                var find = styleEngines.Find(o => o.Extension == style.Extension);
                if (find != null)
                {
                    return(find.Execute(context, style.Source));
                }
                else
                {
                    return(style.Body);
                }
            }
        }
 public StyleViewModel(Models.Style style)
 {
     _style               = style;
     Beers                = new ObservableCollection <Beer>();
     ReloadBeersCommand   = new Command(async() => await ReloadBeers());
     LoadMoreBeersCommand = new Command(async() => await LoadMoreBeers());
 }
Exemple #3
0
 public Models.Style ParseStyle(XmlTextReader reader)
 {
     Models.Style style = new Models.Style();
     var currentNodeName = "";
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element: // The node is an element.
                 currentNodeName = reader.Name;
                 break;
             case XmlNodeType.Text:
                 switch (currentNodeName)
                 {
                     case "NAME":
                         style.Name = reader.Value;
                         break;
                     case "CATEGORY":
                         style.Category = reader.Value;
                         break;
                     case "CATEGORY_NUMBER":
                         style.CategoryNumber = reader.Value;
                         break;
                     case "STYLE_LETTER":
                         style.StyleLetter = reader.Value;
                         break;
                     case "STYLE_GUIDE":
                         style.StyleGuide = reader.Value;
                         break;
                     case "TYPE":
                         Models.StyleType styleType = new Models.StyleType() { Name = reader.Value };
                         using (var context = new Models.ModelsContext())
                         {
                             if (context.StyleTypes.Find(styleType.Name) == null)
                             {
                                 context.StyleTypes.Add(styleType);
                                 context.SaveChanges();
                             }
                         }
                         style.StyleType_Name = reader.Value;
                         break;
                     case "OG_MIN":
                         style.OGMin = float.Parse(reader.Value);
                         break;
                     case "OG_MAX":
                         style.OGMax = float.Parse(reader.Value);
                         break;
                     case "FG_MIN":
                         style.FGMin = float.Parse(reader.Value);
                         break;
                     case "FG_MAX":
                         style.FGMax = float.Parse(reader.Value);
                         break;
                     case "IBU_MIN":
                         style.IBUMin = float.Parse(reader.Value);
                         break;
                     case "IBU_MAX":
                         style.IBUMax = float.Parse(reader.Value);
                         break;
                     case "COLOR_MIN":
                         style.ColorMin = float.Parse(reader.Value);
                         break;
                     case "COLOR_MAX":
                         style.ColorMax = float.Parse(reader.Value);
                         break;
                     case "ABV_MIN":
                         style.ABVMin = float.Parse(reader.Value);
                         break;
                     case "ABV_MAX":
                         style.ABVMax = float.Parse(reader.Value);
                         break;
                     case "CARB_MIN":
                         style.CRABMin = float.Parse(reader.Value);
                         break;
                     case "CARB_MAX":
                         style.CRABMax = float.Parse(reader.Value);
                         break;
                     case "NOTES":
                         style.Notes = reader.Value;
                         break;
                     case "PROFILE":
                         style.Profile = reader.Value;
                         break;
                     case "INGREDIENTS":
                         style.Ingredients = reader.Value;
                         break;
                     case "EXAMPLES":
                         style.Eamples = reader.Value;
                         break;
                 }
                 break;
             case XmlNodeType.EndElement:
                 if (reader.Name == "STYLE")
                 {
                     return style;
                 }
                 break;
         }
     }
     return style;
 }