Inheritance: Behavior
Beispiel #1
0
        } //the super-super class Pile already provides Clone but its result cannot be casted to (DbField) in c#

        public static DbField fromDef(Reach def, Db source, string table)
        {
            DbField ret = new DbField();

            ret.def   = def.before(1, ":").Trim() + " : " + def.after(1, ":").Trim();
            def       = def.after(1, ":").Trim();
            ret.optor = "   ";
            while (def.len > 0)
            {
                Reach fName     = def.before(1, " ").Trim();
                bool  isNumeric = false;
                for (int i = 1; i <= source.Tables[table].Fields.Len; i++)
                {
                    if (source.Tables[table].Fields[i].sql().equals(fName))
                    {
                        isNumeric = ",LONG,INT,INTEGER,DECIMAL,INT4,INT8,BIGINT,REAL,FLOAT8,DOUBLE PRECISION,FLOAT,BIT,".IndexOf("," + source.Tables[table].Fields[i].DataType.ToUpper() + ",") > -1;
                    }
                }
                if (isNumeric)
                {
                    ret.Push(new DbField(fName).cvs());
                }
                else
                {
                    ret.Push(new DbField(fName).ltm().rtm());
                }
                def = def.after(1, " ").Trim();
            }
            return(ret);
        }
Beispiel #2
0
        public DbSlc(Reach smb)
        {
            Db db = new Db(new ctx().DbDrivers);

            init();
            DbSlc ret = new DbGrid(smb.before(-1, ".SL")).SLC;

            smb = smb.after(-1, ".SL");
            if (smb.startsWith("D"))
            {
                ret = ret.DST;
            }
            smb = smb.from(3);
            while (smb.len > 0)
            {
                if (smb.startsWith("DST"))
                {
                    ret = ret.DST; smb = smb.from(5); continue;
                }
                if (smb.startsWith("TOP("))
                {
                    ret = ret.TOP(long.Parse(smb.from(5).before(1, ")").text)); smb = smb.after(1, ")").from(2); continue;
                }
                if (smb.startsWith("ORD("))
                {
                    ret = ret.ORD(smb.from(5).before(1, ")").after(1, "\"").before(1, "\"").text); smb = smb.after(1, ")").from(2); continue;
                }
            }
            this.count  = ret.count;
            this.fields = ret.fields.Clone(); //new Pile<string>(ret.fieldNames);
            this.from   = new KeyPile <string, string>(ret.from);
            this.join   = ret.join.Clone();   //new Pile<Cnd>(ret.join);
            this.where  = ret.where.Clone();  //new Pile<Cnd>(ret.where);
            this.order  = ret.order;
        }
Beispiel #3
0
    Vector2 addReachPosition(Reach reach)
    {
        Vector2 pos;

        switch (reach.reachDir)
        {
            case ReachDir.NORTH:
                pos = reach.reachPos + new Vector2(0, 1);
                break;
            case ReachDir.SOUTH:
                pos = reach.reachPos + new Vector2(0, -1);
                break;
            case ReachDir.EAST:
                pos = reach.reachPos + new Vector2(1, 0);
                break;
            case ReachDir.WEST:
                pos = reach.reachPos + new Vector2(-1, 0);
                break;
            default:
                pos = new Vector2(0, 0);
                break;
        }

        return pos;

    }
Beispiel #4
0
    public List<Vector2> addReach()//right now all cities get reach regardless. Not good tho
    {
        currentReachCount = reach.Count;
        /*
         * The problem is somewhere here, because you are adding reach to every single instance of reach instead of just those on the outside
         * You need to store all the last spawned reach (and eventually find a way to go back through it when it gets destroyed) and use that
         * as the basis point for calculating new reach
         * 
         * */
        List<Vector2> newReach = new List<Vector2>();
        for (int i = 0; i < currentReachCount; i++)
        {
            Vector2 newReachPos = addReachPosition(reach[i]);
            reachStr = new Reach(reach[i].reachDir, newReachPos);
            reach.Add(reachStr);
            newReach.Add(reachStr.reachPos);
        }
        foreach (var thing in newReach)
        {
            Debug.Log(thing);
        }

        return newReach;

    }
Beispiel #5
0
        private Reach extract(Reach source, bool includeTokens)
        {
            Reach ret = source.upto(0) + source.from(source.len + 1); // FromLeftToRight strategy Reach ret = source.from(source.len + 1)

            for (long i = 1; i <= def.Length; i++)
            {
                long k = 1;
                while ((k <= rpt[i - 1]) || ((rpt[i - 1] == 0) && (source.len > 0)))
                {
                    Reach leadIn = source.at(1, utl.dmyBool("al(occur, token) is planned"), def[i - 1].Name);
                    if ((leadIn.len == 0) && (def[i - 1].Name.Length > 0))
                    {
                        return(ret);
                    }
                    if (includeTokens)
                    {
                        if (ret.len == 0)
                        {
                            ret = leadIn;
                        }
                        else
                        {
                            ret = ret + leadIn;
                        }
                    }
                    Reach res     = source.after(leadIn);
                    Reach leadOut = null;
                    int   occur   = 0; // first we try the first closing bracelet, only in case that this will be a non-matching bracelet then wee will try the second, third, fourth etc. closing closing bracelet
                    do
                    {
                        occur++; for (int j = (def[i - 1]).Len; j > 0; j--)
                        {
                            Reach token = res.at(occur, utl.dmyBool("al(occur, token) is planned"), (def[i - 1])[j]); if (token.len > 0)
                            {
                                leadOut = token;
                            }
                        }
                    } while (nested[i - 1] && (res.upto(leadOut).at(-occur, utl.dmyBool("al(occur, token) is planned"), leadIn.text).len > 0));
                    if (leadOut != null)
                    {
                        res = res.before(leadOut);
                    }
                    if (leadOut == null)
                    {
                        return((ret.len == 0) ? res : ret + res);
                    }
                    if (ret.len == 0)
                    {
                        ret = includeTokens ? source.after(leadIn).upto(leadOut) : source.after(leadIn).before(leadOut);
                    }
                    else
                    {
                        ret = includeTokens ? ret + source.after(leadIn).upto(leadOut) : ret + source.after(leadIn).before(leadOut);
                    }
                    source = source.after(leadOut);
                    k++;
                }
            }
            return(ret);
        }
Beispiel #6
0
        internal DbUpd(Reach smb)
        {
            //TBD
            Db db = new Db(new ctx().DbDrivers);

            smb = smb;
        }
Beispiel #7
0
 public DbField apd(Reach rOpnd)
 {
     if (optor.Length > 0)
     {
         return(new DbField(this).apd(rOpnd));
     }
     this.Push(rOpnd);                                        optor = utl.OPR("APD"); return(this);
 }
Beispiel #8
0
 public virtual Trm cct(Reach rOpnd)
 {
     if (optor.Length > 0)
     {
         return(new Trm(this).cct(rOpnd));
     }
     this.Push(rOpnd);                                       optor = utl.OPR("CCT"); return(this);
 }
Beispiel #9
0
 public Tag(Reach source, bool xml)
 {
     if (ic++ == 0)
     {
         selfTest();
     }
     init(source, null, xml);
 }
