コード例 #1
0
ファイル: SealedStringTests.cs プロジェクト: itadapter/nfx
        public void Equals()
        {
            var s1 = new SealedString("Bird");
              var s2 = new SealedString("Cat");

              Assert.IsTrue(s1.IsAssigned);
              Assert.IsTrue(s2.IsAssigned);
              Assert.AreEqual("Bird", s1.Value);
              Assert.AreEqual("Cat", s2.Value);

              Assert.AreNotEqual(s1, s2);
              Assert.IsFalse( s1 == s2);
              Assert.IsTrue( s1 != s2);
              Assert.AreNotEqual(s1.GetHashCode(), s2.GetHashCode());

              var s3 = SealedString.Unassigned;
              Assert.AreNotEqual(s1, s3);
              Assert.IsFalse( s1 == s3);
              Assert.IsTrue( s1 != s3);
              Assert.AreNotEqual(s1.GetHashCode(), s3.GetHashCode());

              s3 = s1;
              Assert.AreEqual(s1, s3);
              Assert.IsTrue( s1 == s3);
              Assert.IsFalse( s1 != s3);
              Assert.AreEqual(s1.GetHashCode(), s3.GetHashCode());
        }
コード例 #2
0
ファイル: Rows.cs プロジェクト: wangchengqun/azos
 public Location(
     SealedString id,
     SealedString localeCode,
     SealedString continentID,
     SealedString continentName,
     SealedString countryISOName,
     SealedString countryName,
     SealedString subdivisionISOCode,
     SealedString subdivisionName,
     SealedString subdivision2ISOCode,
     SealedString subdivision2Name,
     SealedString cityName,
     SealedString metroCode,
     SealedString timeZone)
 {
     ID                  = id;
     LocaleCode          = localeCode;
     ContinentID         = continentID;
     ContinentName       = continentName;
     CountryISOName      = countryISOName;
     CountryName         = countryName;
     SubdivisionISOCode  = subdivisionISOCode;
     SubdivisionName     = subdivisionName;
     Subdivision2ISOCode = subdivision2ISOCode;
     Subdivision2Name    = subdivision2Name;
     CityName            = cityName;
     MetroCode           = metroCode;
     TimeZone            = timeZone;
 }
コード例 #3
0
        public void Equals()
        {
            var s1 = new SealedString("Bird");
            var s2 = new SealedString("Cat");


            Assert.IsTrue(s1.IsAssigned);
            Assert.IsTrue(s2.IsAssigned);
            Assert.AreEqual("Bird", s1.Value);
            Assert.AreEqual("Cat", s2.Value);

            Assert.AreNotEqual(s1, s2);
            Assert.IsFalse(s1 == s2);
            Assert.IsTrue(s1 != s2);
            Assert.AreNotEqual(s1.GetHashCode(), s2.GetHashCode());

            var s3 = SealedString.Unassigned;

            Assert.AreNotEqual(s1, s3);
            Assert.IsFalse(s1 == s3);
            Assert.IsTrue(s1 != s3);
            Assert.AreNotEqual(s1.GetHashCode(), s3.GetHashCode());

            s3 = s1;
            Assert.AreEqual(s1, s3);
            Assert.IsTrue(s1 == s3);
            Assert.IsFalse(s1 != s3);
            Assert.AreEqual(s1.GetHashCode(), s3.GetHashCode());
        }
コード例 #4
0
        public void Create()
        {
            var s1 = new SealedString("Lenin");

            var original = s1.Value;

            Assert.IsTrue(s1.IsAssigned);
            Assert.AreEqual("Lenin", original);
            Console.WriteLine(s1.ToString());
        }
コード例 #5
0
ファイル: SealedStringTests.cs プロジェクト: itadapter/nfx
        public void Create()
        {
            var s1 = new SealedString("Lenin");

              var original = s1.Value;

              Assert.IsTrue(s1.IsAssigned);
              Assert.AreEqual("Lenin", original);
              Console.WriteLine(s1.ToString());
        }
