Exemple #1
0
 /// <summary>
 /// Visits the or right.
 /// </summary>
 /// <code>
 /// L_0008: ldloc.1 // right
 /// L_0009: br.s L_000c
 /// L_000b: ldc.i4.1
 /// L_000c: stloc.2 // result
 /// </code>
 /// <param name="or">The or.</param>
 public void VisitOrRight(OrCondition or)
 {
     Instructions.Add(Worker.Create(OpCodes.Br_S, GetJumpLabel(or.BranchId + 1)));
     Instructions.Add(GetJumpLabel(or.BranchId));
     Instructions.Add(Worker.Create(OpCodes.Ldc_I4_1));
     Instructions.Add(GetJumpLabel(or.BranchId + 1));
 }
        public void Test_4()
        {
            var condition1 = new SqlCondition("Name=@Name");
            var condition  = new OrCondition(condition1, null);

            Assert.Equal("Name=@Name", condition.GetCondition());
        }
Exemple #3
0
        private bool GetToolbarItems(AutomationElement element)
        {
            int retCounter = 0;
            PropertyCondition toolbarCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ToolBar);
            PropertyCondition paneCondition    = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane);
            PropertyCondition windowCondition  = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window);
            Condition         propCondition    = new OrCondition(toolbarCondition, paneCondition, windowCondition);

            var toolbars = element.FindAll(TreeScope.Children, propCondition).Cast <AutomationElement>();

            foreach (var el in toolbars)
            {
                ControlType type = el.Current.ControlType;

                if (type == ControlType.ToolBar)
                {
                    if (GetToolbarItem(el))
                    {
                        ++retCounter;
                    }
                }
                else
                {
                    if (GetToolbarItems(el))
                    {
                        ++retCounter;
                    }
                }
            }
            return(retCounter > 0);
        }
        public void NullBoostIsIgnored()
        {
            var condition = new OrCondition(new IOperator[] { new TestCondition("TEST") });

            Assert.That(condition.Boost, Is.Null);
            Assert.That(!condition.Options.Any());
        }
        public AutomationElementCollection Get_AllContainerUIElement(AutomationElement ancestorElement = null, bool childOnly = false, int timeout = 60)
        {
            if (ancestorElement == null)
            {
                ancestorElement = _GetRootElement();
            }
            AutomationElementCollection UIElems = null;
            TreeScope myScope   = TreeScope.Descendants;
            Condition condition = new OrCondition(
                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window),
                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane),
                new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Group)
                );

            if (childOnly)
            {
                myScope = TreeScope.Children;
            }
            DateTime dtBegin = DateTime.Now;

            do
            {
                UIElems = ancestorElement.FindAll(myScope, condition);
                if (UIElems != null)
                {
                    return(UIElems);
                }
            } while (dtBegin.AddSeconds(timeout) < DateTime.Now);
            return(UIElems);
        }