Beispiel #10
0
 public DbField cct(Reach rOpnd)
 {
     if (optor.Length > 0)
     {
         return(new DbField(this).cct(rOpnd));
     }
     this.Push(rOpnd);                                        optor = utl.OPR("CCT"); return(this);
 }
Beispiel #11
0
 public virtual Trm apd(Reach rOpnd)
 {
     if (optor.Length > 0)
     {
         return(new Trm(this).apd(rOpnd));
     }
     this.Push(rOpnd);                                       optor = utl.OPR("APD"); return(this);
 }
Beispiel #12
0
 public Fmla(string text)
 {
     while (text.IndexOf(" (") > 0)
     {
         text = text.Replace(" (", "(");
     }
     this.text = text.Trim();
     parts.Push(text);
     splitparts();
 }
Beispiel #13
0
        public string GetParser(string name, long type)
        {
            switch (type) // 0:xml 1:c# 2:java
            {
            case 0: return(Reach.Load(xmlDefPath + "/parsers/" + name + ".xml").text);

            case 1: return(SourceCode(name, type));

            case 2: return(SourceCode(name, type));
            }
            return("");
        }
Beispiel #14
0
        internal DbIns(Reach smb)
        {
            init();
            //TBD
            Db    db        = new Db(new ctx().DbDrivers);
            DbIns ret       = null;
            Zone  bktFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "(", ")", "||:0"));
            Zone  strFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "\"", "\"", "||:1"));

            /*
             * string insstr = "Grid(\"prdrln\").sC(\"sbj, obj, vb, rul, steps, excerpt, trust\").INS(XXXX)";
             * insstr = insstr.Replace("XXXX", "Grid(\"prdrln p1, prdvrb pv1, prdrln p2, prdvrb pv2, kndrln sc, itmrln si, prdvrb pv, prdrul pr, itmrln oi, kndrln oc\", cd(\"p1.obj\").EQ(\"p2.sbj\")).sC(\"si.id, oi.id, pv.id, pr.id, 0, '', 0.5\").sR(XXXX).SLD");
             * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX");
             * insstr = bktFilter.on(insstr).text;
             * insstr = insstr.Replace("XXXX", "cd(\"0\").EQ(Grid(\"prdrln prdrln\").sC(\"count(*)\").sR(cd(\"sbj\").EQ(\"si.id\"), cd(\"obj\").EQ(\"oi.id\"), cd(\"vb\").EQ(\"pr.vb\")).SLC ), XXXX");
             */

            Reach gridDef = smb - bktFilter.on(smb);
            Reach ins     = gridDef.at(".INS(");

            if (ins.len == 0)
            {
                throw new Exception("DbIns Constructor: invalid symbolic Definition");
            }
            DbGrid res = db.Grid(smb.before(ins));

            smb = smb.after(ins).before(-1, ")");
            if (smb.startsWith("Grid("))
            {
                ret = res.INS(new DbSlc(smb));
            }
            else
            {
                Pile <string> val = new Pile <string>();
                while (smb.len > 0)
                {
                    if (smb.startsWith("ds("))
                    {
                        val.Push(db.ds(smb.after(1, "\"").before(1, "\""))); smb = smb.after(1, "),").Trim();
                    }
                    else
                    {
                        val.Push(smb.before(1, ",").Trim()); smb = smb.after(1, ",").Trim();
                    }
                }
                ret = res.INS(val.array());
            }
            into   = ret.into;
            fields = ret.fields.Clone(); //new Pile<string>(ret.fieldNames);
            values = ret.values;
            slc    = ret.slc;
        }
Beispiel #15
0
    public List <Tile> GetAttackTiles(Unit unit)
    {
        List <Tile> retVal = Reach.GetTiles(unit.Tile);

        for (int i = retVal.Count - 1; i >= 0; i--)
        {
            if (!Filter.ValidateTarget(retVal[i], unit))
            {
                retVal.RemoveAt(i);
            }
        }
        return(retVal);
    }
        public ControladorDifuso()
        {
            //Variables Linguisticas
            // Edad
            var vyoung = Age.MembershipFunctions.AddTriangle("muy joven", 15, 15, 18);
            var young  = Age.MembershipFunctions.AddTriangle("joven", 15, 18, 30);
            var adult  = Age.MembershipFunctions.AddTriangle("adulto", 18, 30, 50);
            var mature = Age.MembershipFunctions.AddTriangle("mayor", 30, 50, 100);
            // Presupuesto
            var low    = Budget.MembershipFunctions.AddTriangle("bajo", 1000, 1000, 10000);
            var medium = Budget.MembershipFunctions.AddTriangle("medio", 7000, 10000, 35000);
            var high   = Budget.MembershipFunctions.AddTriangle("alto", 28000, 35000, 70000);
            var vhigh  = Budget.MembershipFunctions.AddTriangle("muy alto", 60000, 70000, 1000000);
            // Alcance
            var national      = Reach.MembershipFunctions.AddTriangle("nacional", 0, 50, 100);
            var latin         = Reach.MembershipFunctions.AddTriangle("latino", 50, 100, 150);
            var international = Reach.MembershipFunctions.AddTriangle("internacional", 100, 150, 200);


            //Reglas
            // Edad/Presupuesto = Alcance
            // Muy joven
            // Base de conocimiento
            Rules.Add(Rule.If(Age.Is(vyoung).And(Budget.Is(low))).Then(Reach.Is(national)));                    //rule1
            Rules.Add(Rule.If(Age.Is(vyoung).And(Budget.Is(medium))).Then(Reach.Is(national)));                 //rule2
            Rules.Add(Rule.If(Age.Is(vyoung).And(Budget.Is(high))).Then(Reach.Is(latin)));                      //rule3
            Rules.Add(Rule.If(Age.Is(vyoung).And(Budget.Is(vhigh))).Then(Reach.Is(international)));             //rule4
            // Joven
            Rules.Add(Rule.If(Age.Is(young).And(Budget.Is(low))).Then(Reach.Is(national)));                     //rule5
            Rules.Add(Rule.If(Age.Is(young).And(Budget.Is(medium))).Then(Reach.Is(latin)));                     //rule6
            Rules.Add(Rule.If(Age.Is(young).And(Budget.Is(high))).Then(Reach.Is(latin)));                       //rule7
            Rules.Add(Rule.If(Age.Is(young).And(Budget.Is(vhigh))).Then(Reach.Is(international)));              //rule8
            // Adulto
            Rules.Add(Rule.If(Age.Is(adult).And(Budget.Is(low))).Then(Reach.Is(national)));                     //rule9
            Rules.Add(Rule.If(Age.Is(adult).And(Budget.Is(medium))).Then(Reach.Is(latin)));                     //rule10
            Rules.Add(Rule.If(Age.Is(adult).And(Budget.Is(high))).Then(Reach.Is(international)));               //rule11
            Rules.Add(Rule.If(Age.Is(adult).And(Budget.Is(vhigh))).Then(Reach.Is(international)));              //rule12
            // Mayor
            Rules.Add(Rule.If(Age.Is(mature).And(Budget.Is(low))).Then(Reach.Is(national)));                    //rule13
            Rules.Add(Rule.If(Age.Is(mature).And(Budget.Is(medium))).Then(Reach.Is(latin)));                    //rule14
            Rules.Add(Rule.If(Age.Is(mature).And(Budget.Is(high))).Then(Reach.Is(international)));              //rule15
            Rules.Add(Rule.If(Age.Is(mature).And(Budget.Is(vhigh))).Then(Reach.Is(international)));             //rule16


            //Agrega las reglas al motor de fusificaación
            foreach (FuzzyRule rule in Rules)
            {
                FuzzyEngine.Rules.Add(rule);
            }
        }
