Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of protocol.</param>
        public Protocol(string name)
            : this()
        {
            _name = name;

            while (_storageDirectory == null)
            {
                _id = Guid.NewGuid().ToString();
                string candidateStorageDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), _id);
                if (!Directory.Exists(candidateStorageDirectory))
                {
                    _storageDirectory = candidateStorageDirectory;
                    Directory.CreateDirectory(_storageDirectory);
                }
            }

            _probes = new List <Probe>();
            foreach (Probe probe in Probe.GetAll())
            {
                probe.Protocol = this;

                // since the new probe was just bound to this protocol, we need to let this protocol know about this probe's default anonymization preferences.
                foreach (PropertyInfo anonymizableProperty in probe.DatumType.GetProperties().Where(property => property.GetCustomAttribute <Anonymizable>() != null))
                {
                    Anonymizable anonymizableAttribute = anonymizableProperty.GetCustomAttribute <Anonymizable>(true);
                    _jsonAnonymizer.SetAnonymizer(anonymizableProperty, anonymizableAttribute.DefaultAnonymizer);
                }

                _probes.Add(probe);
            }
        }
Beispiel #2
0
 public void ProbeParameterlessConstructorTest()
 {
     SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() =>
     {
         SensusServiceHelper.ClearSingleton();
         Assert.True(Probe.GetAll().Count > 0);
     });
 }