示例#1
0
 /// <summary>
 /// Adds a segment to the beginning of the segment part of the URL
 /// </summary>
 /// <remarks>&lt;scheme&gt;://&lt;host&gt;:&lt;port&gt;/&lt;path segment 1&gt;/&lt;path segment 2&gt;?&lt;query key 1&gt;=&lt;query value 1&gt;&amp;&lt;query key 2&gt;=&lt;query value 2&gt;#&lt;fragment&gt;</remarks>
 /// <param name="segment">The segment to add</param>
 /// <returns>The UrlBuilder so you can chain/build</returns>
 public UrlBuilder AddPathSegmentToBeginning(string segment)
 {
     segment = segment.Replace("/", "").Trim();
     if (!string.IsNullOrWhiteSpace(segment))
     {
         Segments.Insert(0, segment);
     }
     return(this);
 }
示例#2
0
        public void InsertFirst(DcColumn col) // Insert a new segment at the beginning of the path
        {
            Debug.Assert(Size == 0 || col.Output == Input, "A path must continue the first segment inserted in the beginning.");

            Segments.Insert(0, col);
            Input = col.Input;
            if (Output == null)
            {
                Output = col.Output;
            }
        }
示例#3
0
        /// ------------------------------------------------------------------------------------
        public BoundaryModificationResult InsertSegmentBoundary(float newBoundary,
                                                                Func <AnnotationSegment, bool, bool, bool> allowDeletionOfOralAnnotations = null)
        {
            float newSegStart   = 0f;
            var   segBeingSplit = Segments.FirstOrDefault(
                seg => seg.TimeRange.Contains(TimeSpan.FromSeconds(newBoundary), true));

            if (segBeingSplit == null)
            {
                if (Segments.GetLast() != null)
                {
                    newSegStart = Segments.GetLast().End;
                }

                if (!GetIsAcceptableSegmentLength(newSegStart, newBoundary))
                {
                    return(BoundaryModificationResult.SegmentWillBeTooShort);
                }

                AddSegment(newSegStart, newBoundary);
                return(BoundaryModificationResult.Success);
            }

            if (!GetIsAcceptableSegmentLength(segBeingSplit.Start, newBoundary))
            {
                return(BoundaryModificationResult.SegmentWillBeTooShort);
            }

            if (!GetIsAcceptableSegmentLength(newBoundary, segBeingSplit.End))
            {
                return(BoundaryModificationResult.NextSegmentWillBeTooShort);
            }

            if (segBeingSplit.TimeRange.EndSeconds > newBoundary)
            {
                var hasCarefulSpeech   = segBeingSplit.GetHasOralAnnotation(OralAnnotationType.CarefulSpeech);
                var hasOralTranslation = segBeingSplit.GetHasOralAnnotation(OralAnnotationType.Translation);
                if ((hasCarefulSpeech || hasOralTranslation) && (allowDeletionOfOralAnnotations == null ||
                                                                 !allowDeletionOfOralAnnotations(segBeingSplit, hasCarefulSpeech, hasOralTranslation)))
                {
                    return(BoundaryModificationResult.BlockedByOralAnnotations);
                }
            }

            float newSegEnd = segBeingSplit.End;

            segBeingSplit.End = newBoundary;
            var newSegment = new AnnotationSegment(segBeingSplit.Tier, newBoundary, newSegEnd);

            Segments.Insert(GetIndexOfSegment(segBeingSplit) + 1, newSegment);

            return(BoundaryModificationResult.Success);
        }
示例#4
0
 public void AddModuleImport(ImageModuleImport import)
 {
     Segments.Insert(Segments.Count - 1, import);
 }