Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether sub-state combination is applicable for the specified state.
        /// </summary>
        /// <param name="state">
        /// The state.
        /// </param>
        /// <param name="substateCombinationSet">
        /// The sub-state Combination Set.
        /// </param>
        /// <returns>
        /// <c>true</c> if sub-state combination is applicable for the specified state; otherwise, <c>false</c>.
        /// </returns>
        private bool IsSubstateCombinationApplicable([NotNull] State state, [NotNull] SubstateCombinationSet substateCombinationSet)
        {
            Debug.ArgumentNotNull(state, "state");
            Debug.ArgumentNotNull(substateCombinationSet, "substateCombinationSet");

            return(substateCombinationSet.SubstateCombinations.Aggregate(!substateCombinationSet.SubstateCombinations.Any(), (val, combination) => val || (state.Substates.Aggregate(true, (v, e) => v && (e.Active == combination[e.Code])) && (state.Substates.Count > 0))));
        }
Ejemplo n.º 2
0
        private SubstateCombinationSet CreateSubstateCombinationSetFromItem([NotNull] Sitecore.Data.Items.Item item, [NotNull] IDictionary <string, bool> substateCombinationPrototype)
        {
            Debug.ArgumentNotNull(item, "item");
            Debug.ArgumentNotNull(substateCombinationPrototype, "substateCombinationPrototype");

            SubstateCombinationSet             result = new SubstateCombinationSet();
            List <IDictionary <string, bool> > substateCombinationList = new List <IDictionary <string, bool> >();

            result.SubstateCombinations = substateCombinationList;

            foreach (Sitecore.Data.Items.Item substateCombinationItem in item.Children)
            {
                IDictionary <string, bool> substateCombination = new Dictionary <string, bool>(substateCombinationPrototype);

                foreach (Sitecore.Data.Items.Item substateItem in ((Sitecore.Data.Fields.MultilistField)substateCombinationItem.Fields[SubstatesFieldName]).GetItems())
                {
                    substateCombination[substateItem.Fields[CodeFieldName].Value] = !substateCombination[substateItem.Fields[CodeFieldName].Value];
                }

                substateCombinationList.Add(substateCombination);
            }

            return(result);
        }
    private SubstateCombinationSet CreateSubstateCombinationSetFromItem([NotNull] Sitecore.Data.Items.Item item, [NotNull] IDictionary<string, bool> substateCombinationPrototype)
    {
      Debug.ArgumentNotNull(item, "item");
      Debug.ArgumentNotNull(substateCombinationPrototype, "substateCombinationPrototype");

      SubstateCombinationSet result = new SubstateCombinationSet();
      List<IDictionary<string, bool>> substateCombinationList = new List<IDictionary<string, bool>>();

      result.SubstateCombinations = substateCombinationList;

      foreach (Sitecore.Data.Items.Item substateCombinationItem in item.Children)
      {
        IDictionary<string, bool> substateCombination = new Dictionary<string, bool>(substateCombinationPrototype);

        foreach (Sitecore.Data.Items.Item substateItem in ((Sitecore.Data.Fields.MultilistField)substateCombinationItem.Fields[SubstatesFieldName]).GetItems())
        {
          substateCombination[substateItem.Fields[CodeFieldName].Value] = !substateCombination[substateItem.Fields[CodeFieldName].Value];
        }

        substateCombinationList.Add(substateCombination);
      }

      return result;
    }