public void GivenPropeties_ShouldReturnAllCombinations()
        {
            var collection  = new List <List <IKAnonimization> >();
            var algoFactory = new AlgorithmsEnumerator(2, null, _pidProperties);

            foreach (var prop in algoFactory)
            {
                collection.Add(prop);
            }

            Assert.IsTrue(collection.Count == (1 << _pidProperties.Length));
        }
Exemplo n.º 2
0
 public KCombinedAnonimization(int parameterK, List <List <string> > jobDictionary,
                               List <List <string> > cityDictionary, params Expression <Func <Person, object> >[] pidProperties)
 {
     ParameterK            = parameterK;
     _expressions          = pidProperties.ToList();
     _properties           = pidProperties.Select(x => x.Compile()).ToList();
     _algorithmsEnumerator = new AlgorithmsEnumeratorBuilder()
                             .SetMaximumKParameter(100)
                             .SetPID(pidProperties)
                             .AddDictionary(p => p.City, cityDictionary)
                             .AddDictionary(p => p.Job, jobDictionary)
                             .Build();
 }
        public void GivenPropeties_ShouldReturnAllCombinationsUsingWhileLoop()
        {
            var collection  = new List <List <IKAnonimization> >();
            var algoFactory = new AlgorithmsEnumerator(2, null, _pidProperties);

            using (var algosIterator = algoFactory.GetEnumerator())
            {
                while (algosIterator.MoveNext())
                {
                    collection.Add(algosIterator.Current);
                }
            }
            Assert.IsTrue(collection.Count == (1 << _pidProperties.Length));
        }
Exemplo n.º 4
0
 public AKAnonimization(int parameterK, double parameterAlpha, string attributeValue, List <List <string> > jobDictionary,
                        List <List <string> > cityDictionary, Expression <Func <Person, object> > selectedAttribute,
                        params Expression <Func <Person, object> >[] pidProperties)
 {
     ParameterK     = parameterK;
     ParameterAlpha = parameterAlpha;
     AttributeValue = attributeValue;
     _expressions   = pidProperties.ToList();
     _properties    = pidProperties.Select(x => x.Compile()).ToList();
     _selectedAttributeExpression = selectedAttribute;
     _selectedAttributeProperty   = selectedAttribute.Compile();
     _algorithmsEnumerator        = new AlgorithmsEnumeratorBuilder()
                                    .SetMaximumKParameter(100)
                                    .SetPID(pidProperties)
                                    .AddDictionary(p => p.City, cityDictionary)
                                    .AddDictionary(p => p.Job, jobDictionary)
                                    .Build();
 }
        public KEAnonimization(int parameterK, int parameterE,
                               List <List <string> > jobDictionary, List <List <string> > cityDictionary,
                               IEnumerable <Expression <Func <Person, object> > > pid,
                               Expression <Func <Person, object> > anonymyzedProperty)

        {
            ParameterK            = parameterK;
            ParameterE            = parameterE;
            _xExpressions         = pid.ToList();
            _xProperties          = pid.Select(p => p.Compile()).ToList();
            _anonymyzedExpression = anonymyzedProperty;
            _anonymyzedProperty   = anonymyzedProperty.Compile();

            _algorithmsEnumerator = new AlgorithmsEnumeratorBuilder()
                                    .SetMaximumKParameter(100)
                                    .SetPID(pid.ToArray())
                                    .AddDictionary(p => p.City, cityDictionary)
                                    .AddDictionary(p => p.Job, jobDictionary)
                                    .Build();
        }
        public XYAnonimization(int parameterK, List <List <string> > jobDictionary,
                               List <List <string> > cityDictionary, IEnumerable <Expression <Func <Person, object> > > xProperties,
                               IEnumerable <Expression <Func <Person, object> > > yProperties)
        {
            ParameterK    = parameterK;
            _xExpressions = xProperties.ToList();
            _xProperties  = xProperties.Select(x => x.Compile()).ToList();
            _yExpressions = yProperties.ToList();
            _yProperties  = yProperties.Select(x => x.Compile()).ToList();

            if (_yExpressions.Intersect(_xExpressions, new ExpressionEqualityComparer()).Any())
            {
                throw new Exception("X and Y sets have to be disjoint");
            }

            _algorithmsEnumerator = new AlgorithmsEnumeratorBuilder()
                                    .SetMaximumKParameter(100)
                                    .SetPID(_xExpressions.ToArray())
                                    .AddDictionary(p => p.City, cityDictionary)
                                    .AddDictionary(p => p.Job, jobDictionary)
                                    .Build();
        }
        public AlgorithmsEnumerator Build()
        {
            var enumerator = new AlgorithmsEnumerator(_maxKParameter, _dictionaries, _pidProperties);

            return(enumerator);
        }