Esempio n. 1
0
 public ConditionOwner(int ownerType, string ownerName, ConditionOwner parent) :
     base(CONDITION_OWNER)
 {
     this.ownerType = ownerType;
     this.ownerName = ownerName;
     this.parent    = parent;
 }
Esempio n. 2
0
        public static Dictionary <string, ConditionContextProperty> createContextFromOwner(int ownerType, string ownerName)
        {
            Dictionary <string, ConditionContextProperty> context1 = new Dictionary <string, ConditionContextProperty>();
            ConditionOwner owner = new ConditionOwner(ownerType, ownerName);

            context1.Add(ConditionsController.CONDITION_OWNER, owner);

            if (TC.containsConditionsContextText(ownerType, TC.NORMAL_SENTENCE) && TC.containsConditionsContextText(ownerType, TC.NO_CONDITION_SENTENCE))
            {
                ConditionCustomMessage cMessage = new ConditionCustomMessage(TC.getConditionsContextText(ownerType, TC.NORMAL_SENTENCE), TC.getConditionsContextText(ownerType, TC.NO_CONDITION_SENTENCE));
                context1.Add(CONDITION_CUSTOM_MESSAGE, cMessage);
            }

            return(context1);
        }
Esempio n. 3
0
            private string formatSentence(ConditionOwner owner, string sentence)
            {
                string formattedSentence = sentence;

                if (sentence.Contains(ELEMENT_TYPE))
                {
                    //formattedSentence = formattedSentence.replace(ELEMENT_TYPE,
                    //    "<i>" + Language.GetTextElement(owner.getOwnerType()) + "</i>");
                }
                if (sentence.Contains(ELEMENT_ID))
                {
                    formattedSentence = formattedSentence.Replace(ELEMENT_ID, "<b>\"" + owner.getOwnerName() + "\"</b>");
                }
                return(formattedSentence);
            }
Esempio n. 4
0
        /**
         * Sets the evaluation function at the given index
         *
         * @param index1
         *            Int value in rage
         * @param index2
         *            Int value in rage or {@link #INDEX_NOT_USED} if not applicable
         * @param value
         *            {@link #EVAL_FUNCTION_AND} | {@link #EVAL_FUNCTION_OR}
         * @return
         */

        //public bool setEvalFunction(int index1, int index2, int value)
        //{

        //    // Check value
        //    if (value != EVAL_FUNCTION_AND && value != EVAL_FUNCTION_OR)
        //        return false;

        //    // Check index
        //    // Check if the algorithm must search deeper (index2==-1 means no search inside blocks must be carried out)
        //    if (index2 == -1)
        //    {
        //        if (index1 < 0 || index1 >= conditions.size() - 1)
        //            return false;
        //    }
        //    else if (index2 >= 0)
        //    {
        //        if (index1 < 0 || index1 >= conditions.size())
        //            return false;
        //    }

        //    return Controller.getInstance().addTool(new SetEvalFunctionTool(conditions, index1, index2, value));
        //}

        //Condition type. Values: GLOBAL_STATE | CONDITION

        /**
         * The Dictionary of the context
         */

        public Dictionary <string, ConditionContextProperty> getContext()
        {
            Dictionary <string, ConditionContextProperty> currentContext = new Dictionary <string, ConditionContextProperty>();

            foreach (string key in context.Keys)
            {
                currentContext.Add(key, context[key]);
            }

            if (currentContext.ContainsKey(CONDITION_OWNER))
            {
                ConditionOwner owner = (ConditionOwner)currentContext[CONDITION_OWNER];
                if (owner.getOwnerType() == Controller.GLOBAL_STATE)
                {
                    //string ownerId = owner.getOwnerName();
                    //ConditionRestrictions restrictions = new ConditionRestrictions( new string[] { ownerId } );
                    //ConditionRestrictions restrictions = new ConditionRestrictions(exceptions(ownerId));
                    //currentContext.Add(CONDITION_RESTRICTIONS, restrictions);
                }
            }

            return(currentContext);
        }
Esempio n. 5
0
 public string getNoConditionFormattedSentence(ConditionOwner owner)
 {
     return(formatSentence(owner, sentenceNoConditions));
 }