Exemplo n.º 1
0
        public static void OperateFlags(string board_id, string discussion_id, FlagOperation op)
        {
            TableResult        result = Warehouse.DiscussionListTable.Execute(TableOperation.Retrieve(board_id, discussion_id));
            DynamicTableEntity entity = (DynamicTableEntity)result.Result;

            entity.OperateFlags(op);

            Warehouse.DiscussionListTable.Execute(TableOperation.Replace(entity));
            Warehouse.DiscussionListPond.Notify(board_id);
        }
Exemplo n.º 2
0
        public static string Operate(string flags, FlagOperation op)
        {
            if (op.type == FlagOperation.Type.Merge)
            {
                SplitFlags(op.DeltaFlags, (meta_title, meta_value) =>
                {
                    if (Check(flags, meta_title))
                    {
                        flags = Remove(flags, meta_title);
                    }

                    if (meta_value != "0")                              // 0 = default = absence.
                    {
                        flags = Add(flags, meta_title, meta_value);
                    }
                });
            }
            else if (op.type == FlagOperation.Type.AddMultiple)
            {
                SplitFlags(op.DeltaFlags, (meta_title, meta_value) =>
                {
                    int num2 = int.Parse(meta_value);

                    int num = GetNumber(flags, meta_title);
                    flags   = Remove(flags, meta_title);

                    if (num + num2 != 0)
                    {
                        flags = Add(flags, meta_title, num + num2);
                    }
                });
            }
            else if (op.type == FlagOperation.Type.Add)
            {
                int num = GetNumber(flags, op.MetaTitle);
                flags = Remove(flags, op.MetaTitle);

                if (num + op.N != 0)
                {
                    flags = Add(flags, op.MetaTitle, num + op.N);
                }
            }
            else if (op.type == FlagOperation.Type.Multiply)
            {
                int num = GetNumber(flags, op.MetaTitle);
                if (num != 0)
                {
                    flags = Remove(flags, op.MetaTitle);
                    flags = Add(flags, op.MetaTitle, num * op.N);
                }
            }
            return(flags);
        }
Exemplo n.º 3
0
        public static void OperateFlags(this DynamicTableEntity entity, FlagOperation op)
        {
            string flags = entity.GetFlags();

            //flags = SandFlags.Merge(flags, delta_flags);
            flags = SandFlags.Operate(flags, op);

            if (flags.Length > 0)
            {
                entity["flags2"] = new EntityProperty(flags);
            }
            else
            {
                entity.Properties.Remove("flags2");
            }
        }