Esempio n. 1
0
        private static void Initialize()
        {
            lock (initializationSync) {
                if (!broken && !initialized)
                {
                    try {
                        file = GetIsolatedStorage();
                        reportOriginIdentity = GetOrCreateOriginIdentity();

                        webRequestHandler = new StandardWebRequestHandler();
                        observations.Add(observedRequests = new PersistentHashSet(file, "requests.txt", 3));
                        observations.Add(observedCultures = new PersistentHashSet(file, "cultures.txt", 20));
                        observations.Add(observedFeatures = new PersistentHashSet(file, "features.txt", int.MaxValue));

                        // Record site-wide features in use.
                        if (HttpContext.Current != null && HttpContext.Current.ApplicationInstance != null)
                        {
                            // MVC or web forms?
                            // front-end or back end web farm?
                            // url rewriting?
                            ////RecordFeatureUse(IsMVC ? "ASP.NET MVC" : "ASP.NET Web Forms");
                        }

                        initialized = true;
                    } catch (Exception e) {
                        // This is supposed to be as low-risk as possible, so if it fails, just disable reporting
                        // and avoid rethrowing.
                        broken = true;
                        Logger.Library.Error("Error while trying to initialize reporting.", e);
                    }
                }
            }
        }
Esempio n. 2
0
        public void CreateOnNoArgsReturnsEmptySet()
        {
            PersistentHashSet m = PersistentHashSet.create();

            Expect(m.count(), EqualTo(0));
            Expect(m.meta(), Null);
        }
Esempio n. 3
0
        public void CreateOnEmptyListReturnsEmptySet()
        {
            ArrayList      a = new ArrayList();
            IPersistentSet m = PersistentHashSet.createWithCheck(a);

            Expect(m.count(), EqualTo(0));
        }
Esempio n. 4
0
        public void DoBigTest(int numEntries)
        {
            System.Console.WriteLine("Testing {0} items.", numEntries);

            Random rnd = new Random();
            Dictionary <object, object> dict = new Dictionary <object, object>(numEntries);

            for (int i = 0; i < numEntries; i++)
            {
                int r = rnd.Next();
                dict[r] = r;
            }

            object[] items = dict.Keys.ToArray();

            PersistentHashSet m = (PersistentHashSet)PersistentHashSet.create(items);

            Expect(m.count(), EqualTo(dict.Count));

            foreach (int key in dict.Keys)
            {
                Expect(m.contains(key));
            }

            for (ISeq s = m.seq(); s != null; s = s.next())
            {
                Expect(dict.ContainsKey((int)s.first()));
            }
        }
        public void CreateOnNoArgsReturnsEmptySet()
        {
            PersistentHashSet m = PersistentHashSet.create();

            Expect(m.count()).To.Equal(0);
            Expect(m.meta()).To.Be.Null();
        }
Esempio n. 6
0
        public void CreateOnEmptyISeqReturnsEmptySet()
        {
            object[]       items = new object[] { };
            ArrayList      a     = new ArrayList(items);
            ISeq           s     = PersistentList.create(a).seq();
            IPersistentSet m     = PersistentHashSet.create(s);

            Expect(m.count(), EqualTo(0));
        }
Esempio n. 7
0
        public void CreateOnNoArgsReturnsSet()
        {
            PersistentHashSet m = PersistentHashSet.create(1, "a");

            Expect(m.count(), EqualTo(2));
            Expect(m.contains(1));
            Expect(m.contains("a"));
            Expect(m.contains(3), False);
            Expect(m.meta(), Null);
        }
        public void CreateOnNoArgsReturnsSet()
        {
            PersistentHashSet m = PersistentHashSet.create(1, "a");

            Expect(m.count()).To.Equal(2);
            Expect(m.contains(1));
            Expect(m.contains("a"));
            Expect(m.contains(3)).To.Be.False();
            Expect(m.meta()).To.Be.Null();
        }
Esempio n. 9
0
        public void Setup()
        {
            IPersistentMap meta = new DummyMeta();

            PersistentHashSet m = PersistentHashSet.create(1, "a", 2, "b");


            _objWithNullMeta = (IObj)m;
            _obj             = _objWithNullMeta.withMeta(meta);
            _expectedType    = typeof(PersistentHashSet);
        }
Esempio n. 10
0
        public void CreateOnISeqReturnsSet()
        {
            object[]       items = new object[] { 1, "a" };
            ArrayList      a     = new ArrayList(items);
            ISeq           s     = PersistentList.create(a).seq();
            IPersistentSet m     = PersistentHashSet.create(s);

            Expect(m.count(), EqualTo(2));
            Expect(m.contains(1));
            Expect(m.contains("a"));
            Expect(m.contains(3), False);
        }
Esempio n. 11
0
        public void CreateOnListReturnsSet()
        {
            object[]  items = new object[] { 1, "a" };
            ArrayList a     = new ArrayList(items);

            IPersistentSet m = PersistentHashSet.createWithCheck(a);

            Expect(m.count(), EqualTo(2));
            Expect(m.contains(1));
            Expect(m.contains("a"));
            Expect(m.contains(3), False);
        }
Esempio n. 12
0
        public void Setup()
        {
            _mocks = new MockRepository();
            IPersistentMap meta = _mocks.StrictMock <IPersistentMap>();

            _mocks.ReplayAll();

            PersistentHashSet m = PersistentHashSet.create(1, "a", 2, "b");


            _objWithNullMeta = (IObj)m;
            _obj             = _objWithNullMeta.withMeta(meta);
            _expectedType    = typeof(PersistentHashSet);
        }
Esempio n. 13
0
		private static void Initialize() {
			lock (initializationSync) {
				if (!broken && !initialized) {
					try {
						file = GetIsolatedStorage();
						reportOriginIdentity = GetOrCreateOriginIdentity();

						webRequestHandler = new StandardWebRequestHandler();
						observations.Add(observedRequests = new PersistentHashSet(file, "requests.txt", 3));
						observations.Add(observedCultures = new PersistentHashSet(file, "cultures.txt", 20));
						observations.Add(observedFeatures = new PersistentHashSet(file, "features.txt", int.MaxValue));

						// Record site-wide features in use.
						if (HttpContext.Current != null && HttpContext.Current.ApplicationInstance != null) {
							// MVC or web forms?
							// front-end or back end web farm?
							// url rewriting?
							////RecordFeatureUse(IsMVC ? "ASP.NET MVC" : "ASP.NET Web Forms");
						}

						initialized = true;
					} catch (Exception e) {
						// This is supposed to be as low-risk as possible, so if it fails, just disable reporting
						// and avoid rethrowing.
						broken = true;
						Logger.Library.Error("Error while trying to initialize reporting.", e);
					}
				}
			}
		}
Esempio n. 14
0
 protected override object Read(PushbackTextReader r, char leftbracket, object opts)
 {
     return(PersistentHashSet.createWithCheck(ReadDelimitedList('}', r, true, opts)));
 }