// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Collections.Generic;
using System.Linq;
namespace CefSharp.Internals
{
///
/// Use this static class to merge command line arguments.
///
public sealed class CommandLineArgsMerger
{
///
/// Returns the merged command line features.
///
/// The existing features.
/// The features that should be merged.
/// the merged command line features.
public static string MergeFeatures(string existing, string incoming)
{
var features = new HashSet();
AddFeatures(features, existing);
AddFeatures(features, incoming);
return string.Join(",", features.OrderBy(i => i));
}
private static void AddFeatures(HashSet features, string value)
{
if (string.IsNullOrWhiteSpace(value))
{
return;
}
foreach (var item in value.Split(','))
{
features.Add(item.Trim());
}
}
}
}