当前位置: 首页>>代码示例>>C#>>正文


C# Condition类代码示例

本文整理汇总了C#中Condition的典型用法代码示例。如果您正苦于以下问题:C# Condition类的具体用法?C# Condition怎么用?C# Condition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Condition类属于命名空间,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Task

 //Initialize task from Weak variables
 public Task(XmlElement Element)
 {
     if (Element.Name != "Task")
         throw new Exception("Incorrect XML markup");
     this.Name = Element.GetElementsByTagName("Name")[0].InnerText;
     this.GroupName = Element.GetElementsByTagName("GroupName")[0].InnerText;
     this.Description = Element.GetElementsByTagName("Description")[0].InnerText;
     this.Active = Element.GetElementsByTagName("Active")[0].InnerText == "1";
     XmlElement TriggersElement = (XmlElement)Element.GetElementsByTagName("Triggers")[0];
     foreach (XmlElement TriggerElement in TriggersElement.ChildNodes)
     {
         Trigger Trigger = new Trigger(TriggerElement);
         Triggers.Add(Trigger);
         Trigger.AssignTask(this);
     }
     XmlElement ConditionsElement = (XmlElement)Element.GetElementsByTagName("Conditions")[0];
     foreach (XmlElement ConditionElement in ConditionsElement.ChildNodes)
     {
         Condition Condition = new Condition(ConditionElement);
         Conditions.Add(Condition);
         Condition.AssignTask(this);
     }
     XmlElement ActionsElement = (XmlElement)Element.GetElementsByTagName("Actions")[0];
     foreach (XmlElement ActionElement in ActionsElement.ChildNodes)
     {
         Actions.Action Action = new Actions.Action(ActionElement);
         Actions.Add(Action);
         Action.AssignTask(this);
     }
 }
开发者ID:TimeToogo,项目名称:WIDA-Tasks,代码行数:31,代码来源:Task.cs