Exemple #6
0
        public void TestToStringNot()
        {
            EqualToString condition1 = new EqualToString()
            {
                Field = "VENDORID",
                Value = "V1234",
            };
            EqualToString condition2 = new EqualToString()
            {
                Field = "STATUS",
                Value = "T",
            };

            OrCondition or = new OrCondition()
            {
                Negate     = true,
                Conditions = new List <ICondition>
                {
                    condition1,
                    condition2
                }
            };

            Assert.Equal("NOT (VENDORID = 'V1234' OR STATUS = 'T')", or.ToString());
        }
        public void FieldIsAddedToDefinition()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") }, field: "testfield");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or field=testfield TEST)"));
        }
        public void Test_3()
        {
            var condition2 = new SqlCondition("Age>@Age");
            var condition  = new OrCondition(null, condition2);

            Assert.Equal("Age>@Age", condition.GetCondition());
        }
        public void BoostIsAddedToDefinition()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") }, boost: 8);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or boost=8 TEST)"));
        }
        /// <summary>
        /// Close microsoft word dialog
        /// </summary>
        /// <param name="filename">file name</param>
        /// <param name="Accept">A string value specifies the value of accept button in dialog</param>
        public static void CloseMicrosoftWordDialog(string filename, string Accept)
        {
            var       desktop      = AutomationElement.RootElement;
            Condition orCondition  = new OrCondition(new PropertyCondition(AutomationElement.NameProperty, filename + " - Word"), new PropertyCondition(AutomationElement.NameProperty, filename + ".docx - Word"));
            Condition Con_Document = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window), orCondition);
            //AutomationElement item_Document = WaitForWindow(desktop, Con_Document, TreeScope.Children);
            AutomationElement item_Document = desktop.FindFirst(TreeScope.Children, Con_Document);
            Condition         Con_Acc       = null;
            AutomationElement item_Acc      = null;

            if (Accept == "OK")
            {
                Thread.Sleep(2000);
                Condition         Con_Word  = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane), new PropertyCondition(AutomationElement.NameProperty, "Microsoft Word"));
                AutomationElement item_Word = WaitForElement(item_Document, Con_Word, TreeScope.Children, false);
                if (item_Word != null)
                {
                    Con_Acc  = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.NameProperty, "OK"));
                    item_Acc = item_Word.FindFirst(TreeScope.Descendants, Con_Acc);
                }
            }
            else if (Accept == "Yes")
            {
                Condition         Con_Word  = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window), new PropertyCondition(AutomationElement.NameProperty, "Microsoft Word"));
                AutomationElement item_Word = WaitForElement(item_Document, Con_Word, TreeScope.Children, true);
                Con_Acc  = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), new PropertyCondition(AutomationElement.NameProperty, "Yes"));
                item_Acc = item_Word.FindFirst(TreeScope.Descendants, Con_Acc);
            }
            if (item_Acc != null)
            {
                InvokePattern Pattern_Yes = (InvokePattern)item_Acc.GetCurrentPattern(InvokePattern.Pattern);
                Pattern_Yes.Invoke();
            }
        }
Exemple #11
0
        private bool GetMenuBarsInternal(AutomationElement element, List <AutomationElement> menuBars)
        {
            int retCounter = 0;
            PropertyCondition menubarCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.MenuBar);
            PropertyCondition paneCondition    = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane);
            PropertyCondition windowCondition  = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window);
            Condition         propCondition    = new OrCondition(menubarCondition, paneCondition, windowCondition);

            var includeMenuBar = element.FindAll(TreeScope.Children, propCondition).Cast <AutomationElement>();

            foreach (var el in includeMenuBar)
            {
                ControlType type = el.Current.ControlType;

                if (type == ControlType.MenuBar)
                {
                    menuBars.Add(el);
                    ++retCounter;
                }
                else
                {
                    if (GetMenuBarsInternal(el, menuBars))
                    {
                        ++retCounter;
                    }
                }
            }
            return(retCounter > 0);
        }
Exemple #12
0
        public void BoostIsAddedToDefinition()
        {
            var condition  = new OrCondition(new[] { new TestCondition("TEST") }, boost: 8);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or boost=8 TEST)"));
        }
Exemple #13
0
        public void OneTermIsNotWrapped()
        {
            var condition  = new OrCondition(new[] { new TestCondition("TEST") });
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("TEST"));
        }
Exemple #14
0
        public static ICondition GetConditions(List <ICondition> conditions, string conditionOperator)
        {
            ICondition condition = null;

            switch (conditionOperator)
            {
            case AND_OPERATOR:
                condition = new AndCondition()
                {
                    Conditions = conditions.ToArray()
                };
                break;

            case OR_OPERATOR:
                condition = new OrCondition()
                {
                    Conditions = conditions.ToArray()
                };
                break;

            case NOT_OPERATOR:
                condition = new NotCondition()
                {
                    Condition = conditions.Count == 0 ? null : conditions[0]
                };
                break;

            default:
                break;
            }

            return(condition);
        }
