/// <summary> /// {type} {proptag} /// </summary> /// <param name="type">Type.</param> /// <param name="tag">Prop tag.</param> public ExtendedPropertyDefinition(MapiPropertyType type, int tag) : this(type) { this.Tag = tag; this.PropertySet = null; this.Definition = $"{this.Type} 0x{this.TagHex}"; }
/// <summary> /// Loads from json. /// </summary> /// <param name="jsonObject">The json object.</param> internal void LoadFromJson(JsonObject jsonObject) { foreach (string key in jsonObject.Keys) { switch (key) { case XmlAttributeNames.DistinguishedPropertySetId: this.propertySet = jsonObject.ReadEnumValue <DefaultExtendedPropertySet>(key); break; case XmlAttributeNames.PropertySetId: this.propertySetId = new Guid(jsonObject.ReadAsString(key)); break; case XmlAttributeNames.PropertyTag: this.tag = Convert.ToUInt16(jsonObject.ReadAsString(key), 16); break; case XmlAttributeNames.PropertyName: this.name = jsonObject.ReadAsString(key); break; case XmlAttributeNames.PropertyId: this.id = jsonObject.ReadAsInt(key); break; case XmlAttributeNames.PropertyType: this.mapiType = jsonObject.ReadEnumValue <MapiPropertyType>(key); break; default: break; } } }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsServiceXmlReader reader) { string attributeValue; attributeValue = reader.ReadAttributeValue(XmlAttributeNames.DistinguishedPropertySetId); if (!string.IsNullOrEmpty(attributeValue)) { this.propertySet = (DefaultExtendedPropertySet)Enum.Parse(typeof(DefaultExtendedPropertySet), attributeValue, false); } attributeValue = reader.ReadAttributeValue(XmlAttributeNames.PropertySetId); if (!string.IsNullOrEmpty(attributeValue)) { this.propertySetId = new Guid(attributeValue); } attributeValue = reader.ReadAttributeValue(XmlAttributeNames.PropertyTag); if (!string.IsNullOrEmpty(attributeValue)) { this.tag = Convert.ToUInt16(attributeValue, 16); } this.name = reader.ReadAttributeValue(XmlAttributeNames.PropertyName); attributeValue = reader.ReadAttributeValue(XmlAttributeNames.PropertyId); if (!string.IsNullOrEmpty(attributeValue)) { this.id = int.Parse(attributeValue); } this.mapiType = reader.ReadAttributeValue <MapiPropertyType>(XmlAttributeNames.PropertyType); }
private static PropType GetMapiPropType(MapiPropertyType ewsMapiPropertyType) { PropType result; if (ewsMapiPropertyType != 14) { switch (ewsMapiPropertyType) { case 25: result = PropType.String; break; case 26: result = PropType.StringArray; break; default: throw new NotImplementedException(); } } else { result = PropType.Int; } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> /// <param name="propertySetId">The property set Id of the extended property.</param> /// <param name="id">The Id of the extended property.</param> /// <param name="mapiType">The MAPI type of the extended property.</param> public ExtendedPropertyDefinition( Guid propertySetId, int id, MapiPropertyType mapiType) : this(mapiType) { this.propertySetId = propertySetId; this.id = id; }
/// <summary> /// Initializes a new instance of ExtendedPropertyDefinition. /// </summary> /// <param name="propertySet">The property set of the extended property.</param> /// <param name="id">The Id of the extended property.</param> /// <param name="mapiType">The MAPI type of the extended property.</param> public ExtendedPropertyDefinition( DefaultExtendedPropertySet propertySet, int id, MapiPropertyType mapiType) : this(mapiType) { this.propertySet = propertySet; this.id = id; }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> /// <param name="tag">The tag of the extended property.</param> /// <param name="mapiType">The MAPI type of the extended property.</param> public ExtendedPropertyDefinition(int tag, MapiPropertyType mapiType) : this(mapiType) { if (tag < 0 || tag > UInt16.MaxValue) { throw new ArgumentOutOfRangeException("tag", Strings.TagValueIsOutOfRange); } this.tag = tag; }
/// <summary> /// {type} {propertyset} Name {name} /// </summary> /// <param name="type">Type.</param> /// <param name="name">Name.</param> /// <param name="propertySet">Property set.</param> public ExtendedPropertyDefinition(MapiPropertyType type, string name, Guid propertySet) : this(type) { ArgumentValidator.ThrowIfNullOrEmpty(name, nameof(name)); ArgumentValidator.ThrowIfGuidEmpty(propertySet, nameof(propertySet)); this.Name = name; this.PropertySet = propertySet; this.Definition = $"{this.Type} {{{this.PropertySet}}} Name {this.Name}"; }
public MapiPropertyType GetMapiPropertyType() { MapiPropertyType result = 19; if (!string.IsNullOrEmpty(this.PropertyType)) { Enum.TryParse <MapiPropertyType>(this.PropertyType, true, out result); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> /// <param name="propertySetId">The property set Id of the extended property.</param> /// <param name="name">The name of the extended property.</param> /// <param name="mapiType">The MAPI type of the extended property.</param> public ExtendedPropertyDefinition( Guid propertySetId, string name, MapiPropertyType mapiType) : this(mapiType) { EwsUtilities.ValidateParam(name, "name"); this.propertySetId = propertySetId; this.name = name; }
/// <summary> /// {type} {guid} Id {tag} /// </summary> /// <param name="type"></param> /// <param name="tag"></param> /// <param name="propertySet"></param> public ExtendedPropertyDefinition(MapiPropertyType type, int tag, Guid propertySet) : this(type) { ArgumentValidator.ThrowIfGuidEmpty( propertySet, nameof(propertySet)); this.Tag = tag; this.PropertySet = propertySet; this.Definition = $"{this.Type} {{{this.PropertySet}}} Id 0x{this.TagHex}"; }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> /// <param name="propertySet">The extended property set of the extended property.</param> /// <param name="name">The name of the extended property.</param> /// <param name="mapiType">The MAPI type of the extended property.</param> public ExtendedPropertyDefinition( DefaultExtendedPropertySet propertySet, string name, MapiPropertyType mapiType) : this(mapiType) { EwsUtilities.ValidateParam(name, "name"); this.propertySet = propertySet; this.name = name; }
/// <summary> /// Get mapi property type value. /// </summary> /// <param name="mapiPropertyType">Mapi property type.</param> /// <returns></returns> private MapiPropertyValueType GetMapiPropertyValueType(MapiPropertyType mapiPropertyType) { MemberInfo memberInfo = typeof(MapiPropertyType).GetMember(mapiPropertyType.ToString()).FirstOrDefault(); if (memberInfo != null) { MapiPropertyTypeValueAttribute propertyType = (MapiPropertyTypeValueAttribute)memberInfo.GetCustomAttributes( typeof(MapiPropertyTypeValueAttribute), false).FirstOrDefault(); return(propertyType != null ? propertyType.MapiPropertyValueType : MapiPropertyValueType.SingleValueExtendedProperties); } return(MapiPropertyValueType.SingleValueExtendedProperties); }
/// <summary> /// Converts the string list to array. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="strings">Strings.</param> /// <returns>Array of objects.</returns> internal static Array ConvertToValue(MapiPropertyType mapiPropType, IEnumerable <string> strings) { EwsUtilities.ValidateParam(strings, "strings"); MapiTypeConverterMapEntry typeConverter = MapiTypeConverterMap[mapiPropType]; Array array = Array.CreateInstance(typeConverter.Type, strings.Count <string>()); int index = 0; foreach (string stringValue in strings) { object value = typeConverter.ConvertToValueOrDefault(stringValue); array.SetValue(value, index++); } return(array); }
internal static ExtendedPropertyDefinition ConvertExtendedPropertyInfoToExtendedPropertyDefinition(ExtendedPropertyInfo extendedPropertyInfo) { MapiPropertyType mapiPropertyType = extendedPropertyInfo.GetMapiPropertyType(); if (extendedPropertyInfo.PropertyTagId != null && extendedPropertyInfo.PropertyTagId != null) { return(new ExtendedPropertyDefinition(extendedPropertyInfo.PropertyTagId.Value, mapiPropertyType)); } if (extendedPropertyInfo.PropertySetId != Guid.Empty) { if (!string.IsNullOrEmpty(extendedPropertyInfo.PropertyName)) { return(new ExtendedPropertyDefinition(extendedPropertyInfo.PropertySetId, extendedPropertyInfo.PropertyName, mapiPropertyType)); } if (extendedPropertyInfo.PropertyId != null && extendedPropertyInfo.PropertyId != null) { return(new ExtendedPropertyDefinition(extendedPropertyInfo.PropertySetId, extendedPropertyInfo.PropertyId.Value, mapiPropertyType)); } } throw new ArgumentException(string.Format("Could not convert {0} to ExtendedPropertyDefinition", extendedPropertyInfo.ToString())); }
public static bool DoProps(ref List <ExtendedPropertyDefinition> epdProps) { bool bSuccess = true; epdProps = new List <ExtendedPropertyDefinition>(); ExtendedPropertyDefinition extProp = null; int iTag = 0; MapiPropertyType mpType = MapiPropertyType.Null; int Bound0 = rgProps.GetUpperBound(0); for (int i = 0; i < Bound0; i++) { mpType = GetPropType(rgProps[i, 1]); if (rgProps[i, 0] == "") // for string values that have no pTag { string strGUID = GetGUIDFromSetID(rgProps[i, 2]); string strProp = rgProps[i, 3]; extProp = new ExtendedPropertyDefinition(new Guid(strGUID), strProp, mpType); } else // all others that have pTags { iTag = Convert.ToInt32(rgProps[i, 0], 16); if (rgProps[i, 2] == "") // If Not a Named Prop { extProp = new ExtendedPropertyDefinition(iTag, mpType); } else // else it is a named prop { string strGUID = GetGUIDFromSetID(rgProps[i, 2]); extProp = new ExtendedPropertyDefinition(new Guid(strGUID), iTag, mpType); } } epdProps.Add(extProp); } return(bSuccess); }
// Token: 0x06000523 RID: 1315 RVA: 0x00026D00 File Offset: 0x00024F00 private void InitializeRetentionProperties() { this.retentionExtendedProperties = new List <ExtendedPropertyDefinition>(); this.ewsStorePropertyMapping = new Dictionary <PropertyDefinition, ExtendedPropertyDefinition>(); foreach (int num in this.retentionPropertyTags.Keys) { MapiPropertyType mapiPropertyType = this.retentionPropertyTags[num]; ExtendedPropertyDefinition extendedPropertyDefinition; if (num == -1) { Guid guid = new Guid("C7A4569B-F7AE-4DC2-9279-A8FE2F3CAF89"); extendedPropertyDefinition = new ExtendedPropertyDefinition(guid, "RetentionTagEntryId", mapiPropertyType); } else { extendedPropertyDefinition = new ExtendedPropertyDefinition(num, mapiPropertyType); } this.retentionExtendedProperties.Add(extendedPropertyDefinition); FolderHelper.DataColumnIndex dataColumnIndex = this.retentionPropertyTagsMapping[num]; PropertyDefinition key = FolderHelper.DataColumns[(int)dataColumnIndex]; this.ewsStorePropertyMapping.Add(key, extendedPropertyDefinition); } }
public static bool GetMapiPropertyTypeFromString(string sProperty, ref MapiPropertyType oMapiPropertyType) { switch (sProperty.ToUpper()) { case "INTEGER": oMapiPropertyType = MapiPropertyType.Integer; break; case "STRING": oMapiPropertyType = MapiPropertyType.String; break; case "BINARY": oMapiPropertyType = MapiPropertyType.Binary; break; case "LONG": oMapiPropertyType = MapiPropertyType.Long; break; case "SHORT": oMapiPropertyType = MapiPropertyType.Short; break; case "FLOAT": oMapiPropertyType = MapiPropertyType.Float; break; case "BOOLEAN": oMapiPropertyType = MapiPropertyType.Boolean; break; case "SYSTEMTIME": oMapiPropertyType = MapiPropertyType.SystemTime; break; case "INTEGERARRAY": oMapiPropertyType = MapiPropertyType.IntegerArray; break; case "STRINGARRAY": oMapiPropertyType = MapiPropertyType.StringArray; break; case "BINARYARRAY": oMapiPropertyType = MapiPropertyType.BinaryArray; break; case "LONGARRAY": oMapiPropertyType = MapiPropertyType.LongArray; break; case "SHORTARRAY": oMapiPropertyType = MapiPropertyType.ShortArray; break; case "FLOATARRAY": oMapiPropertyType = MapiPropertyType.FloatArray; break; case "SYSTEMTIMEARRAY": oMapiPropertyType = MapiPropertyType.SystemTimeArray; break; default: MessageBox.Show(string.Format("Non-supported data type in CSV: {0}.", sProperty), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
/// <summary> /// Change value to a value of compatible type. /// </summary> /// <param name="mapiType">Type of the mapi property.</param> /// <param name="value">The value.</param> /// <returns>Compatible value.</returns> internal static object ChangeType(MapiPropertyType mapiType, object value) { EwsUtilities.ValidateParam(value, "value"); return(MapiTypeConverterMap[mapiType].ChangeType(value)); }
/// <summary> /// Determines whether MapiPropertyType is an array type. /// </summary> /// <param name="mapiType">Type of the mapi.</param> /// <returns>True if this is an array type.</returns> internal static bool IsArrayType(MapiPropertyType mapiType) { return(MapiTypeConverterMap[mapiType].IsArray); }
/// <summary> /// Converts a string to value consistent with MAPI type. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="stringValue">String to convert to a value.</param> /// <returns></returns> internal static object ConvertToValue(MapiPropertyType mapiPropType, string stringValue) { return(MapiTypeConverterMap[mapiPropType].ConvertToValue(stringValue)); }
/// <summary> /// Converts a value to a string. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="value">Value to convert to string.</param> /// <returns>String value.</returns> internal static string ConvertToString(MapiPropertyType mapiPropType, object value) { return((value == null) ? string.Empty : MapiTypeConverterMap[mapiPropType].ConvertToString(value)); }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> /// <param name="mapiType">The MAPI type of the extended property.</param> internal ExtendedPropertyDefinition(MapiPropertyType mapiType) : this() { this.mapiType = mapiType; }
///<Summary> /// Add Custom Property ///</Summary> /// <param name="msg"></param> /// <param name="name"></param> /// <param name="type"></param> /// <param name="valueBytes"></param> public static MapiProperty AddCustomProperty(this MapiMessage msg, string name, MapiPropertyType type, byte[] valueBytes) { var newProperty = new MapiProperty(msg.NamedPropertyMapping.GetNextAvailablePropertyId(type), 0, valueBytes); msg.AddCustomProperty(newProperty, name); return(newProperty); }
/// <summary> /// Change value to a value of compatible type. /// </summary> /// <param name="mapiType">Type of the mapi property.</param> /// <param name="value">The value.</param> /// <returns>Compatible value.</returns> internal static object ChangeType(MapiPropertyType mapiType, object value) { EwsUtilities.ValidateParam(value, "value"); return MapiTypeConverterMap[mapiType].ChangeType(value); }
/// <summary> /// Determines whether MapiPropertyType is an array type. /// </summary> /// <param name="mapiType">Type of the mapi.</param> /// <returns>True if this is an array type.</returns> internal static bool IsArrayType(MapiPropertyType mapiType) { return MapiTypeConverterMap[mapiType].IsArray; }
/// <summary> /// Converts a string to value consistent with MAPI type. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="stringValue">String to convert to a value.</param> /// <returns></returns> internal static object ConvertToValue(MapiPropertyType mapiPropType, string stringValue) { return MapiTypeConverterMap[mapiPropType].ConvertToValue(stringValue); }
/// <summary> /// Converts a value to a string. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="value">Value to convert to string.</param> /// <returns>String value.</returns> internal static string ConvertToString(MapiPropertyType mapiPropType, object value) { return (value == null) ? string.Empty : MapiTypeConverterMap[mapiPropType].ConvertToString(value); }
/// <summary> /// Converts the string list to array. /// </summary> /// <param name="mapiPropType">Type of the MAPI property.</param> /// <param name="strings">Strings.</param> /// <returns>Array of objects.</returns> internal static Array ConvertToValue(MapiPropertyType mapiPropType, IEnumerable<string> strings) { EwsUtilities.ValidateParam(strings, "strings"); MapiTypeConverterMapEntry typeConverter = MapiTypeConverterMap[mapiPropType]; Array array = Array.CreateInstance(typeConverter.Type, strings.Count<string>()); int index = 0; foreach (string stringValue in strings) { object value = typeConverter.ConvertToValueOrDefault(stringValue); array.SetValue(value, index++); } return array; }
private void btnAddPropertiesFromCsv_Click(object sender, EventArgs e) { PropertySetDialogAddFromCSV oForm = new PropertySetDialogAddFromCSV(); oForm.ShowDialog(); if (oForm.ClickedOK == true) { PropertyDefinitionBase oPD = null; //bool bNamedProp = false; foreach (AdditionalPropertyDefinition o in oForm.APD) { MapiPropertyType oMapiPropertyType = MapiPropertyType.String; AdditionalProperties.GetMapiPropertyTypeFromString(o.PropertyType, ref oMapiPropertyType); if (o.PropertyIdIsString == true) { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( new Guid(o.PropertySetId), o.PropertySetIdString, oMapiPropertyType); } else { if (o.PropertySetId != "") { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( new Guid(o.PropertySetId), o.PropertyId, oMapiPropertyType); } else { oPD = (PropertyDefinitionBase) new ExtendedPropertyDefinition( o.PropertyId, oMapiPropertyType); } } AddPropertyToDisplayTable(oPD); //DataRow row = this.propertyDisplayTable.NewRow(); //row["PropertyName"] = o.PropertyName; //row["PropertyType"] = o.PropertyType; //row["WellKnownName"] = o.PropertyName; //row["PropertyDefinitionBase"] = o.PropertyDefinitionType; //// Don't add the row if it already exists //if (!this.propertyDisplayTable.Rows.Contains(row["PropertyName"])) //{ // this.propertyDisplayTable.Rows.Add(row); //} //AddPropertyToDisplayTable(PropertyDefinitionBase prop) } } }
/// <summary> /// Default constructor. /// </summary> /// <param name="type">Type of property.</param> private ExtendedPropertyDefinition(MapiPropertyType type) { this.Type = type; }
public static bool GetAdditionalPropertiesFromCsv( ref string sChosenFile, ref List <AdditionalPropertyDefinition> oAdditionalPropertyDefinitions, ref List <ExtendedPropertyDefinition> oExtendedPropertyDefinitions ) { bool bRet = false; oExtendedPropertyDefinitions = new List <ExtendedPropertyDefinition>(); oAdditionalPropertyDefinitions = new List <AdditionalPropertyDefinition>(); ExtendedPropertyDefinition oExtendedPropertyDefinition = null; //AdditionalPropertyDefinition oAdditionalPropertyDefinition = null; MapiPropertyType oType = MapiPropertyType.String; // ---------------------- // Get property definition list. // Before: //bRet = GetAdditionalPropertiesDefinitionsFromCsv(ref sChosenFile, ref oAdditionalPropertyDefinitions); // Use form... PropertySetDialogAddFromCSV oForm = new PropertySetDialogAddFromCSV(sChosenFile); oForm.ShowDialog(); if (oForm.ClickedOK == true) { oAdditionalPropertyDefinitions = oForm.APD; sChosenFile = oForm.ChosenFile; bRet = true; } else { bRet = false; } // ------------------------------ if (bRet == false) { return(false); } int iCount = 0; // build list of ExtendedPropertyDefinition using list of AdditionalProperty try { foreach (AdditionalPropertyDefinition o in oAdditionalPropertyDefinitions) { iCount++; if (GetMapiPropertyTypeFromString(o.PropertyType, ref oType)) { // Named Property? if (o.PropertyIdIsString == true) { ////PropertyType = string.Empty; ////ropertyIdIsString = false; //oExtendedPropertyDefinition = new ExtendedPropertyDefinition(o.PropertySetIdString, o., oType); //oExtendedPropertyDefinitions.Add(oExtendedPropertyDefinition); if (o.PropertySetId == "") // Have a propset guid? { // Need the propset guid for the custom property... string sBad = string.Format("Line {0} has an invalide Property Set ID: \"{1}\".", iCount, o.PropertySetId); MessageBox.Show(sBad, "Error in CSV."); return(false); } else { oExtendedPropertyDefinition = new ExtendedPropertyDefinition(new Guid(o.PropertySetId), o.PropertySetIdString, oType); oExtendedPropertyDefinitions.Add(oExtendedPropertyDefinition); } } if (o.PropertyIdIsString == false) { if (o.PropertySetId == "") // Have a propset guid? { oExtendedPropertyDefinition = new ExtendedPropertyDefinition(o.PropertyId, oType); oExtendedPropertyDefinitions.Add(oExtendedPropertyDefinition); } else { oExtendedPropertyDefinition = new ExtendedPropertyDefinition(new Guid(o.PropertySetId), o.PropertyId, oType); oExtendedPropertyDefinitions.Add(oExtendedPropertyDefinition); } } } else { return(false); } } } catch (Exception ex) { MessageBox.Show("Error converting CSV data into properties. : \r\n\r\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bRet = false; } return(bRet); }
private static long GenerateNamedPropertyTag(long index, MapiPropertyType dataType) { return(((long)(long)dataType | (0x8000 | index) << 16) & 0x00000000FFFFFFFF); }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedPropertyDefinition"/> class. /// </summary> internal ExtendedPropertyDefinition() : base() { this.mapiType = MapiPropertyType.String; }
private static long GenerateNamedPropertyTag(long index, MapiPropertyType dataType) { return ((long)(long)dataType | (0x8000 | index) << 16) & 0x00000000FFFFFFFF; }