示例#1
0
        public override IValue interpret(Context context)
        {
            List <object> toDelete = null;

            if (deletables != null)
            {
                toDelete = new List <object>();
                deletables.ForEach((exp) => CollectDeletables(context, exp, toDelete));
            }
            List <IStorable> toStore = null;

            if (storables != null)
            {
                toStore = new List <IStorable>();
                storables.ForEach((exp) => CollectStorables(context, exp, toStore));
            }
            if (deletables != null || storables != null)
            {
                IAuditMetadata withMeta = null;
                if (metadata != null)
                {
                    IValue value = metadata.interpret(context);
                    if (value is DocumentValue)
                    {
                        DocumentValue doc = (DocumentValue)value;
                        withMeta = DataStore.Instance.NewAuditMetadata();
                        foreach (String name in doc.GetMemberNames())
                        {
                            value          = doc.GetMemberValue(context, name, false);
                            withMeta[name] = value.GetStorableData();
                        }
                    }
                }
                DataStore.Instance.DeleteAndStore(toDelete, toStore, withMeta);
            }
            if (andThen != null)
            {
                andThen.interpret(context);
            }
            return(null);
        }