Example #1
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the value to convert into an instance of <see cref="MetricsResponse" />.</param>
 /// <returns>
 /// an instance of <see cref="MetricsResponse" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.IMetricsResponse ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     global::System.Type type = sourceValue.GetType();
     if (typeof(Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.IMetricsResponse).IsAssignableFrom(type))
     {
         return(sourceValue);
     }
     try
     {
         return(MetricsResponse.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()));;
     }
     catch
     {
         // Unable to use JSON pattern
     }
     if (typeof(global::System.Management.Automation.PSObject).IsAssignableFrom(type))
     {
         return(MetricsResponse.DeserializeFromPSObject(sourceValue));
     }
     if (typeof(global::System.Collections.IDictionary).IsAssignableFrom(type))
     {
         return(MetricsResponse.DeserializeFromDictionary(sourceValue));
     }
     return(null);
 }