Exemple #1
0
 public Factory(int classCount, RoleMappedData data, CursOpt opt = CursOpt.Label)
     : base(data, opt)
 {
     // Zero means that any non-negative integer value is fine.
     Contracts.CheckParamValue(classCount >= 0, classCount, nameof(classCount), "Must be non-negative");
     _classCount = classCount;
 }
Exemple #2
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     Contracts.CheckValue(buffer, nameof(buffer));
     Contracts.CheckParamValue(offset >= 0, offset, nameof(offset), "Must be non-negative value");
     Contracts.CheckParamValue(offset < buffer.Length, offset, nameof(offset), "Must be greater than buffer length");
     Contracts.CheckParamValue(count >= 0, count, nameof(count), "Must be non-negative value");
     Contracts.CheckParamValue(count <= buffer.Length - offset, count, nameof(count),
                               "Must or equal than difference between buffer length and offset");
     if (count == 0)
     {
         return(0);
     }
     unsafe
     {
         fixed(byte *pInput = &_buffer[0])
         fixed(byte *pOutput = &buffer[offset])
         {
             return(InternalRead(pInput, pOutput, count));
         }
     }
     throw Contracts.Except("Bad offset {0} and count {1} for length {2} buffer", offset, count, buffer.Length);
 }
Exemple #3
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            Contracts.CheckValue(buffer, nameof(buffer));
            Contracts.CheckParamValue(offset >= 0, offset, nameof(offset), "offset can't be negative value");
            Contracts.CheckParamValue(offset < buffer.Length, offset, nameof(offset), "offset can't be greater than buffer length");
            Contracts.CheckParamValue(count >= 0, count, nameof(count), "count can't be negative value");
            Contracts.CheckParamValue(count <= buffer.Length - offset, count, nameof(count),
                                      "count should be less or equal than difference between buffer length and offset");

            int length = buffer.Length;

            if (count == 0)
            {
                return;
            }
            unsafe
            {
                fixed(byte *pOutput = &_buffer[0])
                fixed(byte *pInput = &buffer[offset])
                {
                    RawWrite(pInput, pOutput, count);
                }
            }
        }
 public ListDataSource(IList <TInput> collection)
 {
     Contracts.CheckParamValue(Utils.Size(collection) > 0, collection, nameof(collection), "Must be non-empty");
     _listCollection = collection;
 }