/// <summary> /// Передає діаграму з правильними елементами і рандомно вибраними /// </summary> /// <param name="patter_Id"></param> /// <returns></returns> public static Diagram CreateRandomDiagram(int patter_Id) { var diagram = DiagramWorker.CreateDiagram(patter_Id); var randomDiagram = new Diagram() { Pattern = diagram.Pattern, SubjectReferences = new List <SubjectReferenceView>(), Subjects = Mapper.Map <IEnumerable <Subject>, IEnumerable <SubjectView> > (_GetRandomValues <Subject>(10)), SubjectMethods = Mapper.Map <IEnumerable <SubjectMethod>, IEnumerable <SubjectMethodView> > (_GetRandomValues <SubjectMethod>(5)), SubjectProperties = Mapper.Map <IEnumerable <SubjectProperty>, IEnumerable <SubjectPropertyView> > (_GetRandomValues <SubjectProperty>(5)), MethodParameters = Mapper.Map <IEnumerable <MethodParameter>, IEnumerable <MethodParameterView> > (_GetRandomValues <MethodParameter>(5)) }; diagram = diagram + randomDiagram; diagram.SubjectReferences = new List <SubjectReferenceView>(); return(diagram); }
public DiagramWorker(Diagram diagram) { _received = diagram; _correct = DiagramWorker.CreateDiagram(_received.Pattern.Id); //Minus all basic types _correct.Subjects = _correct.Subjects.Where(x => x.type == SubjectType.Abstract_Class || x.type == SubjectType.Class || x.type == SubjectType.Interface).ToList(); //Set Ids to subjectreferences foreach (var reference in _received.SubjectReferences) { var cxReferences = cx.SubjectReferences .Where(x => x.subject.Id == reference.subject_Id && x.target.Id == reference.target_Id && x.type == reference.type).ToList(); if (cxReferences.Count != 0) { reference.Id = cxReferences.Single().Id; } } }