Пример #1
0
 public dynamic Augment(BetterExpando obj)
 {
     obj._dict
     .Where(pair => !_dict.ContainsKey(pair.Key))
     .ForEach(pair => UpdateDictionary(pair.Key, pair.Value));
       return this;
 }
Пример #2
0
 /// <summary>
 /// Combine two instances together to get a union.
 /// </summary>
 /// <returns>This instance but with additional properties</returns>
 /// <remarks>Existing properties are not overwritten.</remarks>
 public dynamic Augment(BetterExpando obj)
 {
     obj._dict
     .Where(pair => !_dict.ContainsKey(pair.Key))
     .ForEach(pair => UpdateDictionary(pair.Key, pair.Value));
     return(this);
 }
Пример #3
0
        private dynamic LoadGlobalSettings()
        {
            dynamic globalSettings = null;

            globalSettings = new BetterExpando();
            // Set the default template if required
            if (!String.IsNullOrEmpty(_defaultTemplate))
            {
                globalSettings.template = _defaultTemplate;
            }
            else
            {
                globalSettings.template = "no_template_defined";
            }
            globalSettings.title = "Title Not Set";
            return(globalSettings);
        }
Пример #4
0
        public static dynamic GetProperties(this string[] lines)
        {
            dynamic properties = new BetterExpando(ignoreCase: true, returnEmptyStringForMissingProperties: true);

            lines
            .TakeUpTo(line => line.Contains("-->"))
            .Where(line => !String.IsNullOrEmpty(line))
            .ForEach(line =>
            {
                var parts = line.Split('=')
                            .Select(part => part.Trim())
                            .Where(part => part.Length > 0)
                            .ToArray();
                if (parts.Length == 2)
                {
                    properties[parts[0]] = parts[1];
                }
            });
            return(properties);
        }
Пример #5
0
        public virtual string Include(string template, string key = null, string value = null)
        {
            var           templateContent = SiteBuilder.Razor.GetTemplate("~/" + template + ".cshtml");
            BetterExpando viewbag;

            if (key != null && value != null)
            {
                viewbag = new BetterExpando();
                ((dynamic)viewbag)[key] = value;
                viewbag.Augment(this.ViewBag);
            }
            else
            {
                viewbag = this.ViewBag;
            }
            // Render the page at the template
            ITemplate output = SiteBuilder.Razor.Execute(templateContent, this.Model, viewbag: viewbag);

            return(output.Result);
        }
Пример #6
0
 private dynamic LoadGlobalSettings()
 {
     dynamic globalSettings = null;
       globalSettings = new BetterExpando();
       // Set the default template if required
       if (!String.IsNullOrEmpty(_defaultTemplate))
       {
     globalSettings.template = _defaultTemplate;
       }
       else
       {
     globalSettings.template = "no_template_defined";
       }
       globalSettings.title = "Title Not Set";
       return globalSettings;
 }