public ProfileRegion(ProfileRegion parent) { _parent = parent; (_parent._children ?? (_parent._children = new List<ProfileRegion>())).Add(this); _currentRegion = this; _start = _watch.ElapsedMilliseconds; }
public ProfileRegion(ProfileRegion parent) { _parent = parent; (_parent._children ?? (_parent._children = new List <ProfileRegion>())).Add(this); _currentRegion = this; _start = Watch.ElapsedMilliseconds; }
public virtual bool Apply(ref string line) { using (var profileRegion = new ProfileRegion(string.Format("Patch {0}", this.Name ?? this.Pattern))) { int index = line.IndexOf(this.Pattern, StringComparison.Ordinal); bool didMatch = false; while (index >= 0) { didMatch = true; line = string.Concat( line.Substring(0, index), this.Replacement, line.Substring(index + this.Pattern.Length, line.Length - index - this.Pattern.Length)); this.ApplyCount++; index = line.IndexOf(this.Pattern, index + this.Replacement.Length, StringComparison.Ordinal); } if (didMatch) { profileRegion.Tag = this.ApplyCount; Profiler.RegionFinish(profileRegion); } else { profileRegion.Discard = true; } return didMatch; } }