private ResponseViewModel[] SearchInternal(object source) { var result = (IEnumerable <ResponseViewModel>)source; if (SearchFromSelectedParts) { result = result.Where(r => Parts.Any(p => p == r.PartNumber)); } if (SearchFromSelectedPeople) { result = result.Where(r => People.Any(p => p == r.Tag)); } if (SearchFromSelectedDate && (StartDate != null || EndDate != null)) { var start = StartDate ?? DateTime.MinValue; var end = EndDate == null?DateTime.MaxValue:EndDate.Value.Date.Add(new TimeSpan(23, 59, 59)); result = result.Where(r => r.Date >= start && r.Date <= end); } var buffer = new StringBuilder(1000); return(result.Where(r => { CharWidthNormalizer.NormalizeFast(r.Text, buffer); return Condition.IsMatch(CharWidthNormalizer.Normalize(buffer.ToString())); }).ToArray()); }
public static void ReplaceBlipContent(this WordprocessingDocument doc, Blip blip, Bitmap bitmap, string newImagePartId, ImagePartType imagePartType = ImagePartType.Png) { if (doc.MainDocumentPart !.Parts.Any(p => p.RelationshipId == blip.Embed)) { doc.MainDocumentPart.DeletePart(blip.Embed !); } ImagePart img = CreateImagePart(doc, bitmap, newImagePartId, imagePartType); blip.Embed = doc.MainDocumentPart.GetIdOfPart(img); }
public OpenWordRunText(params string[] lines) { foreach (string l in lines) { Parts.Add(new Text(l)); Parts.Add(new Break()); } if (Parts.Any()) { Parts.Remove(Parts.Last()); } }
// Saves current Computer to human-readable text file, showing price info public void SaveToReceipt(string dir) { using (StreamWriter sw = new StreamWriter(dir)) { for (int i = 0; i < 100; i++) { sw.Write("-"); } sw.WriteLine(); sw.WriteLine($"{"Type",-20} | {"Manufacturer",-20} | {"Name",-20} | {"Model",-20} | {"Price",-20:C}"); for (int i = 0; i < 100; i++) { sw.Write("-"); } sw.WriteLine(); //foreach (var part in Parts) sw.WriteLine(part.ToStringInFile()); foreach (var part in this) { sw.WriteLine(part.ToStringInFile()); } for (int i = 0; i < 100; i++) { sw.Write("-"); } sw.WriteLine(); //sw.WriteLine($"{DateTime.Today.ToLongDateString(),50} Total: {Price:C}"); //for (int i = 0; i < 100; i++) sw.Write("-"); if (Parts.Any(x => x.IsDiscounted)) { sw.WriteLine($"{DateTime.Now,50} Total (PROMO PRICE): {Price:C}"); for (int i = 0; i < 100; i++) { sw.Write("-"); } } else { sw.WriteLine($"{DateTime.Now,50} Total: {Price:C}"); for (int i = 0; i < 100; i++) { sw.Write("-"); } } } }
protected override void EnsureValidState() { if (Parts == null) { throw new Exception("Model Invalid. Parts can not be null."); } foreach (var part in Parts) { if (Parts.Any(x => (x.Scheduled.Overlap(part.Scheduled) && x != part))) { throw new Exception("Model Invalid. Parts overlap"); } } }
internal void UpdateHasTranslation(bool slideHasTranslation) { bool newHasTranslation; if (slideHasTranslation) { newHasTranslation = true; } else { newHasTranslation = Parts.Any(part => part.Slides.Any(slide => slide.HasTranslation)); } if (newHasTranslation != hasTranslation) { OnPropertyChanging("HasTranslation"); hasTranslation = newHasTranslation; OnPropertyChanged("HasTranslation"); } }
/// <summary> /// Determines whether or not the media item contains the specified search in any of it's properties /// </summary> /// <param name="searchText">Search text to look for</param> /// <returns>True if the media item contains the specified search in any of it's properties, false if not</returns> public Boolean ContainsSearchText(String searchText) { if (String.IsNullOrEmpty(searchText)) { return(true); } searchText = searchText.ToLower(); if (Name.ToLower().Contains(searchText)) { return(true); } if (Genre.ToLower().Contains(searchText)) { return(true); } if (MediaItemContainsSearchText(searchText)) { return(true); } if (Parts.Any(p => p.Location.ToLower().Contains(searchText))) { return(true); } if (Tags.Any(p => p.ToLower().Contains(searchText))) { return(true); } return(false); }
public IEnumerable <FluentRouteSetter> GetFluentRouteSetters() { var setters = new List <FluentRouteSetter>(); if (!Parts.Any()) { return(setters); } var alwaysGenerate = new[] { "index" }; var parts = Parts .Where(p => !p.Required || alwaysGenerate.Contains(p.Name)) .Where(p => !string.IsNullOrEmpty(p.Name)) .ToList(); var returnType = CsharpNames.GenericOrNonGenericDescriptorName; foreach (var part in parts) { var p = part; var paramName = p.Name.ToPascalCase(); if (paramName.Length > 1) { paramName = paramName.Substring(0, 1).ToLowerInvariant() + paramName.Substring(1); } else { paramName = paramName.ToLowerInvariant(); } var routeValue = "v"; var routeSetter = p.Required ? "Required" : "Optional"; var code = $"public {returnType} {p.InterfaceName}({p.HighLevelTypeName} {paramName}) => Assign({paramName}, (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", {routeValue}));"; var xmlDoc = $"///<summary>{p.Description}</summary>"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); if (paramName == "index") { code = $"public {returnType} {p.InterfaceName}<TOther>() where TOther : class "; code += $"=> Assign(typeof(TOther), (a,v)=>a.RouteValues.{routeSetter}(\"{p.Name}\", ({p.HighLevelTypeName})v));"; xmlDoc = $"///<summary>a shortcut into calling {p.InterfaceName}(typeof(TOther))</summary>"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); } if (paramName == "index" && p.Type == "list") { code = $"public {returnType} AllIndices() => Index(Indices.All);"; xmlDoc = $"///<summary>A shortcut into calling Index(Indices.All)</summary>"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); } if (paramName == "fields" && p.Type == "list") { code = $"public {returnType} Fields<T>(params Expression<Func<T, object>>[] fields) "; code += $"=> Assign(fields, (a,v)=>a.RouteValues.{routeSetter}(\"fields\", (Fields)v));"; xmlDoc = $"///<summary>{p.Description}</summary>"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); } } return(setters); }
public override bool IsOneOf(params Terrain[] options) => Parts.Any(part => part.IsOneOf(options));
public override bool Is(Terrain terrain) => Parts.Any(part => part.Is(terrain));
public bool ContainsContent(IPartEntity content) => As.Expression(() => Parts.Any(p => p.Content.Is(content)));
/// <summary> /// Determines whether the specified <paramref name="layer"/> is currently enabled. /// </summary> /// <param name="layer">The layer.</param> public bool IsLayerEnabled(string layer) { return(Parts.Any(p => p.IsLayerEnabled(layer))); }
public bool KeyExists(string key) { return(Parts.Any(p => p.IndexOf(key) != -1)); }
public bool HasPartTypeOf(Type type) { return(Parts.Any(part => part.Valid && part.IsTypeOf(type))); }
public int GetNewPartId() => Parts.Any() ? Parts.Max(part => part.ID) + 1 : 0;