Exemplo n.º 1
0
        /// <summary>
        ///     Gets the type of the property this path points to
        /// </summary>
        /// <returns>If possible, the property type</returns>
        public Type?GetPropertyType()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("DataModelPath");
            }

            return(Segments.LastOrDefault()?.GetPropertyType());
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gets the property description of the property this path points to
        /// </summary>
        /// <returns>If found, the data model property description</returns>
        public DataModelPropertyAttribute?GetPropertyDescription()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("DataModelPath");
            }

            return(Segments.LastOrDefault()?.GetPropertyDescription());
        }
Exemplo n.º 3
0
            private void AddFormattingSegment()
            {
                InlineSegment lastSegment = Segments.LastOrDefault();

                if (lastSegment == null || lastSegment.Text != null)
                {
                    lastSegment = InlineSegment.CreateEmpty();
                    Segments.Add(lastSegment);
                }
                lastSegment.Color      = _formattingStack.First(s => s.Color != null).Color.Value;
                lastSegment.Background = _formattingStack.First(s => s.Background != null).Background.Value;
            }
Exemplo n.º 4
0
 public bool AddSegment(RaceSegment segment)
 {
     lock (_syncObject)
     {
         var last   = Segments.LastOrDefault();
         var lastNo = last != null ? last.No : 0;
         segment.No = lastNo + 1;
         if (Math.Abs(segment.Speed) < 0.0001)
         {
             return(false);
         }
         Segments.Add(segment);
     }
     return(true);
 }
Exemplo n.º 5
0
        private IEnumerable<IQrDataObject> extractSegment(string specificTagId)
        {
            var merchant = Segments.LastOrDefault(it => it.IdByConvention == QrIdentifier.MerchantAccountInformation);
            var shouldSkip = merchant == null || merchant.Id != specificTagId;
            if (shouldSkip)
            {
                yield break;
            }

            var nextValue = merchant.Value;
            while (!string.IsNullOrWhiteSpace(nextValue))
            {
                var (segment, next) = ExtractSegments(new QrDataObject(nextValue));
                nextValue = next;
                yield return segment;
            }
        }
Exemplo n.º 6
0
        public bool TryAddSegment(UniversalLine line)
        {
            var allowance = Segments.LastOrDefault()?.Length * 0.1 ?? 0.0;

            if (!Lines.Any())
            {
                Lines.Add(line);
            }

            else if (VisuallyClosed || line.VisuallyClosed && Lines.Any())
            {
                return(false);
            }

            else if (AlmostEqual(line.EndPoint, StartPoint, allowance))
            {
                Lines.Insert(0, line);
            }
            else if (AlmostEqual(line.StartPoint, EndPoint, allowance))
            {
                Lines.Add(line);
            }
            else if (AlmostEqual(line.StartPoint, StartPoint, allowance))
            {
                line.Reverse();
                Lines.Insert(0, line);
            }
            else if (AlmostEqual(line.EndPoint, EndPoint, allowance))
            {
                line.Reverse();
                Lines.Add(line);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        public bool AddSegments(IEnumerable <RaceSegment> segmentsToAdd)
        {
            var last                 = Segments.LastOrDefault();
            var lastNo               = last != null ? last.No : 0;
            var lastSpeed            = last != null ? last.Speed : 0;
            var numberedSegmentsList = new List <RaceSegment>();

            lock (_syncObject)
            {
                foreach (var s in segmentsToAdd)
                {
                    s.No = lastNo + 1;
                    if (Math.Abs(s.Speed) < 0.0001)
                    {
                        s.Speed = lastSpeed;
                    }
                    lastNo = s.No;
                    numberedSegmentsList.Add(s);
                }
                Segments.AddRange(numberedSegmentsList);
            }
            return(true);
        }
Exemplo n.º 8
0
 private string getSegment(QrIdentifier identifier)
 => Segments?.LastOrDefault(it => it.Identifier == identifier)?.Value ?? "undefine";
Exemplo n.º 9
0
 private string getSegment(QrIdentifier identifier)
 => Segments?.LastOrDefault(it => it.IdByConvention == identifier)?.Value ?? null;
Exemplo n.º 10
0
 /// <summary>
 /// ดึงข้อมูลจากส่วนประกอบ โดยการระบุประเภทข้อมูลที่ต้องการ
 /// </summary>
 /// <param name="identifier">ประเภทข้อมูลที่ต้องการอ่าน</param>
 protected string GetSegmentValue(QrIdentifier identifier)
 => Segments?.LastOrDefault(it => it.IdByConvention == identifier)?.Value ?? null;