Beispiel #17
0
        internal DbGrid(Reach smb)
        {
            init();
            Zone bktFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "(", ")", "||:1"));
            Zone strFilter = new Zone(new Pile <string>(), new Pile <string>("", true, "\"", "\"", "||:1"));

            if (smb.at(".OR").len > 0)
            {
                smb = smb;
            }

            //def = new Reach("Grid(\"cpt cpt\").sC(\"id\").sR(cd(\"idnm\").EQ(ds(\"TS\")).OR(cd(\"idnm\").EQ(ds(\"TO\"))).OR(cd(\"idnm\").EQ(ds(\"TO\")))).SLC");
            smb = new Reach(smb.text);

            Reach gridDef = bktFilter.on(smb);
            Reach tblDef  = strFilter.on(gridDef);

            addTables(tblDef);
            Reach jCnd = smb.after(tblDef).after(1, ", ");

            joinCnd.Add(DbCnd.fromSymbolicDef(jCnd));
            string testsql = this.SLC.sql();

            smb = smb.after(gridDef).from(3);
            while (smb.len > 0)
            {
                if (smb.startsWith("sR("))
                {
                    Reach selCnds = bktFilter.on(smb);
                    joinCnd = sR(DbCnd.fromSymbolicDef(selCnds)).joinCnd;
                    selCnd  = sR(DbCnd.fromSymbolicDef(selCnds)).selCnd;
                    smb     = smb.after(selCnds).from(3);
                }
                else
                if (smb.startsWith("sC("))
                {
                    Reach colDef = strFilter.on(bktFilter.on(smb));
                    fields = sC(colDef).fields;
                    smb    = smb.after(colDef).from(4);
                }
                else
                if (smb.startsWith("SL"))
                {
                    smb = smb.from(4);
                }
            }
            allFields = fields;
            //addTables(tables);
        }
Beispiel #18
0
    private void Awake()
    {
        reach       = GameObject.Find("reach");
        reachHandle = reach.GetComponent <Reach>();

        pose  = GetComponent <SteamVR_Behaviour_Pose>();
        joint = GetComponent <FixedJoint>();

        pointerSphere = GameObject.Find("PR_Sphere");
        joystick      = GameObject.Find("JoyStick");
        throttle      = GameObject.Find("Throttle");
        player        = GameObject.Find("Player");
        ship          = GameObject.Find("ship");

        pointer = transform.Find("LeftRenderModel(Clone)/vr_glove_left(Clone)/vr_glove_model/Root/wrist_r/finger_inex_meta_r/finger_index_0_r/finger_index_1_r/");
    }
Beispiel #19
0
 public bool matches(Tag t)
 {
     for (int i = 1; i <= symbs.Len; i++)
     {
         Reach  value = t.val(symbs[i]);
         string comp  = comps[i];
         string ptn   = patts[i];
         bool   neg   = comp.StartsWith("!");
         if (neg)
         {
             comp = comp.Substring(1);
         }
         if (comp.Equals("=="))
         {
             if (neg ^ value.equals(ptn))
             {
                 return(true);
             }
         }
         else if (comp.Equals("°="))
         {
             if (neg ^ value.Equals(ptn))
             {
                 return(true);
             }
         }
         else if (comp.Equals("~~"))
         {
             if (neg ^ new Regex(ptn).IsMatch(value.text))
             {
                 return(true);
             }
         }
         else if (comp.Equals("°~"))
         {
             if (neg ^ new Regex(ptn.ToUpper()).IsMatch(value.uText))
             {
                 return(true);
             }
         }
         else
         {
             throw new Exception("Invalid Compare Operator for Tag Filter! Use one of these: == °= ~~ °~ !== !°= !~~ !°~");
         }
     }
     return(false);
 }
Beispiel #20
0
        public Reach fromClause(Db db)
        {
            Reach ret = "";

            foreach (string t in From.Keys)
            {
                ret += db.dbTable(From[t]) + " " + t.Replace(".", "") + ", ";
            }
            if (ret.EndsWith(" \r\n FROM "))
            {
                ret = ret.before(-9);
            }
            else
            {
                ret = ret.before(-2);
            }
            return(ret);
        }
