Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from dclaux/Fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
dclaux committed Apr 27, 2015
2 parents 2f06138 + 66d9fd5 commit 31951f4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ComplexProperties/DictionaryProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ internal void InternalRemove(TKey key)
}

this.addedEntries.Remove(key);
this.modifiedEntries.Remove (key);
this.modifiedEntries.Remove(key);
}

/// <summary>
Expand Down Expand Up @@ -525,4 +525,4 @@ bool ICustomUpdateSerializer.WriteDeleteUpdateToJson(ExchangeService service, Se

#endregion
}
}
}
32 changes: 28 additions & 4 deletions Core/EwsUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal static class EwsUtilities
/// Dictionary of enum type to ExchangeVersion maps.
/// </summary>
private static LazyMember<Dictionary<Type, Dictionary<Enum, ExchangeVersion>>> enumVersionDictionaries = new LazyMember<Dictionary<Type, Dictionary<Enum, ExchangeVersion>>>(
() => new Dictionary<Type, Dictionary<Enum, ExchangeVersion>>()
() => new Dictionary<Type, Dictionary<Enum, ExchangeVersion>>()
{
{ typeof(WellKnownFolderName), BuildEnumDict(typeof(WellKnownFolderName)) },
{ typeof(ItemTraversal), BuildEnumDict(typeof(ItemTraversal)) },
Expand All @@ -93,7 +93,7 @@ internal static class EwsUtilities
/// Dictionary of enum type to schema-name-to-enum-value maps.
/// </summary>
private static LazyMember<Dictionary<Type, Dictionary<string, Enum>>> schemaToEnumDictionaries = new LazyMember<Dictionary<Type, Dictionary<string, Enum>>>(
() => new Dictionary<Type, Dictionary<string, Enum>>
() => new Dictionary<Type, Dictionary<string, Enum>>
{
{ typeof(EventType), BuildSchemaToEnumDict(typeof(EventType)) },
{ typeof(MailboxType), BuildSchemaToEnumDict(typeof(MailboxType)) },
Expand All @@ -106,7 +106,7 @@ internal static class EwsUtilities
/// Dictionary of enum type to enum-value-to-schema-name maps.
/// </summary>
private static LazyMember<Dictionary<Type, Dictionary<Enum, string>>> enumToSchemaDictionaries = new LazyMember<Dictionary<Type, Dictionary<Enum, string>>>(
() => new Dictionary<Type, Dictionary<Enum, string>>
() => new Dictionary<Type, Dictionary<Enum, string>>
{
{ typeof(EventType), BuildEnumToSchemaDict(typeof(EventType)) },
{ typeof(MailboxType), BuildEnumToSchemaDict(typeof(MailboxType)) },
Expand All @@ -119,7 +119,7 @@ internal static class EwsUtilities
/// Dictionary to map from special CLR type names to their "short" names.
/// </summary>
private static LazyMember<Dictionary<string, string>> typeNameToShortNameMap = new LazyMember<Dictionary<string, string>>(
() => new Dictionary<string, string>
() => new Dictionary<string, string>
{
{ "Boolean", "bool" },
{ "Int16", "short" },
Expand Down Expand Up @@ -720,6 +720,30 @@ internal static T Parse<T>(string value)
}
}

/// <summary>
/// Tries to parses the specified value to the specified type.
/// </summary>
/// <typeparam name="T">The type into which to cast the provided value.</typeparam>
/// <param name="value">The value to parse.</param>
/// <param name="result">The value cast to the specified type, if TryParse succeeds. Otherwise, the value of result is indeterminate.</param>
/// <returns>True if value could be parsed; otherwise, false.</returns>
internal static bool TryParse<T>(string value, out T result)
{
try
{
result = EwsUtilities.Parse<T>(value);

return true;
}
//// Catch all exceptions here, we're not interested in the reason why TryParse failed.
catch (Exception)
{
result = default(T);

return false;
}
}

/// <summary>
/// Converts the specified date and time from one time zone to another.
/// </summary>
Expand Down
27 changes: 24 additions & 3 deletions Core/ServiceObjects/Folders/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,33 @@ public ArchiveTag ArchiveTag
}

/// <summary>
/// Gets the name of the well known folder.
/// Gets the well known name of this folder, if any, as a string.
/// </summary>
/// <value>The name of the well known folder.</value>
/// <value>The well known name of this folder as a string, or null if this folder isn't a well known folder.</value>
public string WellKnownFolderNameAsString
{
get { return (string)this.PropertyBag[FolderSchema.WellKnownFolderName]; }
}

/// <summary>
/// Gets the well known name of this folder, if any.
/// </summary>
/// <value>The well known name of this folder, or null if this folder isn't a well known folder.</value>
public WellKnownFolderName? WellKnownFolderName
{
get { return (WellKnownFolderName?)this.PropertyBag[FolderSchema.WellKnownFolderName]; }
get
{
WellKnownFolderName result;

if (EwsUtilities.TryParse<WellKnownFolderName>(this.WellKnownFolderNameAsString, out result))
{
return result;
}
else
{
return null;
}
}
}

#endregion
Expand Down
5 changes: 2 additions & 3 deletions Core/ServiceObjects/Schemas/FolderSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,11 @@ private static class FieldUris
/// </summary>
[SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Immutable type")]
public static readonly PropertyDefinition WellKnownFolderName =
new GenericPropertyDefinition<WellKnownFolderName>(
new StringPropertyDefinition(
XmlElementNames.DistinguishedFolderId,
FieldUris.DistinguishedFolderId,
PropertyDefinitionFlags.CanSet | PropertyDefinitionFlags.CanFind,
ExchangeVersion.Exchange2013,
true);
ExchangeVersion.Exchange2013);

/// <summary>
/// Defines the PolicyTag property.
Expand Down
4 changes: 2 additions & 2 deletions Notifications/StreamingSubscriptionConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ public void Close()
/// <param name="ex">The exception that caused the disconnection. May be null.</param>
private void InternalOnDisconnect(Exception ex)
{
this.currentHangingRequest = null;

if (this.OnDisconnect != null)
{
this.OnDisconnect(this, new SubscriptionErrorEventArgs(null, ex));
}

this.currentHangingRequest = null;
}

/// <summary>
Expand Down

0 comments on commit 31951f4

Please sign in to comment.