コード例 #1
0
        public void UT_Section_secPars()
        {
            var sec = new Sec("проф:Уголок 40х4 ст3");
            var ps = sec.secPars("Уголок * х *c*");
            Assert.AreEqual(ps[0].parStr(), "40");
            Assert.AreEqual(ps[1].parStr(), "4");
            Assert.AreEqual(ps[2].parStr(), "т3");

            // случай 1) const , напр. templ=материал С235
            sec = new Sec("");  //то есть в прайс-листе этой колонки нет
            ps = sec.secPars("M:C235");
            Assert.AreEqual(ps.Count, 0);

            // случай 2)  *    , напр. templ="Уголок *х*" comp= "Уголок 40x8"
            sec = new Sec("Уголок 40х4");
            ps = sec.secPars("проф: опис: Уголок * х * ");
            Assert.AreEqual(ps.Count, 2);
            Assert.AreEqual(ps[0].parStr(), "40");
            Assert.AreEqual(ps[1].parStr(), "4");

            // случай 3) {4}   , напр. templ="{4}"        comp= "Уголок 40x8" в кол 4
            sec = new Sec("Уголок 40x8");
            ps = sec.secPars("{4}");
            Assert.AreEqual(ps.Count, 0);
            Assert.AreEqual(sec.body, "угoлoк40x8");

            // случай 4) ссылка, напр. templ="проф:опис: Уголок *х*с*" 
            //                                          comp= "Уголок 40х8" ps 40 и 8
            sec = new Sec("Уголок 40х8");
            ps = sec.secPars("проф: опис: Уголок * х * ");
            Assert.AreEqual(ps.Count, 2);
            Assert.AreEqual(ps[0].parStr(), "40");
            Assert.AreEqual(ps[1].parStr(), "8");
        }
コード例 #2
0
        public Component(Dictionary <SType, string> comp
                         , Dictionary <SType, FP> cs_fps)
        {
            bool flag = false;

            foreach (var fpD in cs_fps)
            {
                FP     csFP   = fpD.Value;
                FP     compFP = new FP();
                string str    = comp[fpD.Key];
                Sec    s      = new Sec(str);
                string ld     = csFP.parN();
                if (ld.Contains('*'))       // * template
                {
                    compFP.pars = s.secPars(ld);
//30/3                    s.txs =
                    break;
                }
                if (ld.Contains('{'))       // {2} Col() Parameter
                {
                    compFP.pars.Add(new Parameter.Parameter(ld));
                    break;
                }
                fps.Add(fpD.Key, compFP);
            }
        }
コード例 #3
0
        /// <summary>
        /// FingerPrint(str, FP csFP, ref flag) -- FP constructor- specially for Component
        /// </summary>
        /// <param name="str">string to be parsed with CompSet FPs</param>
        /// <param name="_section">section of str the FP belongs to</param>
        /// <param name="csFPs">FP  from CompSet</param>
        /// <note>
        /// - parse str with csFP to put price-list parameters in this FP
        /// - quantity of tx in txs is always pars.Count (may be +1)
        /// - 
        /// </note>
            //////////////////public FingerPrint(string str, List<FingerPrint> csFPs, ref bool flag)
            //////////////////{
            //////////////////    typeFP = type.Component;
            //////////////////    flag = false;
            //////////////////    str = Lib.ToLat(str).ToLower();
            //////////////////    section = (Section)RecognyseSection(str);
            //////////////////    FingerPrint csFP = csFPs.Find(x => x.section == section);
            //////////////////    if (csFP == null) Msg.F("No Section \"" + section + " in csFPs");
            //////////////////    int ind = str.IndexOf(':') + 1;
            //////////////////    foreach (var tx in csFP.txs)
            //////////////////    {
            //////////////////        int lng = Math.Min(str.Length, tx.Length);
            /// 28/2/2017 ////        while (string.IsNullOrWhiteSpace(str[ind].ToString())) ind++;
            //////////////////        string s_str = str.Substring(ind, lng);
            //////////////////        string s_tx  = tx.Substring(0, lng);
            //////////////////        if (!isMatchStr(s_str, s_tx)) return;   //по несоответствию tx надо разбираться с синонимами - потом
            //////////////////        flag = true;
            //////////////////        txs.Add(s_tx);
            //////////////////        ind += tx.Length;
            //////////////////        bool isBrackets;
            //////////////////        string par = getPar(str, ref ind, out isBrackets);
            //////////////////        pars.Add(par);
            //////////////////        // 27/02 //                if (isBrackets) pars.Add(par); else txs.Add(par);
            //////////////////    }
            //////////////////}

        public FingerPrint(string str, FingerPrint csFP, out bool flag)
        { 
            flag = false;
            typeFP = type.Component;
            if (string.IsNullOrEmpty(str) || csFP == null) return;
            flag = true;
            section = csFP.section;
            if(str.Contains("*"))
            {
                pars = section.secPars(str);
            }
            Par par = new Par(str);
            pars.Add(par);
        }