Ejemplo n.º 1
0
 /// <summary>Default constructor.</summary>
 public SQLNETItem()
 {
     CacheKey = Guid.NewGuid().ToString();
     ParameterTables = new ListDictionary();
     ParameterTypes = new SharedCache<string, Type>();
     ParameterValues = new ListDictionary();
     ParallelItems = new SharedBucketList();
 }
        private static void CacheSource(Uri source, ResourceDictionary dictionary)
        {
            if (SharedCache.ContainsKey(source))
            {
                InternalSharedCache.Remove(source);
            }

            InternalSharedCache.Add(source, new WeakReference(dictionary, false));
        }
 public AwardStatsModule(
     DiscordResolver discordResolver,
     AwardMessageRepository awardMessageRepo,
     SharedCache cache
     )
 {
     _discordResolver  = discordResolver;
     _awardMessageRepo = awardMessageRepo;
     _cache            = cache;
 }
        public void Demonstrate_that_copies_are_equals()
        {
            ICache cache = new PerpetualCache();

            cache = new SharedCache(cache);

            for (int i = 0; i < 100000; i++)
            {
                cache[i] = i;
                Assert.That(cache[i], Is.EqualTo(i));
            }
        }
Ejemplo n.º 5
0
        public void Demonstrate_that_copies_are_equals()
        {
            ICache cache = new WeakCache();

            cache = new SharedCache(cache);

            for (int i = 0; i < 100000; i++)
            {
                cache[i] = i;
                object value = cache[i];
                Assert.That(value, Is.Null | Is.EqualTo(i));
            }
        }
Ejemplo n.º 6
0
		public static void Save(SharedCache.WinServiceTestClient.Common.Reporting report)
		{
			DAL.DalReporting.Save(report);
		}
Ejemplo n.º 7
0
        static void Main(string[] args) {
            //if (!ConfigurationHelper.Import("NordicConf.json")) {
            //    Console.WriteLine("Configuration import failed, using default values and writing configuration file \"NordicConf.json\".");
            //    ConfigurationHelper.Export("NordicConf.json");
            //}
            var _hardcodedChallenge = "miner_test";

            ServerAuthenticator.Initialize("pubKey.pem", "privKey.pem", "");
            ClientAuthenticator.Initialize("pubKey.pem", "privKey.pem", "");
            ClientAuthenticator.Add(_hardcodedChallenge, File.ReadAllText("miner_pubKey.pem"));

            Console.WriteLine("---------- BLOCKCHAIN ----------\n");

            Blockchain _nbStructure = new Blockchain();
            var gBlock = _nbStructure.GetBlock(0);

            Console.WriteLine(gBlock.ToString());
            //_nbStructure.Add(new BlockData("", IOperation.OPERATION_TYPE.SECURITY_BC_COMPROMISE_NOTICE, "Lol"));
            
            Console.WriteLine(_nbStructure.LastBlock().ToString());

            Console.WriteLine("Fork Validity: " + _nbStructure.Validity());

            Console.WriteLine("\n---------- NODE VAULT ----------\n");

            Console.WriteLine("Importing current node credentials...");
            TrustVault _vault = new TrustVault(File.ReadAllText("privKey.pem"), File.ReadAllText("pubKey.pem"));
            Console.WriteLine(_vault.ToJson());

            Console.WriteLine("\n----------- NETWORK ------------\n");
            Console.WriteLine("Setting up network for 127.0.0.1:1337 (LOCAL ONLY BINDING!).");

            Network _net = new Network("127.0.0.1", 1337);
            if (_net.Setup()) {
                _net.Start();
                Console.WriteLine("Network started on 127.0.0.1:1337.");
                
            } else
                Console.WriteLine("Network setup failed.");

            Console.WriteLine("\n---------- SHAREDCACHE ---------\n");

            Console.WriteLine("Building Shared Node Cache for online nodes...");
            Console.WriteLine("\tOnly 1 node online.");
            SharedCache _cache = new SharedCache();
            _cache.AddAddress("127.0.0.1");
            Console.WriteLine(_cache.ToJson());

            Console.WriteLine("\n-------------- RSA -------------\n");

            RSA _rsa = new RSA(File.ReadAllText("privKey.pem"), File.ReadAllText("pubKey.pem"));
            var _signature = _rsa.Sign("makeAwish");
            var _verify = _rsa.VerifySignature("makeAwish", _signature, null);
            var _verify2 = _rsa.VerifySignature("makeAwisha", _signature, null);

            Console.WriteLine("Signed: " + _signature + "\n\n");
            Console.WriteLine("Verify: " + _verify);
            Console.WriteLine("Verify fake one: " + _verify2);

            Client cl = new Client();
            cl.Connect("ws://127.0.0.1:1337/blt");
            bool _sent = false;
            while (true) {
                if (WaitOrBreak(_nbStructure.LastBlock())) break;

                if (!_nbStructure.Validity()) {
                    Console.WriteLine("Blockchain violation detected!");

                    
                    break;
                }
                //try {
                //    if (!_sent) {
                //        IOperation _op = new OperationTransaction("d3vil401", "13.2", "none");
                //        ClmManager _clm = new ClmManager(_op);
                //        var _buffer = _clm.GetBuffer().Result.ToBase64();
                //
                //        cl.Send("ws://127.0.0.1:1337/blt", _buffer);
                //        _sent = true;
                //    }
                //
                //} catch (Exception ex) {
                //    Console.WriteLine(ex.Message);
                //}
            }
        }
Ejemplo n.º 8
0
		internal static void Save(SharedCache.WinServiceTestClient.Common.Reporting report)
		{
			XmlDocument doc = LoadDocument();
			Common.Report re = (Common.Report)Deserialize(doc, typeof(Common.Report));
			re.List.Add(report);

			SaveDocument(Serialize(re));			
		}