Exemple #15
0
        /// <summary>
        /// 用户查询
        /// 添加人:周 鹏
        /// 添加时间:2014-01-03
        /// </summary>
        /// <history>
        /// 修改描述:时间+作者+描述
        /// </history>
        /// <param name="search">查询实体</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">分页大小</param>
        /// <returns></returns>
        public PageJqDatagrid <CrmUserEntity> GetSearchResult(CrmUserEntity search, int pageSize = 10, int pageIndex = 1)
        {
            var queryCondition = QueryCondition.Instance.AddEqual(CrmUserEntity.Parm_CrmUser_RowStatus, "1");

            if (!string.IsNullOrEmpty(search.Account))
            {
                OrCondition orCondition = OrCondition.Instance.AddLike(CrmUserEntity.Parm_CrmUser_Account,
                                                                       search.Account);
                orCondition.AddLike(CrmUserEntity.Parm_CrmUser_RealName, search.Account);
                queryCondition.AddOr(orCondition);
            }
            if (!string.IsNullOrEmpty(search.DepartmentId))
            {
                queryCondition.AddEqual(CrmUserEntity.Parm_CrmUser_DepartmentId, search.DepartmentId);
            }
            //排序
            queryCondition.AddOrderBy(CrmUserEntity.Parm_CrmUser_SortCode, true);
            queryCondition.SetPager(pageIndex, pageSize);
            int totalRecord, totalPage;
            //计时
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var list = Query(queryCondition, out totalRecord, out totalPage);

            stopwatch.Stop();
            return(new PageJqDatagrid <CrmUserEntity>
            {
                page = pageIndex,
                rows = list,
                total = totalPage,
                records = totalRecord,
                costtime = stopwatch.ElapsedMilliseconds.ToString()
            });
        }
Exemple #16
0
        private Condition GetCondition()
        {
            var       info   = this.infoList[0];
            Condition result = new PropertyCondition(info.Property, info.Value);

            for (var i = 1; i < this.infoList.Count; ++i)
            {
                info = this.infoList[i];
                var condition = new PropertyCondition(info.Property, info.Value);
                switch (info.ConditionType)
                {
                case ConditionType.And:
                    result = new AndCondition(result, condition);
                    break;

                case ConditionType.Or:
                    result = new OrCondition(result, condition);
                    break;

                default:
                    throw new CruciatusException("ConditionType ERROR");
                }
            }

            return(result);
        }
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            WithImportancePredicate withImportancePredicate = new WithImportancePredicate();

            if (WithImportancePredicate.IsImportanceCondition(condition, Importance.High))
            {
                withImportancePredicate.Importance = Importance.High;
                return(withImportancePredicate);
            }
            if (WithImportancePredicate.IsImportanceCondition(condition, Importance.Low))
            {
                withImportancePredicate.Importance = Importance.Low;
                return(withImportancePredicate);
            }
            if (condition.ConditionType == ConditionType.Not)
            {
                NotCondition notCondition = (NotCondition)condition;
                if (notCondition.SubCondition.ConditionType == ConditionType.Or)
                {
                    OrCondition orCondition = (OrCondition)notCondition.SubCondition;
                    if (orCondition.SubConditions.Count == 2 && WithImportancePredicate.IsImportanceCondition(orCondition.SubConditions[0], Importance.High) && WithImportancePredicate.IsImportanceCondition(orCondition.SubConditions[1], Importance.Low))
                    {
                        withImportancePredicate.Importance = Importance.Normal;
                        return(withImportancePredicate);
                    }
                }
            }
            return(null);
        }