Beispiel #21
0
 private void txtDtv_TextChanged(object sender, EventArgs e)
 {
     if (programGeneratedEvent > 0)
     {
         return;
     }
     programGeneratedEvent++;
     try
     {
         Reach dtv = txtDtv.Text;
         txtOptor.Text = dtv.before(1, " = ");
         writeToTable(txtOptor.Text, dtv.after(1, " = "));
         trm = new Trm(txtOptor.Text, txtOpnd1.Text, txtOpnd2.Text, txtOpnd3.Text, txtOpnd4.Text); //trm = new Trm(":dbg:" + txtOptor.Text, txtOpnd1.Text, txtOpnd2.Text, txtOpnd3.Text, txtOpnd4.Text);
         trm.Dtv.Set(txtOptor.Text, dtv.after(1, " = ").text);                                     //trm.Dtv.Set(":dbg:" + txtOptor.Text, dtv.after(1, " = ").text);
         try { txtVal4.Text = trm.val(); }
         catch { }
         txtOptr.Text          = trm.optr;
         txtDtv0.Text          = trm.dtv0;
         txtDtv1lR.Text        = trm.dtv1lR;
         txtDtv1mR.Text        = trm.dtv1mR;
         txtDtv1rR.Text        = trm.dtv1rR;
         txtDtv1lS.Text        = trm.dtv1lS;
         txtDtv1mS.Text        = trm.dtv1mS;
         txtDtv1rS.Text        = trm.dtv1rS;
         txtDtv2.Text          = trm.dtv2;
         chkRight2Left.Checked = !trm.left2right;
         chkRevert.Checked     = trm.revert;
         try
         {
             trm = new Trm(txtOptor.Text, txtOpnd1.Text, txtOpnd2.Text, txtOpnd3.Text);
             trm.Dtv.Set(txtOptor.Text, dtv.after(1, " = ").text); //trm.Dtv.Set(":dbg:" + txtOptor.Text, dtv.after(1, " = ").text);
             txtVal3.Text = trm.val();                             //txtVal3.Text = new Trm(":dbg:" + txtOptor.Text, txtOpnd1.Text, txtOpnd2.Text, txtOpnd3.Text).val();
             trm          = new Trm(txtOptor.Text, new object[] { txtOpnd1.Text, txtOpnd2.Text });
             trm.Dtv.Set(txtOptor.Text, dtv.after(1, " = ").text); //trm.Dtv.Set(":dbg:" + txtOptor.Text, dtv.after(1, " = ").text);
             txtVal2.Text = trm.val();                             //txtVal2.Text = new Trm(":dbg:" + txtOptor.Text, new object[] { txtOpnd1.Text, txtOpnd2.Text }).val();
             trm          = new Trm(txtOptor.Text, txtOpnd1.Text);
             trm.Dtv.Set(txtOptor.Text, dtv.after(1, " = ").text); //trm.Dtv.Set(":dbg:" + txtOptor.Text, dtv.after(1, " = ").text);
             txtVal1.Text = trm.val();                             //txtVal1.Text = new Trm(":dbg:" + txtOptor.Text, txtOpnd1.Text).val();
         }
         catch { }
     }
     finally { programGeneratedEvent--; }
 }
        public ControladorDifuso2()
        {
            //Variables Linguisticas
            // Proposito
            var familiar = Purpose.MembershipFunctions.AddTriangle("familiar", 0, 50, 100);
            var romantic = Purpose.MembershipFunctions.AddTriangle("romantico", 50, 100, 150);
            var friends  = Purpose.MembershipFunctions.AddTriangle("amigos", 100, 150, 200);
            // Subconjuntos
            var conjunto1 = Sublist.MembershipFunctions.AddTriangle("conjunto 1", 0, 50, 100);
            var conjunto2 = Sublist.MembershipFunctions.AddTriangle("conjunto 2", 50, 100, 150);
            var conjunto3 = Sublist.MembershipFunctions.AddTriangle("conjunto 3", 100, 150, 200);
            var conjunto4 = Sublist.MembershipFunctions.AddTriangle("conjunto 4", 150, 200, 250);
            var conjunto5 = Sublist.MembershipFunctions.AddTriangle("conjunto 5", 200, 250, 300);
            var conjunto6 = Sublist.MembershipFunctions.AddTriangle("conjunto 6", 250, 300, 350);
            var conjunto7 = Sublist.MembershipFunctions.AddTriangle("conjunto 7", 300, 350, 400);
            var conjunto8 = Sublist.MembershipFunctions.AddTriangle("conjunto 8", 350, 400, 450);
            var conjunto9 = Sublist.MembershipFunctions.AddTriangle("conjunto 9", 400, 450, 500);
            // Alcance
            var national      = Reach.MembershipFunctions.AddTriangle("nacional", 0, 50, 100);
            var latin         = Reach.MembershipFunctions.AddTriangle("latino", 50, 100, 150);
            var international = Reach.MembershipFunctions.AddTriangle("internacional", 100, 150, 200);

            //Reglas
            //Proposito/Alcance = Subconjuntos
            // Reglas que proporcionan la inferencia para los resultados
            Rules.Add(Rule.If(Purpose.Is(familiar).And(Reach.Is(national))).Then(Sublist.Is(conjunto1)));       //rule17
            Rules.Add(Rule.If(Purpose.Is(familiar).And(Reach.Is(latin))).Then(Sublist.Is(conjunto2)));          //rule18
            Rules.Add(Rule.If(Purpose.Is(familiar).And(Reach.Is(international))).Then(Sublist.Is(conjunto3)));  //rule19
            Rules.Add(Rule.If(Purpose.Is(romantic).And(Reach.Is(national))).Then(Sublist.Is(conjunto4)));       //rule20
            Rules.Add(Rule.If(Purpose.Is(romantic).And(Reach.Is(latin))).Then(Sublist.Is(conjunto5)));          //rule21
            Rules.Add(Rule.If(Purpose.Is(romantic).And(Reach.Is(international))).Then(Sublist.Is(conjunto6)));  //rule22
            Rules.Add(Rule.If(Purpose.Is(friends).And(Reach.Is(national))).Then(Sublist.Is(conjunto7)));        //rule23
            Rules.Add(Rule.If(Purpose.Is(friends).And(Reach.Is(latin))).Then(Sublist.Is(conjunto8)));           //rule24
            Rules.Add(Rule.If(Purpose.Is(friends).And(Reach.Is(international))).Then(Sublist.Is(conjunto9)));   //rule25

            //Adding the rules to the Fuzzy Engine
            foreach (FuzzyRule rule in Rules)
            {
                FuzzyEngine.Rules.Add(rule);
            }
        }
Beispiel #23
0
        /// <summary> sC ("select Columns") is the fields selector clause. (like in SQL Statements)</summary>
        public DbGrid sC(string allfields)
        {
            DbGrid ret = new DbGrid(this);

            ret.allFields = ret.fields.Clone(); //new Pile<string> (ret.fieldNames);
            Reach fields = new Reach(allfields + ",");

            if (!fields.Trim().equals("*,"))
            {
                ret.fields = new Pile <DbField>();
                Reach tokenMap = fields - bltZone.upon(fields - chrZone.upon(fields)); //AttGeTr: upon is too expensive!
                while (fields.Trim().len > 0)
                {
                    Reach token = tokenMap.at(1, ",");
                    ret.fields.Add(new DbField(fields.before(token).Trim().text)); //AttGeTr: no type information is added for each field !!! / ToBeSolved !!!
                    fields   = fields.after(token);
                    tokenMap = tokenMap.after(token);
                }
            }
            return(ret);
        }
Beispiel #24
0
    public City()
    {
        cityPos = new Vector2(0, 0);
        reach = new List<Reach>();
        sentiment = Sentiment.Proud;

        Vector2[] startReach = new Vector2[]
        {
            cityPos + new Vector2 (0,1),
            cityPos + new Vector2(0, -1),
            cityPos + new Vector2(1, 0),
            cityPos + new Vector2(-1, 0),
        };


        for (int i = 0; i < startReach.Length; i++)
        {
            reachStr = new Reach((ReachDir)i, startReach[i]);
            reach.Add(reachStr);

        }
    }
Beispiel #25
0
    public City(Vector2 _cityPos, int initialReach, Sentiment _sentiment)
    {
        cityPos = _cityPos;
        reach = new List<Reach>();
        sentiment = _sentiment;

        Vector2[] startReach = new Vector2[]
       {
            cityPos + new Vector2 (0,initialReach),
            cityPos + new Vector2(0, -initialReach),
            cityPos + new Vector2(initialReach, 0),
            cityPos + new Vector2(-initialReach, 0),
       };


        for (int i = 0; i < startReach.Length; i++)
        {
            reachStr = new Reach((ReachDir)i, startReach[i]);
            reach.Add(reachStr);

        }

    }
Beispiel #26
0
        private static void selfTest()
        {
            if ((quotations == null) || (charrays == null) || (bracelets == null) || (brackets == null) || (curlybracks == null) || (quotation == null) || (charray == null) || (bracelet == null) || (bracket == null) || (curlybrack == null))
            {
                return;
            }
            selfTested = true;

            Reach r0 = new Reach("' ', sbj.id, 'ape:', 'birth', ' ', LEFT(CONVERT(VARCHAR(23), sbj.birth, 121), 4) + '-' + LEFT(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 18), 2) + '-' + LEFT(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 15), 2) + ' ' + LEFT(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 12), 2) + ':' + LEFT(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 9), 2) + ':' + LEFT(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 6), 2) + '.' + RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 3)");
            Reach r1 = new Reach("a('b')c");
            Reach r2 = new Reach("a('b')c('d')e");
            Reach r3 = new Reach("('field') + ('2')");

            ass(charrays.upon(r1).equals("'b'"));
            ass(bracelets.upon(r1).equals("('b')"));
            ass(charrays.upon(r2).equals("'b''d'"));
            ass(bracelets.upon(r2).equals("('b')('d')"));
            ass(charrays.upon(r0).equals("' ''ape:''birth'' ''-''-'' '':'':''.'"));
            ass(bracelets.upon(r0).equals("(CONVERT(VARCHAR(23), sbj.birth, 121), 4)(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 18), 2)(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 15), 2)(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 12), 2)(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 9), 2)(RIGHT(CONVERT(VARCHAR(23), sbj.birth, 121), 6), 2)(CONVERT(VARCHAR(23), sbj.birth, 121), 3)"));
            ass(charray.upon(r3).equals("'field'"));
            ass(charray.on(r3).equals("field"));
            ass(bracelet.upon(r3).equals("('field')"));
            ass(bracelet.on(r3).equals("'field'"));
        }
