コード例 #1
0
        internal static PlugInConfigurationDTO ConfigurationToDTO(this PlugInConfiguration source)
        {
            var options = new List <ConfigurationOptionDTO>();

            foreach (var configurationOption in source.Options)
            {
                options.Add(configurationOption.ConfigurationOptionsToDTO());
            }

            var result = new PlugInConfigurationDTO
            {
                PlugInName = source.PlugInName,
                Version    = source.Version.ToString(),
                Options    = options.ToArray(),
            };

            return(result);
        }
コード例 #2
0
        internal static PlugInConfiguration ConfigurationFromDTO(this PlugInConfigurationDTO source, ILogger logger)
        {
            var options = new HashSet <ConfigurationOption>();

            foreach (var configurationOption in source.Options)
            {
                options.Add(configurationOption.ConfigurationOptionFromDTO());
            }

            if (!SemanticVersion.TryParse(source.Version, out var version))
            {
                logger?.Error("Unable to parse PlugInConfiguration version: {0}", source.Version);
                return(null);
            }

            var result = new PlugInConfiguration(source.PlugInName, version, options);

            return(result);
        }