Example #1
0
 /// <summary>
 /// Resolves the property request with a read result
 /// </summary>
 /// <param name="readResult">The read result</param>
 public void Resolve(ReadAccessResult.ReadResultType readResult)
 {
     if (readResult.IsPropertyAccessError)
     {
         if (this.OnError != null)
         {
             this.OnError(readResult.AsPropertyAccessError);
         }
     }
     else if (readResult.IsPropertyValue)
     {
         if (this.OnValue != null)
         {
             try
             {
                 var value = readResult.AsPropertyValue.As <T>();
                 this.OnValue(value);
             }
             catch (Exception)
             {
                 var error = new Error(Error.ErrorClassType.Property, Error.ErrorCodeType.InvalidDataType);
                 if (this.OnError != null)
                 {
                     this.OnError(error);
                 }
             }
         }
     }
 }
Example #2
0
 /// <summary>
 /// Transforms a read result into an ErrorOr value
 /// </summary>
 /// <typeparam name="T">The type of value</typeparam>
 /// <param name="result">The read result</param>
 /// <returns>The ErrorOr instance</returns>
 internal ErrorOr <T> FromReadResult <T>(ReadAccessResult.ReadResultType result)
 {
     if (result.IsPropertyAccessError)
     {
         return(new ErrorOr <T>(result.AsPropertyAccessError));
     }
     else
     {
         return(new ErrorOr <T>(result.AsPropertyValue.As <T>()));
     }
 }