Beispiel #27
0
        private string prepare(string name, string param, KeyPile <string, Tag> paramSet, Pile <Tag> rsDefSet, KeyPile <string, Conditions> rsCondSet, KeyPile <string, Tag> responseSet, KeyPile <string, Tag> results, string debug)
        {
            Tag def         = new Tag(GetParser(name, 0), true);
            Tag requestDef  = def.tags(2, new Pile <string>("", true, "[type]==request"))[1];
            Tag parserDef   = def.tags(2, new Pile <string>("", true, "[type]==parser"))[1];
            Tag responseDef = def.tags(2, new Pile <string>("", true, "[type]==response"))[1];

            KeyPile <string, Tag> resultSetDefinitions = new KeyPile <string, Tag>();
            string url = parserDef.tags(2, Tag.where ("[type]==url"))[1].txt;

            foreach (Tag t in parserDef.tags(2, Tag.where ("[type]==resultset")))
            {
                resultSetDefinitions.Add(t.attr["name"].Value.text, t);
            }

            foreach (string key in resultSetDefinitions.Keys)
            {
                rsDefSet.Add(resultSetDefinitions[key]);
            }

            foreach (Tag t in responseDef.tags(2, Tag.where ("[type]==param")))
            {
                responseSet.Add(t.attr["name"].Value.text, t);
            }
            KeyPile <long, Tag> paramList = new KeyPile <long, Tag>();

            foreach (Tag t in requestDef.tags(2, Tag.where ("[type]==param")))
            {
                paramList.Add(Int32.Parse(t.attr["key"].Value.text), t);
            }
            foreach (long key in paramList.kAsc)
            {
                paramSet.Add(paramList[key].txt.after(1, "[").before(1, "]").text, paramList[key]);
            }

            Pile <Tag> qParams = new Tag(param, true).tags(2, Tag.where ("[type]==param"));

            string[] qp = new string[qParams.Len];
            for (int i = 1; i <= qParams.Len; i++)
            {
                Tag t = qParams[i];
                qp[i - 1] = t.attr["name"].Value.text + "=" + t.attr["value"].Value.text;
            }

            foreach (string worddef in qp)
            {
                string word = worddef;
                string key  = utl.cutl(ref word, "=");
                long   pos  = 0;
                for (int i = 1; i <= paramSet.Len; i++)
                {
                    if (paramSet.Keys[i].Equals(key))
                    {
                        pos = i; break;
                    }
                }
                url = url.Replace("[" + pos + "]", paramSet[key].txt.text.Replace("[" + key + "]", word));
            }
            url = url.Replace("&amp;", "&");
            for (long i = 1; i <= paramSet.Len; i++)
            {
                url = url.Replace("[" + i + "]", "");
            }
            for (int rset = 1; rset <= rsDefSet.Len; rset++)
            {
                if (debug.Equals("base"))
                {
                    break;
                }
                Tag rsDef = rsDefSet[rset];
                Pile <Pile <string> > rsFilters = new Pile <Pile <string> >();
                foreach (Tag filterDef in rsDef.tags(2, Tag.where ("[type]==filter")))
                {
                    Pile <string> rsPatterns = new Pile <string>();
                    foreach (Tag patternDef in filterDef.tags(2, Tag.where ("[type]==pattern")))
                    {
                        bool   neg   = patternDef.attr["neg"].Value.Equals("1");
                        bool   csens = patternDef.attr["csens"].Value.Equals("1");
                        bool   rexp  = patternDef.attr["rexp"].Value.Equals("1");
                        string key   = patternDef.attr["key"].Value.text.Replace("&gt;", ">").Replace("&lt;", "<");
                        string val   = patternDef.txt;
                        string cmp   = "";
                        if (neg)
                        {
                            cmp = "!";
                        }
                        if (!csens)
                        {
                            cmp += "°";
                        }
                        if (rexp)
                        {
                            cmp += "~";
                        }
                        else
                        {
                            cmp += "=";
                        }
                        if (csens)
                        {
                            cmp += cmp.Substring(cmp.Length - 1);
                        }
                        rsPatterns.Add(key + cmp + val);
                    }
                    rsFilters.Add(rsPatterns);
                }
                rsCondSet.Add(rsDef.attr["base"].Value + "-" + rsDef.attr["name"].Value, new Conditions(rsDef.attr["base"].Value, rsDef.attr["name"].Value, rsDef.tags(2, Tag.where ("[type]==sequence"))[1].attr["include"].Value.text.Trim(), rsFilters));
                if (debug.Equals(rsDef.attr["name"].Value))
                {
                    break;
                }
                //rsCondSet.Add(rsDef.attr["base"].Item, new Conditions(rsDef.attr["base"].Item, rsDef.attr["name"].Item, rsDef.tags(2, Tag.where("[type]==sequence"))[1].attr["include"].Item.text.Trim(), rsFilters));
            }
            //long Pos1 = ((string)Reach.Load("http://www.livejasmin.com/listpage.php?page=22&livejasmin_session=4678d6bb9242e4bef687d240c293b873&tags=girl&type=40&orderby=0")).IndexOf("allonline_perfnametext");
            Tag doc = new Tag(Reach.Load(url), false);

            //long Pos2 = doc.struc(-1).IndexOf("allonline_perfnametext");
            //for (long i = 1; i <= doc.Tags.Len(); i++) doc.Tags[i].Name = "base:" + i;
            results.Add("base", doc);
            return(url);
        }
Beispiel #28
0
 public void   ClearSourcePathTrimRules( Reach reach= Reach.Global, bool allowAutoRule= true )
 {
     #if ALOX_DBG_LOG || ALOX_REL_LOG
     try { Acquire();
         scopeInfo.SetSourcePathTrimRule( null, allowAutoRule ? Inclusion.Include
                                                              : Inclusion.Exclude,
                                          999999, // code for clearing
                                          Case.Ignore, null,  reach, -1  );
     } finally { Release(); }
     #endif
 }
Beispiel #29
0
 public static  void  ClearSourcePathTrimRules( Reach reach= Reach.Global, bool allowAutoRule= true )
 {
     #if ALOX_DBG_LOG
         LOX.ClearSourcePathTrimRules( reach, allowAutoRule );
     #endif
 }
