protected NativeStorePropertyDefinition CreatePropertyDefinition(TnefPropertyTag propertyTag, TnefNameId?namedProperty)
        {
            PropType tnefType = (PropType)propertyTag.TnefType;

            if (tnefType == PropType.Error || tnefType == PropType.Null || tnefType == PropType.ObjectArray || tnefType == PropType.Unspecified)
            {
                return(null);
            }
            if (tnefType == PropType.Object && propertyTag != TnefPropertyTag.AttachDataObj)
            {
                return(null);
            }
            if (namedProperty == null)
            {
                return(PropertyTagPropertyDefinition.InternalCreateCustom(string.Empty, (PropTag)propertyTag, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType));
            }
            Guid propertySetGuid = namedProperty.Value.PropertySetGuid;

            if (namedProperty.Value.Kind == TnefNameIdKind.Id)
            {
                return(GuidIdPropertyDefinition.InternalCreateCustom(string.Empty, tnefType, propertySetGuid, namedProperty.Value.Id, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType, new PropertyDefinitionConstraint[0]));
            }
            string name = namedProperty.Value.Name;

            if (!GuidNamePropertyDefinition.IsValidName(propertySetGuid, name))
            {
                return(null);
            }
            return(GuidNamePropertyDefinition.InternalCreateCustom(string.Empty, tnefType, propertySetGuid, name, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType, new PropertyDefinitionConstraint[0]));
        }
Exemplo n.º 2
0
        internal static GuidNamePropertyDefinition InternalCreate(string displayName, Type propertyType, PropType mapiPropType, Guid propertyGuid, string propertyName, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, bool isCustom, params PropertyDefinitionConstraint[] constraints)
        {
            if (!GuidNamePropertyDefinition.IsValidName(propertyGuid, propertyName))
            {
                throw new ArgumentException("Invalid property name for property", "propertyName");
            }
            if (mapiPropType == PropType.AnsiString)
            {
                mapiPropType = PropType.String;
                propertyType = typeof(string);
            }
            else if (mapiPropType == PropType.AnsiStringArray)
            {
                mapiPropType = PropType.StringArray;
                propertyType = typeof(string[]);
            }
            NamedProp namedProp  = new NamedProp(propertyGuid, propertyName);
            NamedProp namedProp2 = WellKnownNamedProperties.Find(namedProp);

            if (namedProp2 != null)
            {
                namedProp = namedProp2;
            }
            else
            {
                namedProp = NamedPropertyDefinition.NamedPropertyKey.GetSingleton(namedProp);
            }
            GuidNamePropertyDefinition.GuidNameKey guidNameKey = new GuidNamePropertyDefinition.GuidNameKey(namedProp);
            GuidNamePropertyDefinition             result;
            bool flag;

            if (GuidNamePropertyDefinition.TryFindEquivalentDefinition(guidNameKey, isCustom, mapiPropType, typeCheckingFlag, out result, out flag))
            {
                return(result);
            }
            if (!flag)
            {
                return(null);
            }
            return(new GuidNamePropertyDefinition(displayName, propertyType, mapiPropType, guidNameKey, flags, isCustom, constraints));
        }
Exemplo n.º 3
0
        private static NativeStorePropertyDefinition GetPropDefByMapiNamedProp(NamedProp prop, PropType type, NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag)
        {
            if (prop == null)
            {
                return(null);
            }
            switch (prop.Kind)
            {
            case NamedPropKind.Id:
                return(GuidIdPropertyDefinition.InternalCreateCustom(string.Empty, type, prop.Guid, prop.Id, PropertyFlags.None, propertyTypeCheckingFlag, new PropertyDefinitionConstraint[0]));

            case NamedPropKind.String:
                if (GuidNamePropertyDefinition.IsValidName(prop.Guid, prop.Name))
                {
                    return(GuidNamePropertyDefinition.InternalCreate(string.Empty, InternalSchema.ClrTypeFromPropTagType(type), type, prop.Guid, prop.Name, PropertyFlags.None, propertyTypeCheckingFlag, true, PropertyDefinitionConstraint.None));
                }
                return(null);

            default:
                throw new ArgumentOutOfRangeException("prop.Kind");
            }
        }