示例#1
0
        private void WritePropValue(PropValue propValue)
        {
            this.writer.WriteStartElement("Property");
            this.writer.WriteAttributeString("Id", RuleWriter.EnumToString(propValue.PropTag));
            this.writer.WriteAttributeString("DataType", RuleWriter.EnumToString(propValue.PropType));
            object obj  = propValue.Value ?? "(null)";
            string text = obj as string;

            byte[] array = obj as byte[];
            if (text != null)
            {
                this.writer.WriteElementString("Value", text);
            }
            else if (array != null)
            {
                this.WriteBinaryData("Value", array);
            }
            else
            {
                if (obj is IEnumerable)
                {
                    using (IEnumerator enumerator = ((IEnumerable)obj).GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            object obj2  = enumerator.Current;
                            string value = (obj2 == null) ? "(null)" : obj2.ToString();
                            this.writer.WriteElementString("Value", value);
                        }
                        goto IL_114;
                    }
                }
                this.writer.WriteElementString("Value", obj.ToString());
            }
IL_114:
            this.writer.WriteEndElement();
        }
示例#2
0
        private void WriteRestriction(Restriction restriction)
        {
            this.writer.WriteStartElement("Restriction");
            if (restriction != null)
            {
                Restriction.ResType type = restriction.Type;
                this.writer.WriteAttributeString("Type", type.ToString());
                Restriction.ResType resType = type;
                switch (resType)
                {
                case Restriction.ResType.And:
                    this.WriteRestrictions("And", ((Restriction.AndRestriction)restriction).Restrictions);
                    break;

                case Restriction.ResType.Or:
                    this.WriteRestrictions("Or", ((Restriction.OrRestriction)restriction).Restrictions);
                    break;

                case Restriction.ResType.Not:
                    this.writer.WriteStartElement("Not");
                    this.WriteRestriction(((Restriction.NotRestriction)restriction).Restriction);
                    this.writer.WriteEndElement();
                    break;

                case Restriction.ResType.Content:
                {
                    Restriction.ContentRestriction contentRestriction = (Restriction.ContentRestriction)restriction;
                    this.writer.WriteAttributeString("ContentFlags", RuleWriter.EnumToString(contentRestriction.Flags));
                    this.writer.WriteAttributeString("PropTag", RuleWriter.EnumToString(contentRestriction.PropTag));
                    this.writer.WriteAttributeString("MultiValued", contentRestriction.MultiValued.ToString());
                    this.WritePropValue(contentRestriction.PropValue);
                    break;
                }

                case Restriction.ResType.Property:
                {
                    Restriction.PropertyRestriction propertyRestriction = (Restriction.PropertyRestriction)restriction;
                    this.writer.WriteAttributeString("Operation", propertyRestriction.Op.ToString());
                    this.writer.WriteAttributeString("PropTag", RuleWriter.EnumToString(propertyRestriction.PropTag));
                    this.writer.WriteAttributeString("MultiValued", propertyRestriction.MultiValued.ToString());
                    this.WritePropValue(propertyRestriction.PropValue);
                    break;
                }

                case Restriction.ResType.CompareProps:
                {
                    Restriction.ComparePropertyRestriction comparePropertyRestriction = (Restriction.ComparePropertyRestriction)restriction;
                    this.writer.WriteAttributeString("Operation", comparePropertyRestriction.Op.ToString());
                    this.writer.WriteAttributeString("PropTagLeft", RuleWriter.EnumToString(comparePropertyRestriction.TagLeft));
                    this.writer.WriteAttributeString("PropTagRight", RuleWriter.EnumToString(comparePropertyRestriction.TagRight));
                    break;
                }

                case Restriction.ResType.BitMask:
                {
                    Restriction.BitMaskRestriction bitMaskRestriction = (Restriction.BitMaskRestriction)restriction;
                    this.writer.WriteAttributeString("PropTag", RuleWriter.EnumToString(bitMaskRestriction.Tag));
                    this.writer.WriteAttributeString("Operation", bitMaskRestriction.Bmr.ToString());
                    this.writer.WriteAttributeString("Mask", bitMaskRestriction.Mask.ToString("X08"));
                    break;
                }

                case Restriction.ResType.Size:
                {
                    Restriction.SizeRestriction sizeRestriction = (Restriction.SizeRestriction)restriction;
                    this.writer.WriteAttributeString("Operation", sizeRestriction.Op.ToString());
                    this.writer.WriteAttributeString("PropTag", RuleWriter.EnumToString(sizeRestriction.Tag));
                    this.writer.WriteAttributeString("Size", sizeRestriction.Size.ToString("X08"));
                    break;
                }

                case Restriction.ResType.Exist:
                {
                    Restriction.ExistRestriction existRestriction = (Restriction.ExistRestriction)restriction;
                    this.writer.WriteAttributeString("PropTag", RuleWriter.EnumToString(existRestriction.Tag));
                    break;
                }

                case Restriction.ResType.SubRestriction:
                {
                    Restriction.SubRestriction subRestriction = (Restriction.SubRestriction)restriction;
                    this.writer.WriteAttributeString("SubType", subRestriction.GetType().Name);
                    this.WriteRestriction(subRestriction.Restriction);
                    break;
                }

                case Restriction.ResType.Comment:
                {
                    Restriction.CommentRestriction commentRestriction = (Restriction.CommentRestriction)restriction;
                    this.WritePropValues("Comment", commentRestriction.Values);
                    this.WriteRestriction(commentRestriction.Restriction);
                    break;
                }

                case Restriction.ResType.Count:
                {
                    Restriction.CountRestriction countRestriction = (Restriction.CountRestriction)restriction;
                    this.writer.WriteAttributeString("Count", countRestriction.Count.ToString());
                    this.WriteRestriction(countRestriction.Restriction);
                    break;
                }

                default:
                    switch (resType)
                    {
                    }
                    this.writer.WriteAttributeString("Error", "Unsupported restriction type: " + type.ToString());
                    break;
                }
            }
            this.writer.WriteEndElement();
        }