Beispiel #30
0
 public static void      SetSourcePathTrimRule( String       path,
                                                Inclusion    includeString   = Inclusion.Exclude,
                                                int          trimOffset      = 0,
                                                Case         sensitivity     = Case.Ignore,
                                                Reach        reach           = Reach.Global,
                                                String       trimReplacement = null ,
                                                int          priority        = Configuration.PrioDefault    )
 {
     #if ALOX_DBG_LOG
         LOX.SetSourcePathTrimRule( path, includeString, trimOffset, sensitivity,
                                    trimReplacement, reach, priority );
     #endif
 }
        /** ****************************************************************************************
         * Does the job for
         * \ref cs::aworx::lox::Lox::SetSourcePathTrimRule    "Lox.SetSourcePathTrimRule" and
         * \ref cs::aworx::lox::Lox::ClearSourcePathTrimRules "Lox.ClearSourcePathTrimRules".
         *
         * @param path            The path to search for. If not starting with <c> '*'</c>,
         *                        a prefix is searched.
         * @param includeString   Determines if \p path should be included in the trimmed path
         *                        or not.
         * @param trimOffset      Adjusts the portion of \p path that is trimmed. 999999 to clear!
         * @param sensitivity     Determines if the comparison of \p path with a source files' path
         *                        is performed case sensitive or not.
         * @param trimReplacement Replacement string for trimmed portion of the path.
         * @param reach           Denotes whether the rule is applied locally (to this \b %Lox only)
         *                        or applies to all instances of class \b %Lox.
         * @param priority        The priority of the setting.
         ******************************************************************************************/
        public void   SetSourcePathTrimRule( String     path,
                                             Inclusion  includeString,
                                             int        trimOffset,
                                             Case       sensitivity,
                                             String     trimReplacement,
                                             Reach      reach,
                                             int        priority            )
        {
            // unset current origFile to have lazy variables reset with the next invocation
            for ( int i= 0; i< cacheSize; i++ )
                cache[i].origFile= null;

            // clear command
            if ( trimOffset == 999999 )
            {
                LocalSPTRs.Clear();
                if ( reach == Reach.Global )
                    GlobalSPTRs.Clear();
                AutoDetectTrimableSourcePath=  (includeString == Inclusion.Include);

                // reset config read flag. This is done for unit testing. Not really
                // useful/needed in real life.
                GlobalSPTRsReadFromConfig= false;
                return;
            }

            // choosel local or global list
            List<SourcePathTrimRule> trimInfoList = reach == Reach.Global  ? GlobalSPTRs
                                                                           : LocalSPTRs;

            // add new entry
            SourcePathTrimRule rule= new SourcePathTrimRule();

            // if path starts with '*', it is not a prefix. We store without *
            rule.Path= new AString( (rule.IsPrefix= !path.StartsWith("*")) ? path : path.Substring( 1 ) );
            if ( rule.Path.CharAtEnd() == '*' )
                rule.Path.DeleteEnd( 1 );
            if ( rule.Path.IsEmpty() )
                return;

            if( Path.DirectorySeparatorChar == '/' )
                rule.Path.SearchAndReplaceAll( "\\", "/"  );
            else
                rule.Path.SearchAndReplaceAll( "/" , "\\" );

            rule.IncludeString=   includeString;
            rule.TrimOffset=      trimOffset;
            rule.Sensitivity=     sensitivity;
            rule.TrimReplacement= trimReplacement;

            // add rule ordered by priority
            rule.Priority= priority;
            int pos= 0;
            while( pos < trimInfoList.Count && priority < trimInfoList[pos].Priority )
                ++pos;

            trimInfoList.Insert( pos, rule );
        }
Beispiel #32
0
        public string Exec(string name, string param)
        {
            string ret = "";
            string debug = ""; Tag debugDef = null; try { debugDef = new Tag(param, true).tags(2, Tag.where ("[type]==debug"))[1]; } catch (Exception ex) { } if (debugDef != null)
            {
                debug = debugDef.attr["name"].Value;
            }

            KeyPile <string, Tag>        paramSet    = new KeyPile <string, Tag>();              //Dictionary<string, Tag> paramSet = new Dictionary<string, Tag>();
            Pile <Tag>                   rsDefSet    = new Pile <Tag>();
            KeyPile <string, Conditions> rsCondSet   = new KeyPile <string, Conditions>();
            KeyPile <string, Tag>        responseSet = new KeyPile <string, Tag>();              //Dictionary<string, Tag> responseSet = new Dictionary<string, Tag>();
            KeyPile <string, Tag>        results     = new KeyPile <string, Tag>();
            KeyPile <string, Pile <NamedValue <string, Tag> > > resSet = new KeyPile <string, Pile <NamedValue <string, Tag> > >();

            string url = prepare(name, param, paramSet, rsDefSet, rsCondSet, responseSet, results, debug);

            Pile <NamedValue <string, Tag> > baseSet = new Pile <NamedValue <string, Tag> >();

            foreach (Tag t in results[1].Tags)
            {
                baseSet.Add(new NamedValue <string, Tag>("base:" + (baseSet.Len + 1), t));
            }
            resSet.Add("base", baseSet);
            results[1].tags(-1, 1, rsCondSet, resSet);
            ret += "<tr>\n<td>" + (++execCounter) + "</td></tr>\n";
            foreach (NamedValue <string, Tag> nt in resSet[-1])
            {
                ret += "<tr>\n";
                if (debug.Length == 0)
                {
                    foreach (Tag rDef in responseSet)
                    {
                        Reach val;
                        Reach valDef = rDef.attr["value"].Value.text.Replace("&lt;", "<").Replace("&gt;", ">").ToLower();
                        Reach delim  = valDef.at(1, ".");
                        if ((delim.len > 0) && (!valDef.before(delim).Equals(resSet.Keys[-1])))
                        {
                            NamedValue <string, Tag> baseTag = nt;
                            while (true)
                            {
                                Reach baseName = (Reach)baseTag.Name; int num = Int32.Parse(baseName.after(1, ":")); baseTag = resSet[baseName.before(1, ":")][num]; if (baseName.before(1, ":").Equals(valDef.before(delim)))
                                {
                                    val = baseTag.Value.val(valDef.after(delim)); break;
                                }
                            }
                        }
                        else if (delim.len > 0)
                        {
                            val = nt.Value.val(valDef.after(delim));
                        }
                        else
                        {
                            val = nt.Value.val(valDef);
                        }
                        ret += " <td>" + val.text.Replace("\n", "").Replace("\r", "") + " </td>\n";
                    }
                    ret += "</tr>\n";
                }
                else
                {
                    ret += nt.Value.struc(-1) + "</tr>\n";
                }
            }
            return("<url>" + url + "</url>" + ret);
        }
Beispiel #33
0
 public Udf(string xmlFile)
 {
     xmlDefFile = xmlFile;
     xmlDefPath = Path.GetDirectoryName(xmlDefFile);
     xmlDef     = Reach.Load(xmlFile);
 }
