// Search within catalog (browsing) public ActionResult BrowseCatalog(int?id, PaginationFormModel p) { var catId = (id.HasValue) ? id.Value : -1; var rec = GetRecommendations(); var ic = new IdComparer(); var publ = ReaderManager.Instance.GetPublished(catId).Union(rec).Distinct(ic).OrderByDescending(pb => pb.Rating); // get pricing previews var medias = OrderManager.Instance.GetMedias(); var pricingPreview = new Dictionary <int, Dictionary <string, decimal> >(); foreach (var pb in publ) { decimal subscriptionPrice; decimal price; var pricing = new Dictionary <string, decimal>(); foreach (var media in medias) { var m = new List <OrderMedia>(new[] { media }); OrderManager.Instance.CalculateProductionCost( m, ControllerContext.HttpContext.Application["ProductionCalc"] as XDocument, true, pb.Marketing.BasePrice, out price, out subscriptionPrice); pricing.Add(media.Name, price); } pricingPreview.Add(pb.Id, pricing); } ViewBag.PricingPreview = pricingPreview; return(PartialView("_BrowseCatalog", publ.AsQueryable().ToPagedList(p.Page, p.PageSize, p.FilterValue, p.FilterName, p.Order, p.Dir))); }
public static AutoTreeSortedList <T, TId, TSortKey> Create <TId, TSortKey>( SelectId <T, TId> selectId, SelectParentId <T, TId> selectParentId, IdComparer <TId> idComparer, SelectSortKey <T, TSortKey> selectSortKey, SortKeyComparer <TSortKey> sortKeyComparer) where TId : struct { return(new AutoTreeSortedList <T, TId, TSortKey>( selectId, selectParentId, idComparer, selectSortKey, sortKeyComparer)); }
public static GroupedTreeList <T, TId, TSortKey, TGroupKey> Create <TId, TSortKey, TGroupKey>( SelectId <T, TId> selectId, SelectParentId <T, TId> selectParentId, IdComparer <TId> idComparer, SelectSortKey <T, TSortKey> selectSortKey, SortKeyComparer <TSortKey> sortKeyComparer, SelectGroupKey <T, TGroupKey> selectGroupKey, GroupKeyComparer <TGroupKey> groupKeyComparer, IEnumerable <TGroupKey> groups, GroupedTreeSeparator separator) where TId : struct { return(new GroupedTreeList <T, TId, TSortKey, TGroupKey>( selectId, selectParentId, idComparer, selectSortKey, sortKeyComparer, selectGroupKey, groupKeyComparer, groups, separator)); }
private void DependencyTest() { Dictionary <int, DependentNode> graph = PipelineState.DependencyGraph; IEqualityComparer <DependentNode> comparer = new IdComparer(); //check all nodes have dependencies set correctly foreach (KeyValuePair <int, DependentNode> node in graph) { bool invalid1 = false, invalid2 = false; //check node dependents if (node.Value.Dependents.Length > 0) { NodeSlot[] dependents = node.Value.Dependents; foreach (NodeSlot depId in dependents) { bool found = false; for (int i = 0; i < graph[depId.NodeId].Dependencies.Length; i++) { if (graph[depId.NodeId].Dependencies[i].NodeId == node.Key) { found = true; break; } } Assert.IsTrue(found); } } else { invalid1 = true; } //check node dependencies if (node.Value.Dependencies.Length > 0) { NodeSlot[] dependencies = node.Value.Dependencies; foreach (NodeSlot depId in dependencies) { bool found = false; for (int i = 0; i < graph[depId.NodeId].Dependents.Length; i++) { if (graph[depId.NodeId].Dependents[i].NodeId == node.Key) { found = true; break; } } Assert.IsTrue(found); } } else { invalid2 = true; } //Nodes in the graph should always be connected to other nodes if (invalid1 && invalid2) { Assert.Fail("Node " + node.Key + " does not have any dependencies or dependents!"); } } }
public override int GetHashCode() { return(17 + GetType().GetHashCode() + IdComparer.GetHashCode(Id)); }
public bool Equals(MockAttribute other) { return(null != other && GetType() == other.GetType() && IdComparer.Equals(Id, other.Id)); }
private static List<String> PrimitiveToGDL(SetOfPrimitives primitives) { if (primitives == null) throw new ArgumentNullException(); string name = "";// "name:" + GestureName + Environment.NewLine; List<String> result = new List<String>(); const string SPACE = " "; List<string> steps = new List<string>(); List<string> complexSteps = new List<string>(); int step = 1; IdComparer comparer = new IdComparer(); for (int i = 0; i < primitives.Count; i++) { if (primitives[i] == null) primitives[i] = new PrimitiveData(); } primitives.Sort(comparer); foreach (PrimitiveData primitive in primitives) { if ((primitive.ID.Count == 1)) // Simple primitives { if (primitive.ID[0] != step) { steps.Add("validate as step" + primitive.ID[0]); step++; } if (primitive.ListValue.Count == 0) { if (primitive.Value != 0) steps.Add(SPACE + primitive.Name + ":" + Math.Round(primitive.Value, 2)); else steps.Add(SPACE + primitive.Name); } else { steps.Add(SPACE + primitive.Name + ":" + string.Join(",", primitive.ListValue)); } } else { string primitiveID = primitive.IDtoString(); if (primitiveID != "") primitiveID = " " + primitiveID; if (primitive.ListValue.Count == 0) { complexSteps.Add(SPACE + primitive.Name + primitiveID + ":" + Math.Round(primitive.Value, 2)); } else { complexSteps.Add(SPACE + primitive.Name + primitiveID + ":" + string.Join(",", primitive.ListValue)); } } } if (step == 1) result.Insert(0, "validate"); else result.Insert(0, "validate as step1"); result.AddRange(steps); if (complexSteps.Count > 1) { if (step > 1) result.Add("validate"); result.AddRange(complexSteps); } result.Add("return" + Environment.NewLine + SPACE + "Touch points"); return result; }
public override int GetHashCode() { return(IdComparer.GetHashCode(this)); }