internal CodeContext( string name, IEnumerable<string> tags, string authors = null, string source = null, string syntax = null, string description = null, string prerequisites = null, CodeContext parentContext = null) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("name"); if (tags == null) throw new ArgumentException("tags"); Name = name; Authors = authors ?? (parentContext != null ? parentContext.Authors : string.Empty); Source = source ?? (parentContext != null ? parentContext.Source : string.Empty); Syntax = syntax ?? (parentContext != null ? parentContext.Syntax : string.Empty); SpecificTags = new SortedSet<string>(tags); Description = description ?? string.Empty; Prerequisites = prerequisites ?? string.Empty; ParentContext = parentContext; AllTags = parentContext != null ? new SortedSet<string>(SpecificTags.Union(parentContext.AllTags)) : new SortedSet<string>(SpecificTags); }
internal CodeSnippet( string code, IEnumerable<string> tags, CodeContext context = null) { if (tags == null) throw new ArgumentException("tags"); Code = code ?? string.Empty; Authors = context != null ? context.Authors : string.Empty; Source = context != null ? context.Source : string.Empty; Syntax = context != null ? context.Syntax : string.Empty; SpecificTags = new SortedSet<string>(tags); AllTags = context != null ? new SortedSet<string>(SpecificTags.Union(context.AllTags)) : new SortedSet<string>(SpecificTags); Context = context; }