Exemple #18
0
        /// <summary>
        /// Visits the or.
        /// </summary>
        /// <remarks>
        /// Generate the || operator. The two values should be placed on the stack first.
        /// <code>
        /// L_0005: ldloc.0 // left
        /// L_0006: brtrue.s L_000b
        /// L_0008: ldloc.1 // right
        /// L_0009: br.s L_000c
        /// L_000b: ldc.i4.1
        /// L_000c: stloc.2 // result
        /// </code>
        /// </remarks>
        /// <param name="or">The or.</param>
        public void VisitOrLeft(OrCondition or)
        {
            or.BranchId        = BranchLabelOffSet + m_NumberOfBranches;
            m_NumberOfBranches = m_NumberOfBranches + 2;

            Instructions.Add(Worker.Create(OpCodes.Brtrue_S, GetJumpLabel(or.BranchId)));
        }
Exemple #19
0
        public void ConstructorTest()
        {
            OrCondition target = new OrCondition();

            // TODO: Implement code to verify target
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Exemple #20
0
        public void NullFieldIsIgnored()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") });

            Assert.That(condition.Field, Is.Null);
            Assert.That(!condition.Options.Any());
        }
Exemple #21
0
        public void FieldIsAddedToDefinition()
        {
            var condition  = new OrCondition(new[] { new TestCondition("TEST") }, field: "testfield");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or field=testfield TEST)"));
        }
Exemple #22
0
        public void OneTermWithOptionIsWrapped()
        {
            var condition  = new OrCondition(new[] { new TestCondition("TEST") }, boost: 3);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or boost=3 TEST)"));
        }
Exemple #23
0
        public void NullBoostIsIgnored()
        {
            var condition = new OrCondition(new IOperator[] { new TestCondition("TEST") });

            Assert.That(condition.Boost, Is.Null);
            Assert.That(!condition.Options.Any());
        }
Exemple #24
0
        public void NegateOrCondition(bool?first, bool?other, bool?third, bool?expected)
        {
            var fake1 = new Fake {
                IsTrueOrNull = first
            };

            using (var condition1 = new Condition(fake1.ObservePropertyChanged(x => x.IsTrueOrNull), () => fake1.IsTrueOrNull))
            {
                var fake2 = new Fake {
                    IsTrueOrNull = other
                };
                using (var condition2 = new Condition(fake2.ObservePropertyChanged(x => x.IsTrueOrNull), () => fake2.IsTrueOrNull))
                {
                    var fake3 = new Fake {
                        IsTrueOrNull = third
                    };
                    using (var condition3 = new Condition(fake3.ObservePropertyChanged(x => x.IsTrueOrNull), () => fake3.IsTrueOrNull))
                    {
                        using (var orCondition = new OrCondition(condition1, condition2, condition3))
                        {
                            using (var negated = new Negated <Condition>(orCondition))
                            {
                                Assert.AreEqual(expected, negated.IsSatisfied);
                            }
                        }
                    }
                }
            }
        }
Exemple #25
0
        public void TestFromJson1()
        {
            var point     = ECPoint.Parse("03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", ECCurve.Secp256r1);
            var hash      = UInt160.Zero;
            var condition = new OrCondition
            {
                Expressions = new WitnessCondition[]
                {
                    new CalledByContractCondition {
                        Hash = hash
                    },
                    new CalledByGroupCondition {
                        Group = point
                    }
                }
            };
            var json      = condition.ToJson();
            var new_condi = WitnessCondition.FromJson(json);

            Assert.IsTrue(new_condi is OrCondition);
            var or_condi = (OrCondition)new_condi;

            Assert.AreEqual(2, or_condi.Expressions.Length);
            Assert.IsTrue(or_condi.Expressions[0] is CalledByContractCondition);
            var cbcc = (CalledByContractCondition)(or_condi.Expressions[0]);

            Assert.IsTrue(or_condi.Expressions[1] is CalledByGroupCondition);
            var cbgc = (CalledByGroupCondition)(or_condi.Expressions[1]);

            Assert.IsTrue(cbcc.Hash.Equals(hash));
            Assert.IsTrue(cbgc.Group.Equals(point));
        }