コード例 #6
0
ファイル: SealedStringTests.cs プロジェクト: azist/azos
        public void Create()
        {
            var s1 = new SealedString("Lenin");

            var original = s1.Value;

            Aver.IsTrue(s1.IsAssigned);
            Aver.AreEqual("Lenin", original);
            s1.ToString().See();
        }
コード例 #7
0
        public void LongMulticulturalString()
        {
            var original = "就是巴尼宝贝儿吧,俺说。有什么怪事儿或是好事儿吗? когда американские авианосцы 'Уинсон' и 'Мидуэй' приблизились 지구상의 3대 we have solved the problem";

            var sld = new SealedString(original);

            var got = sld.Value;

            Aver.IsTrue(sld.IsAssigned);
            Aver.AreEqual(original, got);
        }
コード例 #8
0
        public void VariousSizesOfWideChars(int cnt)
        {
            var original = new string('久', cnt);

            var sld = new SealedString(original);

            var got = sld.Value;

            Aver.IsTrue(sld.IsAssigned);
            Aver.AreEqual(original, got);
        }
コード例 #9
0
        public void Unassigned()
        {
            var empty = new SealedString();

            Assert.IsFalse(empty.IsAssigned);

            empty = SealedString.Unassigned;

            Assert.IsFalse(empty.IsAssigned);

            Assert.AreEqual(SealedString.Unassigned, new SealedString());
            Assert.AreEqual(0, SealedString.Unassigned.GetHashCode());

            Assert.IsTrue(null == empty.Value);
        }
コード例 #10
0
        public void Multithreaded(int cnt, int from, int to)
        {
            var startCount      = SealedString.TotalCount;
            var startUseCount   = SealedString.TotalBytesUsed;
            var startAllocCount = SealedString.TotalBytesAllocated;

            var data = new string[1024];

            for (var i = 0; i < data.Length; i++)
            {
                data[i] = "A".PadRight(from + NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, to));
            }


            Console.WriteLine("Total: {0:n0} / used bytes: {1:n0} / allocated: {2:n0}", startCount, startUseCount, startAllocCount);

            var sw = System.Diagnostics.Stopwatch.StartNew();

            Parallel.For(0, cnt, (_) =>
            {
                var content  = data[NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, data.Length)];
                var s        = new SealedString(content);
                var restored = s.Value;
                Assert.AreEqual(content, restored);
            });
            sw.Stop();

            var endCount      = SealedString.TotalCount;
            var endUseCount   = SealedString.TotalBytesUsed;
            var endAllocCount = SealedString.TotalBytesAllocated;

            Assert.AreEqual(startCount + cnt, endCount);
            Assert.IsTrue(endUseCount > startUseCount);
            Assert.IsTrue(endAllocCount >= startAllocCount);

            Console.WriteLine("Total: {0:n0} / used bytes: {1:n0} / allocated: {2:n0}", endCount, endUseCount, endAllocCount);

            Console.WriteLine("Did {0:n0} in {1:n0} ms at {2:n0} ops/sec".Args(cnt, sw.ElapsedMilliseconds, cnt / (sw.ElapsedMilliseconds / 1000d)));

            Console.WriteLine("Total segments: {0}", SealedString.TotalSegmentCount);
        }
コード例 #11
0
ファイル: Rows.cs プロジェクト: wangchengqun/azos
 public IPSubnetBlock(
     SealedString subnet,
     SealedString locationID,
     SealedString registeredLocationID,
     SealedString representedLocationID,
     bool anonymousProxy,
     bool satelliteProvider,
     SealedString postalCode,
     float lat,
     float lng)
 {
     Subnet                = subnet;
     LocationID            = locationID;
     RegisteredLocationID  = registeredLocationID;
     RepresentedLocationID = representedLocationID;
     AnonymousProxy        = anonymousProxy;
     SatelliteProvider     = satelliteProvider;
     PostalCode            = postalCode;
     Lat = lat;
     Lng = lng;
 }
