public bool InRange(int index) { if (index == 0 & Contents.Count() == 0) { return(true); } int last = Contents.Count() - 1; return(index > 0 || index <= last); }
/// <summary> /// Definition from IAI: The dimension curve directed callout is a dimension callout, which includes a dimension line. It normally presents an extent and/or direction of the product shape. Subtypes are introduced to declare specific forms of dimension curve directed callouts, such as: /// /// linear dimension /// radius dimension /// diameter dimension /// angular dimension /// /// </summary> /// <returns></returns> public override string WhereRule() { var result = ""; if (Contents.Count(e => e is IfcDimensionCurve) != 1) { result += "WR41: There shall be exactly one dimension curve in the set of draughting callout elements. \n"; } if (Contents.Count(e => e is IfcProjectionCurve) > 2) { result += "WR42: There shall be only zero, one, or two projection curves within the content of the callout. \n"; } return(result); }
private bool Equals(CategoryTreeFolder other) { if (Name != other.Name) { return(false); } int contentsCount = Contents.Count(); if (contentsCount != other.Contents.Count()) { return(false); } for (var i = 0; i < contentsCount; i++) { if (!Contents.ElementAt(i).Equals(other.Contents.ElementAt(i))) { return(false); } } return(true); }
private int GetByteLength() { return(BUNDLE_STRING_SIZE + TIME_TAG_SIZE + (Contents.Count() * MESSAGE_SIZE_SIZE) + GetMessagesBytesLength()); }
/// <summary> /// Inserts an <see cref="IHtmlElement" /> to the <see cref="Contents" /> at the given <paramref name="index" /> /// </summary> /// <param name="index">The index at which the <paramref name="elements" /> should be inserted</param> /// <param name="elements"> /// The elements that will be inserted at the specifix <paramref name="index" /> of the contents of /// this tag /// </param> /// <returns>this <see cref="HtmlTag" /></returns> public HtmlTag Insert(int index, IEnumerable <IHtmlElement> elements) { if (elements == null) { throw new ArgumentNullException("elements"); } if (index < 0 || index > _contents.Count) { throw new IndexOutOfRangeException( string.Format("Cannot insert anything at index '{0}', content elements count = {1}", index, Contents.Count())); } foreach (var element in elements.Reverse()) { _contents.Insert(index, element); element.Parent = this; } return(this); }
public string Build(List <ContentBase> contents) { var components = new List <IComponent>(); var corsCount = Contents.Count(c => c.Cors != null); if (corsCount > 0 && corsCount != Contents.Count()) { throw new ArgumentException("CORS must be set for all contents, or none."); } var txtContents = GetTextContents(); var imgContents = GetImageContents(); var soundContents = GetSoundContents(); switch (ElemBuilder.ContentType) { case ContentTypeFlag.Html: case ContentTypeFlag.RawText: if (imgContents.Any()) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Text contains non-text IContent"); } if (txtContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Text does not contain any text IContent"); } BuildTextComponents(0, txtContents.Count, CorsFull.Left, CorsFull.Top, CorsFull.Right, CorsFull.Bottom, txtContents, components); break; case ContentTypeFlag.Image: if (txtContents.Any()) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Image contains non-image IContent"); } if (imgContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Image does not contain any image IContent"); } BuildImageComponents(0, imgContents.Count, CorsFull.Left, CorsFull.Top, CorsFull.Right, CorsFull.Bottom, imgContents, components); break; case ContentTypeFlag.Sound: if (txtContents.Any()) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Image contains non-image IContent"); } if (imgContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.Image does not contain any image IContent"); } BuildImageComponents(0, imgContents.Count, CorsFull.Left, CorsFull.Top, CorsFull.Right, CorsFull.Bottom, imgContents, components); break; case ContentTypeFlag.ImageAndRawText: case ContentTypeFlag.ImageAndHtml: if (txtContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.ImageAndText does not contain any text IContent"); } if (imgContents.Any() == false) { throw new InvalidCastException("ElementBuilder ContentTypeFlag.ImageAndText does not contain any image IContent"); } BuildTextComponents(0, txtContents.Count, CorsVSplitLeft.Left, CorsVSplitLeft.Top, CorsVSplitLeft.Right, CorsVSplitLeft.Bottom, txtContents, components); BuildImageComponents(components.Count, imgContents.Count, CorsVSplitRight.Left, CorsVSplitRight.Top, CorsVSplitRight.Right, CorsVSplitRight.Bottom, imgContents, components); break; default: throw new NotImplementedException(); } var compsText = components.Select(c => c.ToString()) .ToList(); return(string.Format(ComponentsSkeleton, compsText.Count, string.Join("\n", compsText))); }
private decimal GetBreadCount() { return(Contents.Count(p => string.Compare(p.Name, Bread.ProductName, true) == 0)); }
private int CalculateRemainingItemDropCount() => MaximumResultCount - Contents.Count(e => e.AlwaysDrop && e.IsActive);