// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Utils.Extensions;
using Core.Components.Gis;
using Core.Components.Gis.Data;
namespace Application.Ringtoets.Storage.Create
{
///
/// Extensions methods for related to
/// creating a .
///
internal static class BackgroundMapDataContainerCreateExtensions
{
///
/// Creates a based on the information of the
/// and its .
///
/// The container to create a for.
/// The entity, or null if contains
/// an unsupported instance.
internal static BackgroundMapDataEntity Create(this BackgroundMapDataContainer mapDataContainer)
{
if (mapDataContainer == null)
{
throw new ArgumentNullException(nameof(mapDataContainer));
}
var wmtsMapData = mapDataContainer.MapData as WmtsMapData;
if (wmtsMapData != null)
{
return wmtsMapData.Create();
}
return null; // TODO: WTI-1141
}
///
/// Creates a based on the information of the
///
/// The to create a
/// for.
/// A configured .
/// Thrown when
/// is null.
internal static BackgroundMapDataEntity Create(this WmtsMapData mapData)
{
if (mapData == null)
{
throw new ArgumentNullException(nameof(mapData));
}
var entity = new BackgroundMapDataEntity
{
Name = mapData.Name.DeepClone(),
IsVisible = Convert.ToByte(mapData.IsVisible),
Transparency = mapData.Transparency
};
if (mapData.IsConfigured)
{
entity.SelectedCapabilityName = mapData.SelectedCapabilityIdentifier.DeepClone();
entity.SourceCapabilitiesUrl = mapData.SourceCapabilitiesUrl.DeepClone();
entity.PreferredFormat = mapData.PreferredFormat.DeepClone();
}
return entity;
}
}
}