コード例 #12
0
ファイル: Rows.cs プロジェクト: itadapter/nfx
 public IPSubnetBlock(
     SealedString subnet,
     SealedString locationID,
     SealedString registeredLocationID,
     SealedString representedLocationID,
     bool anonymousProxy,
     bool satelliteProvider,
     SealedString postalCode,
     float lat,
     float lng)
 {
     Subnet = subnet;
       LocationID = locationID;
       RegisteredLocationID = registeredLocationID;
       RepresentedLocationID = representedLocationID;
       AnonymousProxy = anonymousProxy;
       SatelliteProvider = satelliteProvider;
       PostalCode = postalCode;
       Lat = lat;
       Lng = lng;
 }
コード例 #13
0
ファイル: Rows.cs プロジェクト: itadapter/nfx
 public Location(
     SealedString id,
     SealedString localeCode,
     SealedString continentID,
     SealedString continentName,
     SealedString countryISOName,
     SealedString countryName,
     SealedString subdivisionISOCode,
     SealedString subdivisionName,
     SealedString subdivision2ISOCode,
     SealedString subdivision2Name,
     SealedString cityName,
     SealedString metroCode,
     SealedString timeZone)
 {
     ID = id;
       LocaleCode = localeCode;
       ContinentID = continentID;
       ContinentName = continentName;
       CountryISOName = countryISOName;
       CountryName = countryName;
       SubdivisionISOCode = subdivisionISOCode;
       SubdivisionName = subdivisionName;
       Subdivision2ISOCode = subdivision2ISOCode;
       Subdivision2Name = subdivision2Name;
       CityName = cityName;
       MetroCode = metroCode;
       TimeZone = timeZone;
 }
コード例 #14
0
ファイル: SealedStringTests.cs プロジェクト: itadapter/nfx
        public void Unassigned()
        {
            var empty = new SealedString();

              Assert.IsFalse(empty.IsAssigned);

              empty = SealedString.Unassigned;

              Assert.IsFalse(empty.IsAssigned);

              Assert.AreEqual(SealedString.Unassigned, new SealedString());
              Assert.AreEqual(0, SealedString.Unassigned.GetHashCode());

              Assert.IsTrue( null == empty.Value);
        }
コード例 #15
0
ファイル: SealedStringTests.cs プロジェクト: itadapter/nfx
        public void Multithreaded(int cnt, int from, int to)
        {
            var startCount = SealedString.TotalCount;
              var startUseCount = SealedString.TotalBytesUsed;
              var startAllocCount = SealedString.TotalBytesAllocated;

              var data = new string[1024];
              for(var i=0; i<data.Length; i++)
               data[i] = "A".PadRight(from+NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, to));

              Console.WriteLine("Total: {0:n0} / used bytes: {1:n0} / allocated: {2:n0}", startCount, startUseCount, startAllocCount);

              var sw = System.Diagnostics.Stopwatch.StartNew();
            Parallel.For(0, cnt, (_) =>
            {
               var content = data[NFX.ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, data.Length)];
               var s = new SealedString(content);
               var restored = s.Value;
               Assert.AreEqual(content, restored);
            });
              sw.Stop();

              var endCount = SealedString.TotalCount;
              var endUseCount = SealedString.TotalBytesUsed;
              var endAllocCount = SealedString.TotalBytesAllocated;

              Assert.AreEqual( startCount+cnt, endCount);
              Assert.IsTrue(endUseCount > startUseCount);
              Assert.IsTrue(endAllocCount >= startAllocCount);

              Console.WriteLine("Total: {0:n0} / used bytes: {1:n0} / allocated: {2:n0}", endCount, endUseCount, endAllocCount);

              Console.WriteLine("Did {0:n0} in {1:n0} ms at {2:n0} ops/sec".Args(cnt, sw.ElapsedMilliseconds, cnt / (sw.ElapsedMilliseconds / 1000d)));

              Console.WriteLine("Total segments: {0}", SealedString.TotalSegmentCount);
        }