Пример #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="SslKey" />.</param>
 /// <returns>
 /// an instance of <see cref="SslKey" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         SslKey.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new SslKey
         {
             ExpireDatetime = sourceValue.ExpireDatetime,
             KeyName = sourceValue.KeyName,
             KeyType = sourceValue.KeyType,
             SigningInfo = CertificationSigningInfoTypeConverter.ConvertFrom(sourceValue.SigningInfo),
         });
     }
     catch
     {
     }
     return(null);
 }
Пример #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="ClusterConfig" />.</param>
 /// <returns>
 /// an instance of <see cref="ClusterConfig" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         ClusterConfig.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new ClusterConfig
         {
             AuthorizedPublicKeyList = sourceValue.AuthorizedPublicKeyList,
             Build = BuildInfoTypeConverter.ConvertFrom(sourceValue.Build),
             CaCertificateList = sourceValue.CaCertificateList,
             CertificationSigningInfo = CertificationSigningInfoTypeConverter.ConvertFrom(sourceValue.CertificationSigningInfo),
             ClientAuth = ClientAuthTypeConverter.ConvertFrom(sourceValue.ClientAuth),
             ClusterArch = sourceValue.ClusterArch,
             EnabledFeatureList = sourceValue.EnabledFeatureList,
             EncryptionStatus = sourceValue.EncryptionStatus,
             ExternalConfigurations = ExternalConfigurationsTypeConverter.ConvertFrom(sourceValue.ExternalConfigurations),
             GpuDriverVersion = sourceValue.GpuDriverVersion,
             IsAvailable = sourceValue.IsAvailable,
             ManagementServerList = sourceValue.ManagementServerList,
             OperationMode = sourceValue.OperationMode,
             RedundancyFactor = sourceValue.RedundancyFactor,
             ServiceList = sourceValue.ServiceList,
             SoftwareMap = sourceValue.SoftwareMap,
             SslKey = SslKeyTypeConverter.ConvertFrom(sourceValue.SslKey),
             SupportedInformationVerbosity = sourceValue.SupportedInformationVerbosity,
             Timezone = sourceValue.Timezone,
         });
     }
     catch
     {
     }
     return(null);
 }