Beispiel #1
0
        /// <summary>
        ///     Checks if there is a matching rule for the specified operation.
        /// </summary>
        /// <param name="nrElement">The type of the element to check.</param>
        /// <param name="nrOperation">The operation to check.</param>
        /// <returns><c>True</c> if there is a matching rule.</returns>
        private bool Reflect(FilterElements nrElement, NROperation nrOperation)
        {
            FilterModifiers filterModifiers = GetFilterModifier(nrOperation.AccessModifier);

            filterModifiers |= nrOperation.OperationModifier == OperationModifier.Static ? FilterModifiers.Static : FilterModifiers.Instance;
            return(RuleMatch(nrElement, filterModifiers));
        }
Beispiel #2
0
        /// <summary>
        ///     Determines if a field will be reflected.
        /// </summary>
        /// <param name="nrField">The field to test.</param>
        /// <returns><c>True</c> if the field should be reflected.</returns>
        public bool Reflect(NRField nrField)
        {
            FilterModifiers filterModifiers = GetFilterModifier(nrField.AccessModifier);

            filterModifiers |= nrField.FieldModifier == FieldModifier.Static ? FilterModifiers.Static : FilterModifiers.Instance;
            FilterElements filterElement = nrField.IsConstant ? FilterElements.Constant : FilterElements.Field;

            return(RuleMatch(filterElement, filterModifiers));
        }
Beispiel #3
0
 /// <summary>
 ///     Checks if there is a rule matching the given values.
 /// </summary>
 /// <param name="element">The element of the rule to check.</param>
 /// <param name="modifier">The modifier of the rule to check.</param>
 /// <returns><c>True</c> if there is a rule.</returns>
 private bool RuleMatch(FilterElements element, FilterModifiers modifier)
 {
     foreach (FilterRule rule in Rules)
     {
         if ((rule.Element == FilterElements.AllElements) || (rule.Element == element))
         {
             if ((rule.Modifier == FilterModifiers.AllModifiers) || ((rule.Modifier & modifier) != 0))
             {
                 return(true);
             }
         }
     }
     return(false);
     //return Rules.Where(rule => rule.Element == FilterElements.AllElements || rule.Element == element)
     //  .Any(rule => rule.Modifier == FilterModifiers.AllModifiers || (rule.Modifier & modifier) != 0);
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new FilterRule with the given values.
 /// </summary>
 /// <param name="modifier">The Modifier for this rule.</param>
 /// <param name="element">The element for this rule</param>
 public FilterRule(FilterModifiers modifier, FilterElements element)
     : this()
 {
     Element  = element;
     Modifier = modifier;
 }
Beispiel #5
0
        /// <summary>
        ///     Checks if there is a matching rule for the specified type.
        /// </summary>
        /// <param name="nrElement">The type of the element to check.</param>
        /// <param name="nrType">The type to check.</param>
        /// <returns><c>True</c> if there is a matching rule.</returns>
        private bool Reflect(FilterElements nrElement, NRTypeBase nrType)
        {
            FilterModifiers filterModifiers = GetFilterModifier(nrType.AccessModifier);

            return(RuleMatch(nrElement, filterModifiers));
        }
Beispiel #6
0
 /// <summary>
 /// Update the elements in the hosting unit
 /// </summary>
 /// <param name="unitKey"></param>
 /// <param name="accommodationKey"></param>
 /// <param name="hostKey"></param>
 /// <param name="elements"></param>
 public void HostingUnitElementsUpdate(int unitKey, int accommodationKey, string hostKey,
                                       FilterElements elements)
 {
     _idalImp.HostingUnitElementsUpdate(unitKey, accommodationKey, hostKey, elements.Clone());
 }
        public void HostingUnitElementsUpdate(int unitKey, int accommodationKey, string hostKey, FilterElements elements)
        {
            if (_hosts.All(x => x.Id != hostKey))
            {
                throw new HostsException("Host doesn't exist");
            }

            if (_hosts.SelectMany(x => x.HostAccommodationsList).All(y => y.AccommodationKey != accommodationKey))
            {
                throw new AccommodationsException("Accommodation doesn't exist");
            }

            if (_hosts.SelectMany(x => x.HostAccommodationsList).SelectMany(y => y.ListOfAllUnits)
                .All(z => z.HostingUnitKey != unitKey))
            {
                throw new HostingUnitsException("host unit doesn't exist");
            }


            foreach (var z in from x in _hosts
                     from y in x.HostAccommodationsList
                     from z in y.ListOfAllUnits
                     where z.HostingUnitKey == unitKey && z.AccommodationKey == accommodationKey && z.HostId == hostKey
                     select z)
            {
                z.UnitOptions = elements.Clone();
                Tools.SaveToXML(_hosts, XmlConfigurations.HostsPath);
                return;
            }

            throw new HostsException("Host not found");
        }