Beispiel #1
0
        static void Main(string[] args)
        {
            Ip ekaterinaIp = new Ip("192.168.21.12");
            Ip kaisarIp    = new Ip("228.228.228.322");
            Ip zaharIp     = new Ip("666.666.666.666");

            ekaterinaIp.IpV4Body = "192.168.21.12";
            kaisarIp.IpV4Body    = "228.228.228.322";
            zaharIp.IpV4Body     = "666.666.666.666";

            string ekaterinaFormatted = $"IPv4 User-Friendly = {ekaterinaIp.IpV4Body} :" +
                                        $"IPv4 Machine-Friendly = {ekaterinaIp.ToBinaryIpV4Body()}";

            string kaisarFormatted = $"IPv4 User-Friendly = {kaisarIp.IpV4Body} :" +
                                     $"IPv4 Machine-Friendly = {kaisarIp.ToBinaryIpV4Body()}";

            string zaharFormatted = $"IPv4 User-Friendly = {zaharIp.IpV4Body} :" +
                                    $"IPv4 Machine-Friendly = {zaharIp.ToBinaryIpV4Body()}";

            Console.WriteLine(ekaterinaFormatted);
            Console.WriteLine(kaisarFormatted);
            Console.WriteLine(zaharFormatted);

            Console.WriteLine(Ip.GetCurrentNumberOfIps());

            var a = CurrencyCalculator.GetCurrencyCalculator();
            var b = CurrencyCalculator.GetCurrencyCalculator();
            var c = CurrencyCalculator.GetCurrencyCalculator();

            if (a == c)
            {
                Console.WriteLine("Reference equals");
            }
            Console.ReadLine();
        }
Beispiel #2
0
 public static CurrencyCalculator GetCurrencyCalculator()
 {
     if (_nextElementIndex > 1)
     {
         _nextElementIndex = 0;
     }
     if (_calculatorInstances[_nextElementIndex] == null)
     {
         _calculatorInstances[_nextElementIndex] = new CurrencyCalculator();
         int currentId = _nextElementIndex;
         _nextElementIndex++;
         return(_calculatorInstances[currentId]);
     }
     else
     {
         return(_calculatorInstances[_nextElementIndex]);
     }
 }