Exemple #1
0
        public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager)
        {
            IEntityList leftBounds = ImplementationFactory.CreateEntityList();

            for (int i = 0; i < RightArgs.GetSize(); i++)
            {
                IEntity     arg    = RightArgs[i];
                IEntityList result = ImplementationFactory.CreateEntityList();
                string      attributeValue;
                if (RightType == PqlTokenType.CALL && (LeftType == PqlTokenType.PROCEDURE || LeftType == PqlTokenType.VARIABLE))
                {
                    attributeValue = arg.SecondaryAttribute.AttributeValue;
                }
                else
                {
                    attributeValue = arg.Attribute.AttributeValue;
                }

                if (LeftType == PqlTokenType.CALL && LeftRef.AttributeName.Equals("procName"))
                {
                    result.Sum(pkb.Statements.Copy().FilterBySecondaryAttribute(attributeValue));
                }
                else if (LeftType == PqlTokenType.PROCEDURE)
                {
                    result.AddEntity(pkb.Procedures.GetProcedureByName(attributeValue));
                }
                else if (LeftType == PqlTokenType.VARIABLE)
                {
                    result.AddEntity(pkb.Variables.GetVariableByName(attributeValue));
                }
                else
                {
                    result.AddEntity(pkb.Statements.GetEntityByAttribute(attributeValue));
                }

                if (RightRef is PqlSynonym)
                {
                    bindingsManager.CreateMultipleBindingsOneWay(arg, result, RightArgs, LeftArgs);
                }
                leftBounds.Sum(result);
            }
            LeftArgs.Intersection(leftBounds, bindingsManager);
        }
Exemple #2
0
        public void Process(IProgramKnowledgeBase pkb, BindingsManager bindingsManager)
        {
            if (LeftArgs.GetSize() < RightArgs.GetSize())
            {
                IEntityList rightBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    IEntity     arg    = LeftArgs[i];
                    IEntityList result = ProcessLeftSide(pkb, arg);
                    if (LeftRef is PqlSynonym && RightRef is PqlSynonym)
                    {
                        bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs);
                    }
                    rightBounds.Sum(result);
                }
                RightArgs.Intersection(rightBounds, bindingsManager);

                IEntityList leftBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < RightArgs.GetSize(); i++)
                {
                    IEntity     arg    = RightArgs[i];
                    IEntityList result = ProcessRightSide(pkb, arg);
                    leftBounds.Sum(result);
                }
                LeftArgs.Intersection(leftBounds, bindingsManager);
            }
            else
            {
                IEntityList leftBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < RightArgs.GetSize(); i++)
                {
                    IEntity     arg    = RightArgs[i];
                    IEntityList result = ProcessRightSide(pkb, arg);
                    leftBounds.Sum(result);
                }
                LeftArgs.Intersection(leftBounds, bindingsManager);

                IEntityList rightBounds = ImplementationFactory.CreateEntityList();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    IEntity     arg    = LeftArgs[i];
                    IEntityList result = ProcessLeftSide(pkb, arg);
                    if (LeftRef is PqlSynonym && RightRef is PqlSynonym)
                    {
                        bindingsManager.CreateMultipleBindings(arg, result, LeftArgs, RightArgs);
                    }
                    rightBounds.Sum(result);
                }
                RightArgs.Intersection(rightBounds, bindingsManager);
            }

            if (LeftArgs == RightArgs)
            {
                List <IEntity> toRemove = new List <IEntity>();
                for (int i = 0; i < LeftArgs.GetSize(); i++)
                {
                    if (!CheckFull(pkb, LeftArgs[i], LeftArgs[i]))
                    {
                        toRemove.Add(LeftArgs[i]);
                    }
                }
                foreach (IEntity arg in toRemove)
                {
                    bindingsManager.RemoveBoundEntity(arg, LeftArgs);
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Добавляем мебель
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FormEditFurniture_Load(object sender, EventArgs e)
 {
     this.ListBox_Left.Items.AddRange(LeftArgs.ToArray());
     this.ListBox_Right.Items.AddRange(RightArgs.ToArray());
 }