internal static PropertyValue[] ConvertFromMapiPropValues(PropValue[] mapiPropValues, int codePage) { PropertyValue[] array = null; if (mapiPropValues != null) { array = new PropertyValue[mapiPropValues.Length]; for (int i = 0; i < mapiPropValues.Length; i++) { array[i] = ConvertHelper.ConvertFromMapiPropValue(mapiPropValues[i], codePage); } } return(array); }
internal static Restriction ConvertFromMapiRestriction(Restriction restriction, int codePage) { if (restriction == null) { return(null); } switch (restriction.Type) { case Restriction.ResType.And: return(new AndRestriction((from r in ((Restriction.AndRestriction)restriction).Restrictions select ConvertHelper.ConvertFromMapiRestriction(r, codePage)).ToArray <Restriction>())); case Restriction.ResType.Or: return(new OrRestriction((from r in ((Restriction.OrRestriction)restriction).Restrictions select ConvertHelper.ConvertFromMapiRestriction(r, codePage)).ToArray <Restriction>())); case Restriction.ResType.Not: return(new NotRestriction(ConvertHelper.ConvertFromMapiRestriction((Restriction.NotRestriction)restriction, codePage))); case Restriction.ResType.Content: { Restriction.ContentRestriction contentRestriction = (Restriction.ContentRestriction)restriction; return(new ContentRestriction((FuzzyLevel)contentRestriction.Flags, ConvertHelper.ConvertFromMapiPropTag(contentRestriction.PropTag), new PropertyValue?(ConvertHelper.ConvertFromMapiPropValue(contentRestriction.PropValue, codePage)))); } case Restriction.ResType.Property: { Restriction.PropertyRestriction propertyRestriction = (Restriction.PropertyRestriction)restriction; RelationOperator relop = ConvertHelper.ConvertFromMapiRelOp(propertyRestriction.Op); PropertyTag propertyTag = ConvertHelper.ConvertFromMapiPropTag(propertyRestriction.PropTag); PropertyValue value = ConvertHelper.ConvertFromMapiPropValue(propertyRestriction.PropValue, codePage); return(new PropertyRestriction(relop, propertyTag, new PropertyValue?(value))); } case Restriction.ResType.CompareProps: { Restriction.ComparePropertyRestriction comparePropertyRestriction = (Restriction.ComparePropertyRestriction)restriction; return(new ComparePropsRestriction(ConvertHelper.ConvertFromMapiRelOp(comparePropertyRestriction.Op), ConvertHelper.ConvertFromMapiPropTag(comparePropertyRestriction.TagLeft), ConvertHelper.ConvertFromMapiPropTag(comparePropertyRestriction.TagRight))); } case Restriction.ResType.BitMask: { Restriction.BitMaskRestriction bitMaskRestriction = (Restriction.BitMaskRestriction)restriction; return(new BitMaskRestriction(ConvertHelper.ConvertFromMapiRelBmr(bitMaskRestriction.Bmr), ConvertHelper.ConvertFromMapiPropTag(bitMaskRestriction.Tag), (uint)bitMaskRestriction.Mask)); } case Restriction.ResType.Size: { Restriction.SizeRestriction sizeRestriction = (Restriction.SizeRestriction)restriction; return(new SizeRestriction(ConvertHelper.ConvertFromMapiRelOp(sizeRestriction.Op), ConvertHelper.ConvertFromMapiPropTag(sizeRestriction.Tag), (uint)sizeRestriction.Size)); } case Restriction.ResType.Exist: { Restriction.ExistRestriction existRestriction = (Restriction.ExistRestriction)restriction; return(new ExistsRestriction(ConvertHelper.ConvertFromMapiPropTag(existRestriction.Tag))); } case Restriction.ResType.SubRestriction: { Restriction.SubRestriction subRestriction = (Restriction.SubRestriction)restriction; return(new SubRestriction((SubRestrictionType)subRestriction.Type, ConvertHelper.ConvertFromMapiRestriction(subRestriction.Restriction, codePage))); } default: throw new NspiException(NspiStatus.InvalidParameter, string.Format("Invalid MAPI restriction type: {0}", restriction)); } }