Пример #1
0
        public int CompareTo(ISpecElement other)
        {
            var tube = other as Tube;

            if (tube == null)
            {
                return(-1);
            }

            var result = Diametr.CompareTo(tube.Diametr);

            if (result != 0)
            {
                return(result);
            }

            result = Thickness.CompareTo(tube.Thickness);
            if (result != 0)
            {
                return(result);
            }

            result = Length.CompareTo(tube.Length);
            if (result != 0)
            {
                return(result);
            }

            return(0);
        }
Пример #2
0
        public override int CompareTo(ISpecElement other)
        {
            var det = other as BarDetail;

            if (det == null)
            {
                return(-1);
            }
            var res = prefix.CompareTo(det.prefix);

            if (res != 0)
            {
                return(res);
            }

            res = base.CompareTo(other);
            if (res != 0)
            {
                return(res);
            }

            res = BlockNameDetail.CompareTo(det.BlockNameDetail);
            if (res != 0)
            {
                return(res);
            }

            res = this.CompareTo(det);

            return(res);
        }
Пример #3
0
        public int CompareTo(ISpecElement other)
        {
            var s = other as SlabOpening;

            if (s == null)
            {
                return(-1);
            }
            int res = 0;

            if (!string.IsNullOrEmpty(Mark))
            {
                res = TableService.alpha.Compare(Mark, s.Mark);
            }
            if (res != 0)
            {
                return(res);
            }
            res = length.CompareTo(s.length);
            if (res != 0)
            {
                return(res);
            }
            res = width.CompareTo(s.width);
            if (res != 0)
            {
                return(res);
            }
            res = Role.CompareTo(s.Role);
            return(res);
        }
Пример #4
0
 protected void AddElementary(ISpecElement elem)
 {
     if (elem != null && elem.Amount != 0)
     {
         Elementary.Add(elem);
     }
 }
Пример #5
0
        public int CompareTo(ISpecElement other)
        {
            var s = other as SlabSleeve;

            if (s == null)
            {
                return(-1);
            }
            int res = 0;

            if (!string.IsNullOrEmpty(Mark))
            {
                res = TableService.alpha.Compare(Mark, s.Mark);
            }
            if (res != 0)
            {
                return(res);
            }
            res = diam.CompareTo(s.diam);
            if (res != 0)
            {
                return(res);
            }
            res = depth.CompareTo(s.depth);
            if (res != 0)
            {
                return(res);
            }
            res = length.CompareTo(s.length);
            if (res != 0)
            {
                return(res);
            }
            return(Role.CompareTo(s.Role));
        }
Пример #6
0
        public virtual bool Equals(ISpecElement other)
        {
            if (other == null)
            {
                return(false);
            }
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }
            var c = other as ConstructionElement;

            if (c == null)
            {
                return(false);
            }


            var res = prefix == c.prefix &&
                      Size.Equals(c.Size) &&
                      Elements.SequenceEqual(c.Elements) &&
                      Amount == c.Amount;

            return(res);
        }
Пример #7
0
 protected virtual void AddElement(ISpecElement elem)
 {
     if (elem != null && elem.Amount != 0)
     {
         Elements.Add(elem);
     }
 }
Пример #8
0
        public bool Equals(ISpecElement other)
        {
            var s = other as SlabSleeve;

            if (s == null)
            {
                return(false);
            }
            return(Mark == s.Mark && diam == s.diam && depth == s.depth && length == s.length && Role == s.Role);
        }
Пример #9
0
        public bool Equals(ISpecElement other)
        {
            var conc = other as Concrete;

            if (conc == null)
            {
                return(false);
            }
            return(ClassB.Equals(conc.ClassB));
        }
Пример #10
0
        public bool Equals(ISpecElement other)
        {
            var s = other as SlabOpening;

            if (s == null)
            {
                return(false);
            }
            return(Mark == s.Mark && length == s.length && width == s.width && Role == s.Role);
        }
Пример #11
0
        public override bool Equals(ISpecElement other)
        {
            var b = other as Pylon;

            if (b == null)
            {
                return(false);
            }
            return(length == b.length && width == b.width && height == b.height);
        }
Пример #12
0
        public bool Equals(ISpecElement other)
        {
            var s = other as Opening;

            if (s == null)
            {
                return(false);
            }
            return(Mark == s.Mark && length == s.length && height == s.height &&
                   string.Equals(Role, s.Role, StringComparison.OrdinalIgnoreCase) &&
                   string.Equals(Elevation, s.Elevation, StringComparison.OrdinalIgnoreCase));
        }
Пример #13
0
        public bool Equals(ISpecElement other)
        {
            var tube = other as Tube;

            if (tube == null)
            {
                return(false);
            }
            return(Diametr == tube.Diametr &&
                   Thickness == tube.Thickness &&
                   Length == tube.Length);
        }