Beispiel #34
0
    public void ReadRivers()
    {
        //clear previous data
        rivers.Clear();

        string gml = controller.Geometry_GetGML(controller.CurrentGeomFile());

        //Parse xml from gml
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(gml);

        IList<XmlNode> nlist = doc.GetElementsByTagName("River").Cast<XmlNode>().Where(n => n.ChildNodes.Count > 1).ToList();

        foreach (XmlNode n in nlist)
        {
            string riverId = n["River"].InnerText;
            string reachId = n["Reach"].InnerText;
            River r = null;

            if (rivers.ContainsKey(riverId))
            {
                r = rivers[riverId];
            }
            else
            {
                r = new River(riverId);
                rivers.Add(riverId, r);
            }

            if (!r.Reaches.ContainsKey(riverId))
            {
                List<XmlNode> crosssectionsOnReach = doc.GetElementsByTagName("XS").Cast<XmlNode>()
                    .Where(p => p["River"].InnerText == riverId && p["Reach"].InnerText == reachId).ToList();

                if (crosssectionsOnReach.Count > 0)
                {
                    Reach reach = new Reach(reachId);

                    List<Point> centerLinePoints = new List<Point>();

                    string centerLine = n["geometryProperty"]["gml:LineString"]["gml:coordinates"].InnerText;
                    string[] centerLineCoords = centerLine.Split(spaceDel, StringSplitOptions.RemoveEmptyEntries);

                    for (int j = 0; j < centerLineCoords.Length; j++)
                    {
                        string[] tCoords = centerLineCoords[j].Split(commaDel, StringSplitOptions.RemoveEmptyEntries);
                        centerLinePoints.Add(new Point(double.Parse(tCoords[0]), double.Parse(tCoords[1]), 0.0));
                    }

                    reach.CenterLine = centerLinePoints;

                    for (int i = 0; i < crosssectionsOnReach.Count; i++)
                    {
                        XmlNode xs = crosssectionsOnReach[i];

                        string cutLineCoordsText = xs["geometryProperty"]["gml:LineString"]["gml:coordinates"].InnerText;
                        string[] cutLineCoords = cutLineCoordsText.Split(spaceDel, StringSplitOptions.RemoveEmptyEntries);

                        XSection section = new XSection(xs["RiverStation"].InnerText);

                        for (int j = 0; j < cutLineCoords.Length; j++)
                        {
                            string[] tCoords = cutLineCoords[j].Split(commaDel, StringSplitOptions.RemoveEmptyEntries);
                            section.XSCutLine.Add(new Point(double.Parse(tCoords[0]), double.Parse(tCoords[1]), 0.0));
                        }
                        reach.XSections.Add(section.StationName.Trim(), section);
                    }

                    r.Reaches.Add(reachId, reach);
                }
            }
        }

        foreach (River r in rivers.Values)
        {
            foreach (Reach re in r.Reaches.Values)
            {
                re.CreateGISFeatures();
                re.CreateTriangulationForWaterSurface();
            }
        }
    }
