/// <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="VmNic" />.</param> /// <returns> /// an instance of <see cref="VmNic" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { VmNic.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new VmNic { IpEndpointList = sourceValue.IpEndpointList, MacAddress = sourceValue.MacAddress, Model = sourceValue.Model, NetworkFunctionChainReference = NetworkFunctionChainReferenceTypeConverter.ConvertFrom(sourceValue.NetworkFunctionChainReference), NetworkFunctionNicType = sourceValue.NetworkFunctionNicType, NicType = sourceValue.NicType, SubnetReference = SubnetReferenceTypeConverter.ConvertFrom(sourceValue.SubnetReference), Uuid = sourceValue.Uuid, }); } 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="SubnetResources" />.</param> /// <returns> /// an instance of <see cref="SubnetResources" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { SubnetResources.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new SubnetResources { IpConfig = IpConfigTypeConverter.ConvertFrom(sourceValue.IpConfig), NetworkFunctionChainReference = NetworkFunctionChainReferenceTypeConverter.ConvertFrom(sourceValue.NetworkFunctionChainReference), SubnetType = sourceValue.SubnetType, VlanId = sourceValue.VlanId, VswitchName = sourceValue.VswitchName, }); } 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); }