Пример #14
0
        public bool Equals(ISpecElement other)
        {
            var s = other as WallSleeve;

            if (s == null)
            {
                return(false);
            }
            return(Mark == s.Mark && diam == s.diam && depth == s.depth && length == s.length &&
                   string.Equals(Role, s.Role, StringComparison.OrdinalIgnoreCase) &&
                   string.Equals(Elevation, s.Elevation, StringComparison.OrdinalIgnoreCase));
        }
Пример #15
0
        public override void Calculate()
        {
            // Нумерация элементов в конструкции
            SpecGroup.SpecGroupService service = new SpecGroup.SpecGroupService(Block.IdBlRef.Database);
            service.Numbering(Elementary);
            NumberingElementary();

            string mark = Block.GetPropValue <string> (propMark);

            ConstructionElement = GetConstruction(mark);
            base.AddElement(ConstructionElement);
            base.AddElement(Concrete);
        }
Пример #16
0
        public int CompareTo(ISpecElement other)
        {
            var conc = other as Concrete;

            if (conc == null)
            {
                return(-1);
            }

            var res = ClassB.CompareTo(conc.ClassB);

            return(res);
        }
Пример #17
0
        public ISpecElement RunStory(ISpecElement element,IDSLDefinition DSL,string columnseparator)
        {
            _DslRunner = new DSLRunner(DSL);
            try
            {
                if (element.Type != ElementType.Story) return element;
                var result = element.Clone();
                var newchildren = new List<ISpecElement>(result.Children.Where(o => o.Type != ElementType.Scenario));
                foreach (var sc in element.Children.Where(e => e.Type == ElementType.Scenario))
                {
                    var example = GetData(sc.Children.Where(o => o.Type == ElementType.Example).FirstOrDefault(), columnseparator);
                    if (example.Keys.Count() > 0)
                    {
                        for (var j = 0; j < example[example.Keys.First()].Count; j++)
                        {
                            ISpecElement x = sc.Clone();
                            x.Children = x.Children.Where(o => o.Type != ElementType.Example).Select(o => o.Clone()).ToArray();

                            foreach (var n in example.Keys)
                            {
                                x.Description = x.Description.Replace(n, example[n][j]);
                                foreach (var y in x.Children)
                                    y.Description = y.Description.Replace(n, example[n][j]);
                            }
                            newchildren.Add(x);
                        }
                    }
                    else
                    {
                        newchildren.Add(sc);
                    }
                }
                result.Children = newchildren;
                foreach (var q in result.Children)
                    RunScenario(q, _DslRunner.GetNewContext(), columnseparator, true);
                result.Status = true;
                return result;

            }
            catch (Exception ex)
            {
                element.Status = null;
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                element.StatusInfo = ex.GetType().Name + ":" + ex.Message;
            }
            return element;
        }
Пример #18
0
        public virtual int CompareTo(ISpecElement other)
        {
            var arm = other as Bar;

            if (arm == null)
            {
                return(-1);
            }
            var res = Index.CompareTo(arm.Index);

            if (res != 0)
            {
                return(res);
            }

            res = prefix.CompareTo(arm.prefix);
            if (res != 0)
            {
                return(res);
            }

            res = Diameter.CompareTo(arm.Diameter);
            if (res != 0)
            {
                return(-res);
            }

            res = Length.CompareTo(arm.Length);
            if (res != 0)
            {
                return(-res);
            }

            res = Class.CompareTo(arm.Class);
            if (res != 0)
            {
                return(res);
            }

            res = Gost.CompareTo(arm.Gost);
            if (res != 0)
            {
                return(res);
            }

            return(res);
        }
Пример #19
0
 protected void FillElemPropNameDesc(ISpecElement elem, string posPropertyName, string descPropertyName)
 {
     if (elem != null && elem.Amount != 0)
     {
         // Поз
         Block.FillPropValue(posPropertyName, elem.Mark);
         // Опис
         Block.FillPropValue(descPropertyName, elem.GetDesc());
     }
     else
     {
         // Поз
         Block.FillPropValue(posPropertyName, "", isRequired: false);
         // Опис
         Block.FillPropValue(descPropertyName, "", isRequired: false);
     }
 }
Пример #20
0
 public IDSLDefinition GetDSL(ISpecElement story,Dictionary<string,IDSLDefinition> dsls)
 {
     var key = story.Description.Trim().ToLower();
     string contextname=null;
     var contextelement = story.Children.Where(e => e.Type == ElementType.Context).FirstOrDefault();
     if (contextelement != null)
     {
         contextname = contextelement.Description.Trim().ToLower();
         contextelement.Status = true;
     }
     if (string.IsNullOrEmpty(contextname))
         contextname = dsls.Keys.First();
     else
         foreach(var k in dsls.Keys)
             if (k.ToLower().Trim()==contextname.ToLower())
                return dsls[k];
     return null;
 }