Beispiel #35
0
        public string SourceCode(string name, long type)
        {
            Reach cSharp = new Reach("");

            cSharp = cSharp + new Reach("\n");
            cSharp = cSharp + new Reach("\n");
            cSharp = cSharp + new Reach("/**\n");
            cSharp = cSharp + new Reach(" *\n");
            cSharp = cSharp + new Reach(" * generated source code, do not change\n");
            cSharp = cSharp + new Reach(" */\n");
            cSharp = cSharp + new Reach("\n");
            cSharp = cSharp + new Reach("using System;\n");
            cSharp = cSharp + new Reach("using System.Collections.Generic;\n");
            cSharp = cSharp + new Reach("using System.Linq;\n");
            cSharp = cSharp + new Reach("using System.Text;\n");
            cSharp = cSharp + new Reach("\n");
            cSharp = cSharp + new Reach("using ndBase;\n");
            cSharp = cSharp + new Reach("using ndString;\n");
            cSharp = cSharp + new Reach("using ndData;\n");
            cSharp = cSharp + new Reach("using ndUdf;\n");
            cSharp = cSharp + new Reach("\n");
            cSharp = cSharp + new Reach("public class " + name + "Call\n");
            cSharp = cSharp + new Reach("{\n");
            cSharp = cSharp + new Reach(" private static string  parserName = \"" + name + "\";\n");
            cSharp = cSharp + new Reach(" private static bool    tested     = false;\n");
            cSharp = cSharp + new Reach(" private UdfDisp        Udf        = null;\n");
            cSharp = cSharp + new Reach("\n");

            Reach Java = new Reach("");

            Java = Java + new Reach("\n");
            Java = Java + new Reach("\n");
            Java = Java + new Reach("/**\n");
            Java = Java + new Reach(" *\n");
            Java = Java + new Reach(" * generated source code, do not change\n");
            Java = Java + new Reach(" */\n");
            Java = Java + new Reach("import org.getr.ndBase.Pile;\n");
            Java = Java + new Reach("import org.getr.ndString.Reach;\n");
            Java = Java + new Reach("import org.getr.ndData.Tag;\n");
            Java = Java + new Reach("\n");
            Java = Java + new Reach("public class " + name + "Call\n");
            Java = Java + new Reach("{\n");
            Java = Java + new Reach("\n");
            Java = Java + new Reach(" private static String  parserName = \"" + name + "\";\n");
            Java = Java + new Reach(" private static boolean tested     = false;\n");
            Java = Java + new Reach(" private UdfDisp        Udf        = null;\n");
            Java = Java + new Reach("\n");

            Tag def         = new Tag(GetParser(name, 0), true);
            Tag requestDef  = def.tags(2, new Pile <string>("", true, "[type]==request"))[1];
            Tag parserDef   = def.tags(2, new Pile <string>("", true, "[type]==parser"))[1];
            Tag responseDef = def.tags(2, new Pile <string>("", true, "[type]==response"))[1];

            KeyPile <string, Reach> rqParams = new KeyPile <string, Reach>();
            KeyPile <string, Reach> rpParams = new KeyPile <string, Reach>();

            long ctr = 0;

            while (true)
            {
                Pile <Tag> found = requestDef.tags(1, new Pile <string>("", true, "[type]==param"), new Pile <string>("", true, "key==" + (++ctr) + ""));
                if (found.Len == 0)
                {
                    break;
                }
                Tag    paramTag = found[1];
                string key      = paramTag.txt.after(1, "[").before(1, "]").text;
                string test     = "";
                if (paramTag.attr.hasKey("test"))
                {
                    test = paramTag.attr["test"].Value;
                }
                rqParams.Add(key, test);
            }

            foreach (Tag t in responseDef.tags(1, new Pile <string>("", true, "[type]==param")))
            {
                string key  = t.attr["name"].Value;
                string test = "";
                if (t.attr.hasKey("test"))
                {
                    test = t.attr["test"].Value;
                }
                rpParams.Add(key, test);
            }

            foreach (string paramName in rpParams.Keys)
            {
                cSharp = cSharp + new Reach(" private Reach m_" + Proper(paramName) + ";\n");
                Java   = Java + new Reach(" private Reach m_" + Proper(paramName) + ";\n");
            }
            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");

            foreach (string paramName in rpParams.Keys)
            {
                cSharp = cSharp + new Reach(" public Reach " + Proper(paramName) + "                   { get { return m_" + Proper(paramName) + ";                } }\n");
                Java   = Java + new Reach(" public Reach get" + Proper(paramName) + "                () { return m_" + Proper(paramName) + ";                }\n");
            }

            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");
            cSharp = cSharp + new Reach(" public " + name + "Call(UdfDisp Udf)\n");
            Java   = Java + new Reach(" public " + name + "Call(UdfDisp Udf) throws Exception\n");
            cSharp = cSharp + new Reach(" {\n");
            Java   = Java + new Reach(" {\n");
            cSharp = cSharp + new Reach("  this.Udf = Udf;\n");
            Java   = Java + new Reach("  this.Udf = Udf;\n");
            cSharp = cSharp + new Reach("  if (!tested)\n");
            Java   = Java + new Reach("  if (!tested)\n");
            cSharp = cSharp + new Reach("  {\n");
            Java   = Java + new Reach("  {\n");
            cSharp = cSharp + new Reach("   tested = true;\n");
            Java   = Java + new Reach("   tested = true;\n");

            string testParams = "";

            foreach (string paramName in rpParams.Keys)
            {
                testParams += rpParams[paramName].text;
            }
            if (testParams.Length == 0)
            {
                cSharp = cSharp + new Reach("  }\n");
                Java   = Java + new Reach("  }\n");
            }
            else
            {
                foreach (string paramName in rpParams.Keys)
                {
                    cSharp = cSharp + new Reach("   bool p_" + Proper(paramName) + " = false;\n");
                    Java   = Java + new Reach("   boolean p_" + Proper(paramName) + " = false;\n");
                }
                Reach execParams = new Reach("");
                foreach (Reach test in rqParams)
                {
                    execParams += new Reach("\"") + test + new Reach("\", ");
                }
                execParams = execParams.upto(-3);

                cSharp = cSharp + new Reach("   foreach (" + name + "Call res in exec( " + execParams.text + "))\n");
                Java   = Java + new Reach("   for (" + name + "Call res : exec( " + execParams.text + "))\n");
                cSharp = cSharp + new Reach("   {\n");
                Java   = Java + new Reach("   {\n");

                string passedCondition = "";
                foreach (string paramName in rpParams.Keys)
                {
                    string test = rpParams[paramName].text;
                    passedCondition += " && p_" + Proper(paramName);
                    cSharp           = cSharp + new Reach("    if (res." + Proper(paramName) + ".Equals(\"" + test + "\"))       p_" + Proper(paramName) + " = true;\n");
                    Java             = Java + new Reach("    if (res.get" + Proper(paramName) + "().Equals(\"" + test + "\"))  p_" + Proper(paramName) + " = true;\n");
                }
                passedCondition = "(!(" + passedCondition.Substring(4) + "))";
                cSharp          = cSharp + new Reach("   }\n");
                Java            = Java + new Reach("   }\n");
                cSharp          = cSharp + new Reach("   if " + passedCondition + " throw new Exception(\"" + name + "Call selfTest FAILED! Check test values in " + name + ".xml against the WebPage you get from the url! (has the html structure changed?)\");\n");
                Java            = Java + new Reach("   if " + passedCondition + " throw new Exception(\"" + name + "Call selfTest FAILED! Check test values in " + name + ".xml against the WebPage you get from the url! (has the html structure changed?)\");\n");
                cSharp          = cSharp + new Reach("  }\n");
                Java            = Java + new Reach("  }\n");
            }

            cSharp = cSharp + new Reach(" }\n");
            Java   = Java + new Reach(" }\n");
            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");

            Reach cSharpParams = new Reach("");
            Reach javaParams   = new Reach("");

            foreach (string key in rqParams.Keys)
            {
                cSharpParams += new Reach("string ") + key + new Reach(", "); javaParams += new Reach("String ") + key + new Reach(", ");
            }
            cSharpParams = cSharpParams.upto(-3);
            javaParams   = javaParams.upto(-3);

            cSharp = cSharp + new Reach(" public Pile<" + name + "Call> exec(" + cSharpParams + ")\n");
            Java   = Java + new Reach(" public Pile<" + name + "Call> exec(" + javaParams + ") throws Exception\n");
            cSharp = cSharp + new Reach(" {\n");
            Java   = Java + new Reach(" {\n");
            cSharp = cSharp + new Reach("  string callParams = \"\";\n");
            Java   = Java + new Reach("  String callParams = \"\";\n");

            foreach (string key in rqParams.Keys)
            {
                cSharp = cSharp + new Reach("  callParams += \"<param name=\\\"" + key + "\\\" value=\\\"\" + " + key + " + \"\\\"/>\";\n");
                Java   = Java + new Reach("  callParams += \"<param name=\\\"" + key + "\\\" value=\\\"\" + " + key + " + \"\\\"/>\";\n");
            }
            cSharp = cSharp + new Reach("  Tag result = new Tag(Udf.Exec(parserName, callParams), true);\n");
            Java   = Java + new Reach("  Tag result = new Tag(Udf.exec(parserName, callParams), true);\n");
            cSharp = cSharp + new Reach("  Pile<" + name + "Call> ret = new Pile<" + name + "Call>(0);\n");
            Java   = Java + new Reach("  Pile<" + name + "Call> ret = new Pile<" + name + "Call>(0);\n");
            cSharp = cSharp + new Reach("  ret.Name = result.struc(-1);\n");
            Java   = Java + new Reach("  ret.setName(result.struc(-1));\n");
            cSharp = cSharp + new Reach("  foreach (Tag tr in result.tags(1, new Pile<string>(\"\", \"[type]==tr\")))\n");
            Java   = Java + new Reach("  for (Tag tr : result.tags(1, new Pile<String>(\"\", \"[type]==tr\")))\n");
            cSharp = cSharp + new Reach("  {\n");
            Java   = Java + new Reach("  {\n");
            cSharp = cSharp + new Reach("   " + name + "Call res = new " + name + "Call(Udf);\n");
            Java   = Java + new Reach("   " + name + "Call res = new " + name + "Call(Udf);\n");
            long rpCtr = 0;

            foreach (string key in rpParams.Keys)
            {
                rpCtr++;
                cSharp = cSharp + new Reach("   res.m_" + Proper(key) + " = tr.Tags[" + rpCtr + "].txt;\n");
                Java   = Java + new Reach("   res.m_" + Proper(key) + " = tr.Tags().get(" + rpCtr + ").txt();\n");
            }
            cSharp = cSharp + new Reach("   ret.Add(res);\n");
            Java   = Java + new Reach("   ret.add(res);\n");
            cSharp = cSharp + new Reach("  }\n");
            Java   = Java + new Reach("  }\n");
            cSharp = cSharp + new Reach("  return ret;\n");
            Java   = Java + new Reach("  return ret;\n");
            cSharp = cSharp + new Reach(" }\n");
            Java   = Java + new Reach(" }\n");
            cSharp = cSharp + new Reach("}\n");
            Java   = Java + new Reach("}\n");
            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");
            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");
            cSharp = cSharp + new Reach("\n");
            Java   = Java + new Reach("\n");

            switch (type)
            {
            case 1: return(cSharp.text);

            case 2: return(Java.text);
            }
            return("");
        }
Beispiel #36
0
    public void      SetSourcePathTrimRule( String    path,
                                            Inclusion includeString     = Inclusion.Exclude,
                                            int       trimOffset        = 0,
                                            Case      sensitivity       = Case.Ignore,
                                            String    trimReplacement   = null,
                                            Reach     reach             = Reach.Global,
                                            int       priority          = Configuration.PrioDefault    )
    {
        #if ALOX_DBG_LOG || ALOX_REL_LOG
        try { Acquire();

            scopeInfo.SetSourcePathTrimRule( path, includeString, trimOffset, sensitivity,
                                             trimReplacement, reach, priority );

        } finally { Release(); }
        #endif
    }