예제 #1
0
 public ConfigLevelVar(bool invert, ConfigLevelVar src) : base(src.id)
 {
     _invert     = invert;
     firstItem   = src.firstItem;
     tolerance   = src.tolerance;
     extendArray = src.extendArray;
     gradeArray  = src.gradeArray;
 }
예제 #2
0
        public void NullArray()
        {
            var array = new ReadonlyArray <object>(null);

            Assert.Equal(0, array.Length);

            var enumerator = array.GetEnumerator();

            Assert.False(enumerator.MoveNext());
        }
예제 #3
0
        public void TruncatedArray()
        {
            var array = new ReadonlyArray <int>(new[] { 1, 2, 3 }, 2);

            Assert.Equal(2, array.Length);

            var enumerator = array.GetEnumerator();

            Assert.True(enumerator.MoveNext());
            Assert.Equal(1, enumerator.Current);

            Assert.True(enumerator.MoveNext());
            Assert.Equal(2, enumerator.Current);

            Assert.False(enumerator.MoveNext());
        }
예제 #4
0
    private static void EnsureCreate()
    {
      if(_parseValues != null)
        return;

      var type = typeof(TEnum);

      var staticFields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
      
      _parseValues = new SortedList<int, TEnum>(staticFields.Length);
      if (staticFields.Length == 0)
      {
        _fields = Array.Empty<TEnum>();
      }
      else
      {
        var fields = new TEnum[staticFields.Length];
        int idx = 0;
        for (var index = 0; index < staticFields.Length; index++)
        {
          var notCastItem = staticFields[index].GetValue(null);
          if (notCastItem is TEnum)
          {
            var item = (TEnum)notCastItem;
            fields[idx] = item;
            _parseValues.Add(item.ToString().GetHashCode(), item);

            idx += 1;
          }

          if (staticFields.Length != idx)
          {
            Array.Resize(ref fields, idx + 1);
          }
        }
        
        Array.Sort(fields);
        _fields = fields;
      }
    }
예제 #5
0
 private PropertyValidator(PropertyInfo property, bool shouldFollow, ReadonlyArray <IConstraint <TState> > constraints)
 {
     Property        = property;
     _constraints    = constraints;
     IncludeChildren = shouldFollow;
 }