Пример #21
0
        public virtual int CompareTo(ISpecElement other)
        {
            var c = other as ConstructionElement;

            if (c == null)
            {
                return(-1);
            }

            var res = Size.CompareTo(c.Size);

            if (res != 0)
            {
                return(res);
            }

            res = Amount.CompareTo(c.Amount);
            return(res);
        }
Пример #22
0
        public override bool Equals(ISpecElement other)
        {
            var det = other as BarDetail;

            if (det == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, det))
            {
                return(true);
            }

            var res = prefix == det.prefix &&
                      BlockNameDetail == det.BlockNameDetail &&
                      base.Equals(other) &&
                      this.Equals(det);

            return(res);
        }
Пример #23
0
        public int CompareTo(ISpecElement other)
        {
            var s = other as WallSleeve;

            if (s == null)
            {
                return(-1);
            }
            int res = 0;

            if (!string.IsNullOrEmpty(Mark))
            {
                res = TableService.alpha.Compare(Mark, s.Mark);
            }
            if (res != 0)
            {
                return(res);
            }
            res = diam.CompareTo(s.diam);
            if (res != 0)
            {
                return(res);
            }
            res = depth.CompareTo(s.depth);
            if (res != 0)
            {
                return(res);
            }
            res = length.CompareTo(s.length);
            if (res != 0)
            {
                return(res);
            }
            res = Role.CompareTo(s.Role);
            if (res != 0)
            {
                return(res);
            }
            res = AcadLib.Comparers.AlphanumComparator.New.Compare(Elevation, s.Elevation);
            return(res);
        }
Пример #24
0
        public override int CompareTo(ISpecElement other)
        {
            var b = other as Pylon;

            if (b == null)
            {
                return(-1);
            }
            var res = length.CompareTo(b.length);

            if (res != 0)
            {
                return(res);
            }
            res = width.CompareTo(b.width);
            if (res != 0)
            {
                return(res);
            }
            res = height.CompareTo(b.height);
            return(res);
        }
Пример #25
0
        public virtual bool Equals(ISpecElement other)
        {
            var arm = other as Bar;

            if (arm == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, arm))
            {
                return(true);
            }

            var res = Index == arm.Index &&
                      prefix == arm.prefix &&
                      Diameter == arm.Diameter &&
                      Length == arm.Length &&
                      Class == arm.Class &&
                      Gost.Equals(arm.Gost);

            return(res);
        }
Пример #26
0
 public void RunScenario(ISpecElement element, object context, string columnseperator, bool includeStoryGivens)
 {
     try
     {
         if (element.Type != ElementType.Scenario) return;
         if (includeStoryGivens)
         {
             foreach (var x in element.Parent.Children.Where(e => e.Type == ElementType.Given))
                 RunStep(x, context, columnseperator);
         }
         var els = new ElementType[] { ElementType.GivenIdid, ElementType.Given, ElementType.When, ElementType.Then };
         foreach (var x in element.Children.Where(e => els.Contains(e.Type)))
              RunStep(x, context, columnseperator);
         element.Status = true;
     }
     catch (Exception ex)
     {
         element.Status = null;
         while (ex.InnerException != null)
             ex = ex.InnerException;
         element.StatusInfo = ex.GetType().Name + ":" + ex.Message;
     }
 }
