コード例 #1
0
        public void GivenValidNestedStructure_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(NestedList.Valid());

            Assert.Empty(results);
        }
        public int IndexOf(object value)
        {

            int index = CustomRows.IndexOf(value);
            if (index == -1)
                return NestedList.IndexOf(value);
            return index + NestedList.Count;
        }
コード例 #3
0
        public void GivenInvalidChild_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(NestedList.WithInvalidChild());

            Assert.Equal(3, results.Count);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", "Child[0].RequiredString");
            ValidationResultUtility.AssertValidationResultEquals(results[1], "The RequiredLong field is required.", "Child[0].RequiredLong");
            ValidationResultUtility.AssertValidationResultEquals(results[2], "The RequiredUnsignedLong field is required.", "Child[0].RequiredUnsignedLong");
        }
コード例 #4
0
        public static DelegateFilterBuilder MatchItem <TListItem>(this NestedList <TListItem> value,
                                                                  Expression <Func <TListItem, Filter> > filterExpression)
        {
            return(new DelegateExpressionFilterBuilder <TListItem>(filterExpression, filter => x =>
            {
                // As the path must be absolute nested NestedFilters must have the path prepended
                PrependPathOnNestedFilters(x, filter);

                return new NestedFilter(x, filter);
            }));
        }
コード例 #5
0
 public void Reset()
 {
     progress = 0;
     total    = 0;
     size     = 0;
     current  = new NestedList <Entry>();
     next     = new NestedList <Entry>();
     left     = new List <Entry>();
     right    = new List <Entry>();
     sorted   = new List <Entry>();
 }
コード例 #6
0
        public void SerializeNestedList()
        {
            var list1 = new SomeList()
            {
                new ListItem("aaa"), new ListItem("bbb")
            };
            var list2 = new SomeList()
            {
                new ListItem("ccc"), new ListItem("ddd")
            };
            var nestedList = new NestedList();

            nestedList.Add(list1);
            nestedList.Add(list2);

            Serializer.Serialize(Stream.Null, nestedList);
        }
コード例 #7
0
    public int LoopCount(int n)
    {
        if (n < 2)
        {
            return(0);
        }

        int        count   = 0;
        List <int> current = new List <int>(n);
        List <int> next    = new List <int>(n);

        for (int i = 0; i < n; i++)
        {
            current.Add(1);
        }

        while (true)
        {
            if (current.Count > 1)
            {
                int sum = current[0] + current[1];
                count += sum - 1;
                next.Add(sum);
                current.RemoveRange(0, 2);
            }
            else if (current.Count > 0)
            {
                int sum = current[0];
                next.Add(sum);
                current.RemoveAt(0);
            }
            else
            {
                if (next[0] == n)
                {
                    return(count);
                }
                current = new List <int>(next);
                next.Clear();
            }
        }
    }
コード例 #8
0
 public Team(string name)
 {
     TeamName = name;
     Players = new NestedList<Player>();
 }
コード例 #9
0
 public League(string name)
 {
     LeagueName = name;
     Teams = new NestedList<Team>();
 }
コード例 #10
0
 public Department(string name)
 {
     Name      = name;
     Employees = new NestedList <Employee>();
 }
コード例 #11
0
 public Company(string name)
 {
     Name        = name;
     Departments = new NestedList <Department>();
 }
コード例 #12
0
 public Team(string name)
 {
     TeamName = name;
     Players  = new NestedList <Player>();
 }
コード例 #13
0
 public League(string name)
 {
     LeagueName = name;
     Teams      = new NestedList <Team>();
 }
コード例 #14
0
 public Department(string name)
 {
     Name = name;
     Employees = new NestedList<Employee>();
 }
コード例 #15
0
 public Company(string name)
 {
     Name = name;
     Departments = new NestedList<Department>();
 }