示例2: IsValid

		public bool IsValid(object owner, Condition condition)
		{
			XmlView xmlView = XmlView.ActiveXmlView;
			if (xmlView != null)
				return xmlView.StylesheetFileName != null;
			return false;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:StylesheetAssignedCondition.cs

示例3: FindOrWaitForOpenWindow

        private AutomationElement FindOrWaitForOpenWindow(Condition condition, TimeSpan timeout)
        {
            DateTime startedAt = DateTime.Now;
            Monitor.Enter(_waitingRoom);
            AutomationElement windowElement;

            AutomationEventHandler handler = delegate { windowElement = WindowOpened(condition); };
            Automation.AddAutomationEventHandler(WindowPattern.WindowOpenedEvent,
                                                 AutomationElement.RootElement, TreeScope.Children,
                                                 handler);

            windowElement = FindOpenWindow(condition);
            while (windowElement == null && (DateTime.Now.Subtract(startedAt)).CompareTo(timeout) < 0)
            {
                // We are polling because sometimes the event handler doesn't fire
                // quickly enough for my liking - the system is too busy. This lets
                // us check every second, while still taking advantage of the event handling
                // if it does decide to fire.
                Monitor.Wait(_waitingRoom, Math.Min(1000, timeout.Milliseconds));
            }

            Automation.RemoveAutomationEventHandler(
                WindowPattern.WindowOpenedEvent,
                AutomationElement.RootElement,
                handler);

            Monitor.Exit(_waitingRoom);
            return windowElement;
        }
开发者ID:pako4u2k,项目名称:wipflash,代码行数:29,代码来源:WindowFinder.cs

示例4: ExportExpressionList

 private string ExportExpressionList(Condition c)
 {
     if (!c.IsGroup)
         return c.ToString();
     if (!c.Conditions.Any())
         return null;
     var list = c.Conditions.Select(ExportExpression).ToList();
     string andOrNot;
     string not = "";
     switch (c.ComparisonType)
     {
         case CompareType.AllTrue:
             andOrNot = $"\n{Level}AND ";
             break;
         case CompareType.AnyTrue:
             andOrNot = $"\n{Level}OR ";
             break;
         case CompareType.AllFalse:
             andOrNot = $"\n{Level}AND NOT ";
             not = "NOT ";
             break;
         default:
             throw new ArgumentException();
     }
     var inner = string.Join(andOrNot, list.Where(vv => vv.HasCode()));
     return $"{Level}{not}{inner}";
 }
开发者ID:stevesloka,项目名称:bvcms,代码行数:27,代码来源:QueryExport.cs

示例5: IsValid

 public bool IsValid(object caller, Condition condition, Codon codon)
 {
     if (caller is IOwnerState)
     {
         try
         {
             string str = condition.Properties.Get<string>("ownerstate", string.Empty);
             if (codon.Properties.Contains("ownerstate"))
             {
                 str = codon.Properties["ownerstate"];
             }
             if (string.IsNullOrEmpty(str) || (str == "*"))
             {
                 return true;
             }
             Enum internalState = ((IOwnerState) caller).InternalState;
             Enum enum3 = (Enum) Enum.Parse(internalState.GetType(), str);
             int num = int.Parse(internalState.ToString("D"));
             int num2 = int.Parse(enum3.ToString("D"));
             if (LoggingService.IsDebugEnabled)
             {
                 LoggingService.DebugFormatted("stateInt:{0}, conditionInt:{1}", new object[] { num, num2 });
             }
             return ((num & num2) > 0);
         }
         catch (Exception)
         {
             throw new ApplicationException(string.Format("[{0}] can't parse '" + condition.Properties["ownerstate"] + "'. Not a valid value.", codon.Id));
         }
     }
     return false;
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:32,代码来源:OwnerStateConditionEvaluator.cs

示例6: BuildConditions

        private IPolicyObjectCollection<IPolicyObject> BuildConditions()
        {
            DataMethod dataMethod = new DataMethod("Test method");
            dataMethod.Parameters.Add(new Parameter("FindSomething", new DataElement(new TranslateableLanguageItem("string value"), new TranslateableLanguageItem(""), DataType.String, "missing")));
            dataMethod.Parameters.Add(new Parameter("RunSomething", new DataElement(new TranslateableLanguageItem("string value"), new TranslateableLanguageItem(""), DataType.String, "just do it!")));
            DataSource dataSource = new DataSource("Testme.dll", "TestMe", dataMethod);

            ICondition subCondition = new Condition(new Guid("{6B7F6B0C-747A-4BD0-A65D-A1FB9E44FE7C}"), "ITestOne", OperatorType.GreaterThan);
            subCondition.DataLeft = new DataElement(new Guid("{4E2F50C5-D310-47A1-AE3A-621F5C77FA68}"), new TranslateableLanguageItem("Do testing stuff"), new TranslateableLanguageItem(""), DataType.Object, dataSource);
            IDataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item"), DataType.Long, "10");
            subCondition.DataRight = new DataElement(new Guid("{EB56B397-954D-45C2-ADBA-263372A8B59F}"), new TranslateableLanguageItem("Test data item stored in data element"), new TranslateableLanguageItem(""), DataType.Long, dataItem);

            IConditionGroup subConditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Test group two"), ConditionLogic.AND, false);
            subConditionGroup.Conditions.Add(subCondition);
            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{D64056E5-A19D-4B29-8F4A-A70337B42A19}"), new TranslateableLanguageItem("Test group one"), ConditionLogic.OR, true);
            conditionGroup.Conditions.Add(subConditionGroup);

            DataMethod dataMethod2 = new DataMethod("Test method two");
            dataMethod2.Parameters.Add(new Parameter("DoIt", new DataElement(new TranslateableLanguageItem("string value"), new TranslateableLanguageItem(""), DataType.String, "You should do this")));
            dataMethod2.Parameters.Add(new Parameter("DontDoIt", new DataElement(new TranslateableLanguageItem("string value"), new TranslateableLanguageItem(""), DataType.String, "You should not do this")));
            DataSource dataSource2 = new DataSource("Test2.dll", "JustDoIt", dataMethod2);

            ICondition condition = new Condition(new Guid("{A6F876B6-AD6D-4842-BC0D-4635D1EEE916}"), "ITestTwo", OperatorType.GreaterThanOrEqualTo);
            condition.DataLeft = new DataElement(new Guid("{7CED5561-FD8C-423C-838F-9440EDFE6758}"), new TranslateableLanguageItem("Some data source"), new TranslateableLanguageItem(""), DataType.Object, dataSource2);
            IDataItem dataItem2 = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item 2"), DataType.Long, "2");
            condition.DataRight = new DataElement(new Guid("{C6E38158-AB8C-496B-B97D-FD413680977D}"), new TranslateableLanguageItem("Test result2"), new TranslateableLanguageItem(""), DataType.Long, dataItem2);

            IPolicyObjectCollection<IPolicyObject> conditions = new PolicyObjectCollection<IPolicyObject>();
            conditions.Add(conditionGroup);
            conditions.Add(condition);

            return conditions;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:33,代码来源:TestXmlPolicyWriter.cs

示例7: TestAddConditionGroupWithChildren

        public void TestAddConditionGroupWithChildren()
        {
            IPolicyLanguage language = new PolicyLanguage(new Guid("{E8B22533-98EB-4D00-BDE4-406DC3E1858B}"), "en");

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(new Guid("{AB5E2A43-01FB-4AA6-98FC-8F74BB0621CA}"), language.Identifier, new TranslateableLanguageItem("{B5C31A66-1B39-4CA7-BF02-AF271B5864F7}"), catalogueStore);
            catalogueStore.AddPolicyCatalogue(policyCatalogue);

            PolicySetObserver policySetObserver = new PolicySetObserver(policyCatalogue);

            Assert.AreEqual(0, policyCatalogue.Conditions.Count);
            Assert.AreEqual(0, policyCatalogue.ConditionGroups.Count);

            IConditionGroup conditionGroup = new ConditionGroup(new Guid("{5823E98A-1F4D-44B9-BC0E-A538BD2C9262}"), new TranslateableLanguageItem("Test group"), ConditionLogic.AND, false);
            IConditionGroup subConditionGroup = new ConditionGroup(new Guid("{B87DF614-2400-4C1F-BEA8-3C2EB3964EAE}"), new TranslateableLanguageItem("Test sub group"), ConditionLogic.AND, false);
            ICondition condition = new Condition(new Guid("{98C73BC3-3E20-403C-8023-C91E2818355F}"), "TestClass", new TranslateableLanguageItem("This is a test"), OperatorType.Equals);
            subConditionGroup.Conditions.Add(condition);
            conditionGroup.Conditions.Add(subConditionGroup);

            policySetObserver.AddObject(conditionGroup);

            Assert.AreEqual(1, policyCatalogue.Conditions.Count);
            Assert.AreEqual(2, policyCatalogue.ConditionGroups.Count);
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:TestPolicySetObserver.cs

示例8: Action

 /// <summary>
 /// Creates instance of the <see cref="Action"></see> class with properties initialized with specified parameters.
 /// </summary>
 /// <param name="returnType">The return type of the action.</param>
 /// <param name="when"><see cref="T:WixSharp.When"/> the action should be executed with respect to the <paramref name="step"/> parameter.</param>
 /// <param name="step"><see cref="T:WixSharp.Step"/> the action should be executed before/after during the installation.</param>
 /// <param name="condition">The launch condition for the <see cref="Action"/>.</param>
 protected Action(Return returnType, When when, Step step, Condition condition)
 {
     Return = returnType;
     Step = step;
     When = when;
     Condition = condition;
 }
开发者ID:denis-peshkov,项目名称:WixSharp,代码行数:14,代码来源:Action.cs

示例9: AddCondition

        public void AddCondition(SearchFields field, Condition condition)
        {
            if (! Conditions.ContainsKey(field))
                Conditions.Add(field, new List<Condition>());

            Conditions[field].Add(condition);
        }
开发者ID:lux01,项目名称:LibGatherer,代码行数:7,代码来源:SearchOptions.cs

示例10: PutCondition

        // PUT api/Conditions/5
        public HttpResponseMessage PutCondition(String id, Condition condition)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != condition.ID)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(condition).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
开发者ID:pabloelustondo,项目名称:WellCastServer,代码行数:26,代码来源:ConditionsController.cs

示例11: IsValid

		public bool IsValid(object caller, Condition condition)
		{
			if (caller is ISolutionFolderNode)
				return ProjectService.OpenSolution != null && !ProjectService.OpenSolution.IsReadOnly;
			IProject project = (caller as IProject) ?? ProjectService.CurrentProject;
			return project != null && !project.IsReadOnly;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:7,代码来源:WriteableProjectEvaluator.cs

示例12: CreateInteractionBehavior

    private static Node CreateInteractionBehavior(Dorf d, IInteractable i)
    {
        Condition findWork = new Condition(() => {
            //TODO: what check here? Maybe an action to get a work-place?
            return false;
        });

        BehaviorTrees.Action goToWork = new BehaviorTrees.Action(() => {
            //TODO: replace vector param with location of workplace!
            var mc = new MoveCommand(d,new Vector3(),WALKSPEED);
            if (mc.isAllowed()) {
                mc.execute();
                return Node.Status.RUNNING;
            } else {
                return Node.Status.FAIL;
            }
        });

        BehaviorTrees.Action work = new BehaviorTrees.Action(() => {
            //TODO: replace null value with some kind of interactable variable from d.
            var ic = new InteractCommand(d,null);
            if (ic.isAllowed()) {
                ic.execute();
                return Node.Status.RUNNING;
            } else {
                return Node.Status.FAIL;
            }
        });

        SequenceSelector root = new SequenceSelector(findWork,goToWork,work);
        return root;
    }
开发者ID:evilcandybag,项目名称:DwarfSplat,代码行数:32,代码来源:BehaviorUtils.cs

示例13: ANDCondition

	public ANDCondition(Condition aLeftCon, Condition aRightCon) {
		Debug.Assert(null != aLeftCon);
		Debug.Assert(null != aRightCon);

		left = aLeftCon;
		right = aRightCon;
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:7,代码来源:ANDCondition.cs

示例14: PerformTest

        public override void PerformTest()
        {
            Log("Creating " + _numberOfThreads + " threads");
            Thread[] threads = new Thread[_numberOfThreads];
            for (int i = 0; i < _numberOfThreads; i++)
            {
                threads[i] = new Thread(Work, ThreadPriority.Normal);
            }

            _startedThreads = 0;
            _startedThreadsLock = new Lock();
            _allThreadsStartedLock = new Lock();
            _allThreadsStartedCondition = new Condition(_allThreadsStartedLock);
            _allThreadsStartedLock.Acquire();

            Log("Starting " + _numberOfThreads + " threads"); // TODO: ParametizedThreadStart doesn't work properly
            for (int i = 0; i < _numberOfThreads; i++)
            {
                threads[i].Start();
            }

            // wait for all threads to be running
            _allThreadsStartedCondition.Await();
            _allThreadsStartedLock.Release();

            Log("Waiting for all threads to finish");

            _semaphore.Acquire(_numberOfThreads); // wait for all threads to finish

            Assert(_failedThreads + " threads failed the calculation", _failedThreads == 0);
            Log("All " + _numberOfThreads + " threads finished");

        }
开发者ID:mtenpow,项目名称:tenpow.com,代码行数:33,代码来源:MultiThreadingStressTest.cs

示例15: Rule

        /// <summary>
        /// Creates a new instance of the Rule using the rule defined in the policy document.
        /// </summary>
        /// <param name="rule">The rule defined in the policy document.</param>
        public Rule(RuleElement rule)
        {
            if (rule == null) throw new ArgumentNullException("rule");
            _rule = rule;
            if (_rule.SchemaVersion == XacmlVersion.Version10 || _rule.SchemaVersion == XacmlVersion.Version11)
            {
                _condition = new Condition((ConditionElement)_rule.Condition);
            }
            else if (_rule.SchemaVersion == XacmlVersion.Version20)
            {
                _condition = new Condition2((ConditionElement)_rule.Condition);
            }

            if (rule.Target != null)
            {
                _target = new Target((TargetElement)rule.Target);

                // Load all the resources for the elements within this rule.
                foreach (ResourceElement resource in rule.Target.Resources.ItemsList)
                {
                    foreach (ResourceMatchElement rmatch in resource.Match)
                    {
                        if (!_allResources.Contains(rmatch.AttributeValue.Contents))
                        {
                            _allResources.Add(rmatch.AttributeValue.Contents);
                        }
                    }
                }
            }
        }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:34,代码来源:Rule.cs


注:本文中的Condition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。