예제 #1
0
        public static IConditionTreeItem ReadConditionTree(this System.IO.BinaryReader reader)
        {
            byte type = reader.ReadByte();

            if (type == 0)
            {
                // Empty
                return(ConditionTree.Empty);
            }
            else if (type == 1)
            {
                // Tree
                ConditionTree.ConditionOperator op = (ConditionTree.ConditionOperator)reader.ReadUInt16();
                IConditionTreeItem left            = reader.ReadConditionTree();
                IConditionTreeItem right           = reader.ReadConditionTree();
                return(new ConditionTree(op, left, right));
            }
            else if (type == 2)
            {
                ConditionType       conditionType = (ConditionType)reader.ReadInt32();
                ConditionComparison comparison    = (ConditionComparison)reader.ReadInt32();
                string     variableName           = reader.ReadString();
                BinaryType binType;
                object     compareTo = reader.ReadType(out binType);

                return(new ConditionTreeLeaf(conditionType, variableName, comparison, binType.ToPropertyUnion(compareTo)));
            }
            else
            {
                throw new System.IO.InvalidDataException();
            }
        }