Пример #27
0
        public bool ParseLine(string vv)
        {
            if (vv == null) return true;
            var v = vv.Trim();
            if (v == "") return true;

            if (v.ToLower().StartsWith("columntoken "))
            {
                columntoken = v.Substring("columntoken ".Length).Trim();
                return true;
            }

            var q =
                TransformText(v, "story ", ElementType.Story) ??
                TransformText(v, "scenario ", ElementType.Scenario) ??
                TransformText(v, "given i did ", ElementType.GivenIdid) ??
                TransformText(v, "given ", ElementType.Given) ??
                TransformText(v, "when ", ElementType.When) ??
                TransformText(v, "then ", ElementType.Then) ??
                TransformText(v, "example", ElementType.Example) ??
                TransformText(v, "is about ",ElementType.Context) ??
                TransformText(v, columntoken, ElementType.Data);

            if (q == null && LastElement == null)
                return false;

            q = q ?? TransformText(v, "and ", LastElement.Type);

            if (q == null) return false;

            switch (q.Type)
            {
                case ElementType.Story:
                    StoryContainers.Add(new StoryContainer()
                    {
                        Story = q,
                        ColumnToken = columntoken
                    });

                    StoryChildren = new List<ISpecElement>();
                    ScenarioChildren = new List<ISpecElement>();
                    DataChildren = new List<ISpecElement>();
                    q.Children = StoryChildren;
                    LastElementContainer = q;
                    break;
                case ElementType.Scenario:
                    StoryChildren.Add(q);
                    ScenarioChildren = new List<ISpecElement>();
                    DataChildren = new List<ISpecElement>();
                    q.Children = ScenarioChildren;
                    LastElementContainer = q;
                    break;
                case ElementType.Given:
                    if (LastElementContainer.Type == ElementType.Story)
                        StoryChildren.Add(q);
                    else
                        ScenarioChildren.Add(q);
                    DataChildren = new List<ISpecElement>();
                    q.Children = DataChildren;
                    break;
                case ElementType.GivenIdid:
                    ScenarioChildren.Add(q);
                    DataChildren = new List<ISpecElement>();
                    q.Children = DataChildren;
                    break;
                case ElementType.Then:
                    ScenarioChildren.Add(q);
                    DataChildren = new List<ISpecElement>();
                    q.Children = DataChildren;
                    break;
                case ElementType.When:
                    ScenarioChildren.Add(q);
                    DataChildren = new List<ISpecElement>();
                    q.Children = DataChildren;
                    break;
                case ElementType.Example:
                    ScenarioChildren.Add(q);
                    DataChildren = new List<ISpecElement>();
                    q.Children = DataChildren;
                    break;
                case ElementType.Data:
                    q.Description = columntoken + q.Description;
                    DataChildren.Add(q);
                    break;
                case ElementType.Context:
                    StoryChildren.Add(q);
                    break;

            }
            if (q.Type != ElementType.Data)
                LastElement = q;
            return true;
        }
Пример #28
0
 public abstract int CompareTo(ISpecElement other);
Пример #29
0
 public abstract bool Equals(ISpecElement other);
Пример #30
0
 protected override void AddElement(ISpecElement elem)
 {
     throw new InvalidOperationException("Для конструкций нужно использовать AddElementary метод.");
 }
Пример #31
0
 public void TestMethod(ISpecElement e)
 {
     Assert.That(e.Status == true,e.Description+" Failed");
 }
Пример #32
0
 private Dictionary<string, List<string>> GetData(ISpecElement e, string columnseperator)
 {
     var l = new Dictionary<string, List<string>>();
     if (e == null) return l;
     var rows = e.Children.Where(o => o.Type == ElementType.Data).ToArray();
     if (rows.Count() < 2) return l;
     var names = rows[0].Description.ToLower().Split(columnseperator.ToCharArray()).Select(o => o.Trim()).ToArray();
     foreach (var r in rows.Skip(1))
     {
         var vals = r.Description.Split(columnseperator.ToCharArray()).Select(o => o.Trim()).ToArray();
         for (int i = 1; i < names.Count() - 1; i++)
         {
             if (!l.ContainsKey(names[i]))
                 l.Add(names[i], new List<string>());
             if (i >= vals.Length)
                 l[names[i]].Add("");
             else
                 l[names[i]].Add(vals[i]);
             r.Status = true;
         }
         rows[0].Status = true;
     }
     return l;
 }
Пример #33
0
        void RunStep(ISpecElement element, object context, string columnseparator)
        {
            try
            {
                if (element.Type == ElementType.GivenIdid)
                {
                    var scenario = element.Parent.Parent.Children
                        .Where(o => o.Type == ElementType.Scenario
                            && string.Compare(o.Description, element.Description, true) == 0)
                        .FirstOrDefault();
                    if (scenario == null)
                        throw new ArgumentException("Unknown scenario : " + element.Description);
                    RunScenario(scenario, context, columnseparator, false);
                    element.Status = scenario.Status;
                }
                else
                {

                    var res = _DslRunner.CallContextDSL(element.Description, context, element.Type.ToString(), () => GetData(element, columnseparator));
                    if (element.Type == ElementType.Then)
                        element.Status = (bool)res;
                    else
                        element.Status = true;
                }
            }
            catch (Exception ex)
            {
                element.Status = null;
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                element.StatusInfo = ex.GetType().Name + ":" + ex.Message;
            }
        }
Пример #34
0
 static void PrettyPrint(ISpecElement v, int depth,string header,string fmt,string footer)
 {
     var whitespace = "".PadLeft(depth * 4);
     Console.WriteLine(whitespace+fmt.FormatWith(v).Replace("GivenIdid","Given I did"));
     if (!string.IsNullOrEmpty(header))
         Console.WriteLine(whitespace+header);
     foreach (var c in v.Children)
         PrettyPrint(c, depth+1,header,fmt,footer);
     if (!string.IsNullOrEmpty(footer))
         Console.WriteLine(whitespace + footer);
     if (v.Children.Count() > 0)
         Console.WriteLine("");
 }