39 lines
930 B
C#
39 lines
930 B
C#
// /**
|
|
// * File: Tariff.cs
|
|
// * Author: haraldwolff
|
|
// *
|
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|
// *
|
|
// *
|
|
// **/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using ln.types.btree;
|
|
namespace ln.provider.data.phone
|
|
{
|
|
public class Tariff
|
|
{
|
|
public String Name { get; set; }
|
|
|
|
public MappingBTree<String, Rate> Rates { get; private set; } = new MappingBTree<string, Rate>((value) => value.Prefix);
|
|
|
|
public Tariff()
|
|
{
|
|
}
|
|
|
|
public Rate GetRate(string prefix)
|
|
{
|
|
for (int n=1;n<prefix.Length;n++)
|
|
{
|
|
string p = prefix.Substring(0, n);
|
|
if (Rates.ContainsKey(p))
|
|
return Rates[p];
|
|
}
|
|
|
|
throw new KeyNotFoundException();
|
|
}
|
|
|
|
}
|
|
}
|