Exemple #26
0
        public static bool MeetCondition(string softwareName, string applicationName, SpecificConfig entity)
        {
            bool Apply(Condition condition, Func <bool> isMeet)
            => condition.Excluding
                    ? !isMeet()
                    : isMeet();

            bool CheckConditions(IEnumerable <Condition> conditions, bool isOr)
            {
                bool Predicate(Condition c)
                => c switch
                {
                    AppCondition app => Apply(c, () => softwareName == app.AppName),
                    InstalledAppCondition installedApp => Apply(c, () => applicationName == installedApp.AppName),
                    AndCondition andCondition => Apply(c, () => CheckConditions(andCondition.Conditions, false)),
                    OrCondition orCondition => Apply(c, () => CheckConditions(orCondition.Conditions, true)),
                    _ => false
                };

                return(isOr
                    ? conditions.OrderBy(c => c.Order).Any(Predicate)
                    : conditions.OrderBy(c => c.Order).All(Predicate));
            }

            return(entity.Conditions.IsEmpty ||
                   CheckConditions(entity.Conditions, false));
        }
    }
Exemple #27
0
        public Task <ISubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition)
        {
            const string ruleName = "$Default";

            return(Task.Run(() =>
            {
                EnsureSubscriptionExists(topicPath, subscriptionName);

                var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName),
                                                                       new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName));
                var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition);
                var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition);

                return _retry.Do(async() =>
                {
                    var subscriptionClient = _connectionManager
                                             .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete);
                    var rules = await subscriptionClient.GetRulesAsync();


                    if (rules.Any(r => r.Name == ruleName))
                    {
                        await subscriptionClient.RemoveRuleAsync(ruleName);
                    }

                    await subscriptionClient.AddRuleAsync(ruleName, new SqlFilter(filterSql));

                    return subscriptionClient;
                },
                                 "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " +
                                 filterCondition);
            }).ConfigureAwaitFalse());
        }
        /// <summary>
        /// Wait for document opening with word
        /// </summary>
        /// <param name="docName">Wait for document opening with Office</param>
        /// <param name="docType">A string specify the document type</param>
        /// <param name="isreadonly">A bool value indicate if the document is readonly</param>
        /// <param name="popWindowsSecurity">A bool value indicate if pop Windows Security</param>
        /// <returns>A bool value indicate if the document is opening.</returns>
        public static bool WaitForOneNoteDocumentOpenning(string docName, bool isreadonly = false, bool popWindowsSecurity = false)
        {
            var desktop = AutomationElement.RootElement;
            AutomationElement document = null;

            if (isreadonly)
            {
                Condition multiCondition = new OrCondition(new PropertyCondition(AutomationElement.NameProperty, docName + ".one [Read-Only] - OneNote"), new PropertyCondition(AutomationElement.NameProperty, docName + " [Read-Only] - OneNote"), new PropertyCondition(AutomationElement.NameProperty, "OneNote"), new PropertyCondition(AutomationElement.NameProperty, "OneNote"), new PropertyCondition(AutomationElement.NameProperty, "Untitled page - OneNote"), new PropertyCondition(AutomationElement.NameProperty, docName + ".one - OneNote"));
                document = WaitForElement(desktop, multiCondition, TreeScope.Children, true);
            }
            else
            {
                Condition multiCondition = new OrCondition(new PropertyCondition(AutomationElement.NameProperty, docName + " - OneNote"), new PropertyCondition(AutomationElement.NameProperty, "Untitled page - OneNote"), new PropertyCondition(AutomationElement.NameProperty, docName + ".one - OneNote"), new PropertyCondition(AutomationElement.NameProperty, "OneNote"));
                document = WaitForElement(desktop, multiCondition, TreeScope.Children, true);
            }

            if (popWindowsSecurity)
            {
                Condition         windowsSecurity = new PropertyCondition(AutomationElement.NameProperty, "Windows Security");
                AutomationElement securityWindow  = WaitForElement(document, windowsSecurity, TreeScope.Children);
                if (securityWindow != null)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void Run()
        {
            DetectAlgorithm();

            List <Condition> conds = new List <Condition>();

            if (m_table != null && !m_loadAllConstraints)
            {
                conds.Add(new SchemaCondition(m_table.Schema));
            }
            if (m_table != null && !m_loadAllConstraints)
            {
                conds.Add(new EqualCondition("table_name", m_table.Name, false));
            }
            Condition cond = new AndCondition(conds.ToArray());

            if (m_members.ContainsAny(TableStructureMembers.ConstraintsNoIndexesNoRefs) || (m_members.ContainsAny(TableStructureMembers.ReferencedFrom) && m_loadAllConstraints))
            {
                LoadConstraints(cond);
                if (m_loadCheckConstraints)
                {
                    LoadCheckConstraints(cond);
                }
            }

            if (m_postgreRefs)
            {
                if (m_members.ContainsAny(TableStructureMembers.ForeignKeys | TableStructureMembers.ReferencedFrom))
                {
                    LoadKeyColumnUsage(cond);
                    LoadReferentialConstraints(cond);
                }
                else
                {
                    LoadKeyColumnUsage(cond);
                }
            }
            else
            {
                if (m_members.ContainsAny(TableStructureMembers.ReferencedFrom))
                {
                    List <Condition> conds2 = new List <Condition>();
                    if (m_table != null)
                    {
                        conds2.Add(new SchemaCondition(m_table.Schema));
                    }
                    if (m_table != null)
                    {
                        conds2.Add(new EqualCondition("referenced_table_name", m_table.Name, false));
                    }
                    Condition orcond = new OrCondition(cond, new AndCondition(conds2.ToArray()));
                    LoadKeyColumnUsage(orcond);
                }
            }
            if (m_infoSchema.HasView("referential_constraints") && m_members.ContainsAny(TableStructureMembers.ReferencedFrom | TableStructureMembers.ForeignKeys))
            {
                LoadForeignKeyRules(cond);
            }
        }
Exemple #30
0
        public String GetCellValue(String windowName,
                                   String objName, int row, int column = 0)
        {
            AutomationElement childHandle = GetObjectHandle(windowName,
                                                            objName);

            if (!utils.IsEnabled(childHandle))
            {
                childHandle = null;
                throw new XmlRpcFaultException(123,
                                               "Object state is disabled");
            }
            AutomationElement element = null;
            Condition         prop1   = new PropertyCondition(
                AutomationElement.ControlTypeProperty, ControlType.ListItem);
            Condition prop2 = new PropertyCondition(
                AutomationElement.ControlTypeProperty, ControlType.TreeItem);
            Condition condition1 = new OrCondition(prop1, prop2);
            Condition condition2 = new PropertyCondition(
                AutomationElement.ControlTypeProperty, ControlType.Text);

            try
            {
                childHandle.SetFocus();
                AutomationElementCollection c = childHandle.FindAll(
                    TreeScope.Children, condition1);
                element = c[row];
                c       = element.FindAll(TreeScope.Children, condition2);
                element = c[column];
                c       = null;
                if (element != null)
                {
                    return(element.Current.Name);
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw new XmlRpcFaultException(123,
                                               "Index out of range: " + "(" + row + ", " + column + ")");
            }
            catch (ArgumentException)
            {
                throw new XmlRpcFaultException(123,
                                               "Index out of range: " + "(" + row + ", " + column + ")");
            }
            catch (Exception ex)
            {
                LogMessage(ex);
                throw new XmlRpcFaultException(123,
                                               "Index out of range: " + "(" + row + ", " + column + ")");
            }
            finally
            {
                element = childHandle = null;
                prop1   = prop2 = condition1 = condition2 = null;
            }
            throw new XmlRpcFaultException(123,
                                           "Unable to get item value.");
        }
Exemple #31
0
 public static void IsSatisfied(bool?first, bool?second, bool?third, bool?expected)
 {
     using var collection = new OrCondition(
               Mock.Of <ICondition>(x => x.IsSatisfied == first),
               Mock.Of <ICondition>(x => x.IsSatisfied == second),
               Mock.Of <ICondition>(x => x.IsSatisfied == third));
     Assert.AreEqual(expected, collection.IsSatisfied);
 }
Exemple #32
0
        public static void Prerequisites2()
        {
            var mock1 = Mock.Of <ICondition>();
            var mock2 = Mock.Of <ICondition>();

            using var condition = new OrCondition(mock1, mock2);
            CollectionAssert.AreEqual(new[] { mock1, mock2 }, condition.Prerequisites);
        }
        public void Test_2()
        {
            var condition1 = new SqlCondition("Name=@Name");
            var condition2 = new SqlCondition("Age=@Age");
            var condition  = new OrCondition(condition1, condition2);

            Assert.Equal("(Name=@Name Or Age=@Age)", condition.GetCondition());
        }
        public void BoostIsAddedToOptions()
        {
            var condition = new OrCondition(new IOperator[]  { new TestCondition("TEST") }, boost: 984);
            var option = condition.Options.Single();

            Assert.That(option, Is.Not.Null);
            Assert.That(option.Name, Is.EqualTo("boost"));
            Assert.That(option.Value, Is.EqualTo("984"));
        }
        public static string GenerateSqlFor(OrCondition condition)
        {
            var filterExpressions = condition.Conditions.Select(ConditionSqlGenerator.GenerateSqlFor)
                                             .Select(e => $"({e})")
                                             .ToArray();

            var filterExpression = string.Join(" OR ", filterExpressions);
            return filterExpression;
        }
        public void FieldIsAddedToOptions()
        {
            var condition = new OrCondition(new IOperator[] { new TestCondition("TEST") }, field: "testfield");
            var option = condition.Options.Single();

            Assert.That(option, Is.Not.Null);
            Assert.That(option.Name, Is.EqualTo("field"));
            Assert.That(option.Value, Is.EqualTo("testfield"));
        }
        public void ManyTermsAreWrapped()
        {
            var condition = new OrCondition(new[]
            {
                new TestCondition("(omg)"),
                new TestCondition("(its (a) (test))"),
                new TestCondition("ZUBB")
            });
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or (omg) (its (a) (test)) ZUBB)"));
        }
        public void OneTermIsNotWrapped()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") });
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("TEST"));
        }
        public void NullFieldIsIgnored()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") });

            Assert.That(condition.Field, Is.Null);
            Assert.That(!condition.Options.Any());
        }
Exemple #40
0
	void Operation(out ConditionalExpression expression) {
		expression = null; 
		if (la.kind == 9) {
			Get();
			expression = new AndCondition(); 
		} else if (la.kind == 10) {
			Get();
			expression = new OrCondition(); 
		} else SynErr(48);
	}
Exemple #41
0
        public Task<SubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition)
        {
            return Task.Run(() =>
            {
                EnsureSubscriptionExists(topicPath, subscriptionName);

                var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName),
                                                                       new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName));
                var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition);
                var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition);

                return _retry.Do(() =>
                {
                    var subscriptionClient = _messagingFactory()
                        .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete);
                    subscriptionClient.ReplaceFilter("$Default", filterSql);
                    return subscriptionClient;
                },
                                 "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " +
                                 filterCondition);
            }).ConfigureAwaitFalse();
        }
        public void OneTermWithOptionIsWrapped()
        {
            var condition = new OrCondition(new[] { new TestCondition("TEST") }, boost: 3);
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("(or boost=3 TEST)"));
        }