/// <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="TargetGroup" />.</param>
 /// <returns>
 /// an instance of <see cref="TargetGroup" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         TargetGroup.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new TargetGroup
         {
             DefaultInternalPolicy = sourceValue.DefaultInternalPolicy,
             Filter = CategoryFilterTypeConverter.ConvertFrom(sourceValue.Filter),
             PeerSpecificationType = sourceValue.PeerSpecificationType,
         });
     }
     catch
     {
     }
     return(null);
 }
Example #2
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="CategoryQueryInput" />.</param>
 /// <returns>
 /// an instance of <see cref="CategoryQueryInput" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         CategoryQueryInput.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new CategoryQueryInput
         {
             ApiVersion = sourceValue.ApiVersion,
             CategoryFilter = CategoryFilterTypeConverter.ConvertFrom(sourceValue.CategoryFilter),
             GroupMemberCount = sourceValue.GroupMemberCount,
             GroupMemberOffset = sourceValue.GroupMemberOffset,
             UsageType = sourceValue.UsageType,
         });
     }
     catch
     {
     }
     return(null);
 }
 /// <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="NetworkSecurityRuleResourcesIsolationRule"
 /// />.</param>
 /// <returns>
 /// an instance of <see cref="NetworkSecurityRuleResourcesIsolationRule" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         NetworkSecurityRuleResourcesIsolationRule.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new NetworkSecurityRuleResourcesIsolationRule
         {
             Action = sourceValue.Action,
             FirstEntityFilter = CategoryFilterTypeConverter.ConvertFrom(sourceValue.FirstEntityFilter),
             SecondEntityFilter = CategoryFilterTypeConverter.ConvertFrom(sourceValue.SecondEntityFilter),
         });
     }
     catch
     {
     }
     return(null);
 }
 /// <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="NetworkRule" />.</param>
 /// <returns>
 /// an instance of <see cref="NetworkRule" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         NetworkRule.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new NetworkRule
         {
             ExpirationTime = sourceValue.ExpirationTime,
             Filter = CategoryFilterTypeConverter.ConvertFrom(sourceValue.Filter),
             IcmpTypeCodeList = sourceValue.IcmpTypeCodeList,
             IpSubnet = IpSubnetTypeConverter.ConvertFrom(sourceValue.IpSubnet),
             NetworkFunctionChainReference = NetworkFunctionChainReferenceTypeConverter.ConvertFrom(sourceValue.NetworkFunctionChainReference),
             PeerSpecificationType = sourceValue.PeerSpecificationType,
             Protocol = sourceValue.Protocol,
             TcpPortRangeList = sourceValue.TcpPortRangeList,
             UdpPortRangeList = sourceValue.UdpPortRangeList,
         });
     }
     catch
     {
     }
     return(null);
 }