public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer) {
     dynamic stuff = new Stuff();
     foreach (var kv in dictionary) {
         stuff[kv.Key] = kv.Value;
     }
     return stuff;
 }
        public void OnResultExecuting(ResultExecutingContext filterContext) {
            
            // Only need to include scripts on normal view results and not in admin
            // TODO: We could set an option in the context if we want the possibility of admin-side delta
            if (!(filterContext.Result is ViewResult) 
                || Orchard.UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
                return;

            var context = new DeltaInstanceConfiguration();

            foreach (var p in _deltaInstanceProviders) {
                p.Configure(context);
            }

            dynamic stuff = new Stuff();

            var defs = context.Instances.Select(i => {

                foreach (var req in i.Requires) {
                    var settings = _resourceManager.Require(req.ResourceType, req.ResourceName);
                    if (req.Delegate != null) req.Delegate(settings);
                }

                return new {
                    Namespace = i.Namespace,
                    Type = i.TypeName,
                    Properties = i.Properties
                };

            });
            stuff.Instances = defs;
            string json = stuff.Json();
            string jscript = "Delta.Ready(function(){Delta.Configure("+json+");});";
            _resourceManager.RegisterFootScript("<script type=\"text/javascript\" >"+jscript+"</script>");
        }
 public override object SetIndex(Func<object> proceed, object self, IEnumerable<object> keys, object value) {
     if (keys.Count() == 1) {
         // Create the parent stuff
         Stuff stuff = ((dynamic)_parent)[_parentName] = new Stuff();
         // Set the member on it
         return ((dynamic)stuff)[keys.First().ToString()] = value;
     }
     return proceed();
 }
        public dynamic Describe(IContent content) {

            var x = new XElement("Content");
            var context = new ExportContentContext(content.ContentItem,x);

            foreach (var driver in _contentPartDrivers) {
                driver.Exporting(context);
            }

            var stuff = new Stuff(x);
            return stuff;

            // Well that was easy
            // TODO: There is sensitive data we want to be able to exclude
        }
        public override object InvokeMember(Func <object> proceed, object self, string name, INamedEnumerable <object> args)
        {
            Stuff stuff = ((dynamic)_parent)[_parentName] = new Stuff();

            return((stuff as IClayBehaviorProvider).Behavior.InvokeMember(proceed, self, name, args));
        }
 public override object InvokeMember(Func<object> proceed, object self, string name, INamedEnumerable<object> args) {
     Stuff stuff = ((dynamic)_parent)[_parentName] = new Stuff();
     return (stuff as IClayBehaviorProvider).Behavior.InvokeMember(proceed, self, name, args);
 }
 /// <summary>
 /// As soon as a member gets set, we can actually create the stuff
 /// </summary>
 /// <param name="proceed"></param>
 /// <param name="self"></param>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public override object SetMember(Func<object> proceed, object self, string name, object value) {
     // Create the parent stuff
     Stuff stuff = ((dynamic)_parent)[_parentName] = new Stuff();
     // Set the member on it
     return ((dynamic)stuff)[name] = value;
 }
 public DeltaInstanceDescriptor() {
     Properties = new Stuff();
     Requires = new List<DeltaInstanceRequirement>();
 }