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


C# RuleContext.AddOutValue方法代码示例

本文整理汇总了C#中RuleContext.AddOutValue方法的典型用法代码示例。如果您正苦于以下问题:C# RuleContext.AddOutValue方法的具体用法?C# RuleContext.AddOutValue怎么用?C# RuleContext.AddOutValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RuleContext的用法示例。


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

示例1: Execute

 protected override void Execute(RuleContext context)
 {
     //modify property value, to upper
     var val1 = (string)context.InputPropertyValues[PrimaryProperty];
     if (!string.IsNullOrEmpty(val1))
         context.AddOutValue(PrimaryProperty, val1.ToUpper());
 }
开发者ID:BiYiTuan,项目名称:csla,代码行数:7,代码来源:UpperCaseRule.cs

示例2: Execute

        protected override void Execute(RuleContext context)
        {
            var activityIdValue = (int)context.InputPropertyValues[PrimaryProperty];
            var activityStatusProperty = this.InputProperties.Single(p => p.Name == this.StatusName);
            var activtyStatusValue = (ActivitySubmissionStatus)context.InputPropertyValues[activityStatusProperty];
            var approvedByIdProperty = this.InputProperties.Single(p => p.Name == this.ApprovedByIdName);
            var approvedByIdValue = (ActivitySubmissionStatus)context.InputPropertyValues[approvedByIdProperty];

            if (approvedByIdValue == 0
                && (activtyStatusValue == ActivitySubmissionStatus.Unset
                || activtyStatusValue == ActivitySubmissionStatus.AwaitingApproval
                || activtyStatusValue == ActivitySubmissionStatus.Approved))
            {
                try
                {
                    var activityTask = Task.Run(() => IoC.Container.Resolve<IObjectFactory<IActivityEdit>>().FetchAsync(activityIdValue));
                    var activity = activityTask.Result;
                    context.AddOutValue(activityStatusProperty,
                        activity.RequiresApproval
                            ? ActivitySubmissionStatus.AwaitingApproval
                            : ActivitySubmissionStatus.Approved);
                }
                catch (Exception)
                {
                    context.AddErrorResult(PrimaryProperty,
                        string.Format(CultureInfo.CurrentCulture, "Activity id {0} was not able to be retrieved.", activityIdValue));
                }
            }
        }
开发者ID:Bowman74,项目名称:Badge-Application,代码行数:29,代码来源:DefaultActivityStatus.cs

示例3: Execute

    protected override void Execute(RuleContext context)
    {
      // Use linq Sum to calculate the sum value 
      var sum = context.InputPropertyValues.Sum(property => (dynamic)property.Value);

      // add calculated value to OutValues 
      // When rule is completed the RuleEngig will update businessobject
      context.AddOutValue(PrimaryProperty, sum);
    }
开发者ID:Jaans,项目名称:csla,代码行数:9,代码来源:CalcSum.cs

示例4: Execute

    /// <summary>
    /// The execute.
    /// </summary>
    /// <param name="context">
    /// The context.
    /// </param>
    protected override void Execute(RuleContext context)
    {
      var id = (int) context.InputPropertyValues[PrimaryProperty];

      // use a command or read-only object for lookup
      var lookup = LookupCustomerCommand.Execute(id);

      context.AddOutValue(NameProperty, lookup.Name);
    }
开发者ID:Jaans,项目名称:csla,代码行数:15,代码来源:LookupCustomer.cs

示例5: Execute

        /// <summary>
        /// Business rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var value = (string) context.InputPropertyValues[PrimaryProperty];
            if (string.IsNullOrEmpty(value)) return;

            var newValue = value.Trim();
            var r = new Regex(@"\s+");
            newValue = r.Replace(newValue, @" ");
            context.AddOutValue(PrimaryProperty, newValue);
        }
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:14,代码来源:CollapseWhiteSpace.cs

示例6: Execute

    /// <summary>
    /// The execute.
    /// </summary>
    /// <param name="context">
    /// The context.
    /// </param>
    protected override void Execute(RuleContext context)
    {
      var value = (string) context.InputPropertyValues[PrimaryProperty];
      context.AddOutValue(PrimaryProperty, value.ToUpper());

     if (context.IsCheckRulesContext)
        Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
      else
        Console.WriteLine(".... Rule {0} running from {1} was changed", this.GetType().Name, this.PrimaryProperty.Name);
    }
开发者ID:nschonni,项目名称:csla-svn,代码行数:16,代码来源:ToUpper.cs

示例7: Execute

        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            if (context == null)
                return;

            var input = context.InputPropertyValues[PrimaryProperty] as int?;

            if (input.HasValue && input.Value <= 0)
                context.AddOutValue(null);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:14,代码来源:SingleCrossReferenceValueShouldBePositiveRule.cs

示例8: Execute

        /// <summary>
        /// Rule implementation.
        /// </summary>
        /// <param name="context">Rule context.</param>
        protected override void Execute(RuleContext context)
        {
            var valueAsString = (string) context.InputPropertyValues[PrimaryProperty];

            if (valueAsString != null && valueAsString.IsNotEmpty())
            {
                if (!valueAsString.IsUpper())
                {
                    context.AddOutValue(PrimaryProperty, valueAsString.ToUpper());
                }
            }
        }
开发者ID:nttung91,项目名称:PLSoft,代码行数:16,代码来源:StringToUpperCase.cs

示例9: Execute

    /// <summary>
    /// Business or validation rule implementation.
    /// </summary>
    /// <param name="context">
    /// Rule context object.
    /// </param>
    protected override void Execute(RuleContext context)
    {
      var value = (string)context.InputPropertyValues[PrimaryProperty];
      if (string.IsNullOrEmpty(value)) return;

      var newValue = value.Trim(' ');
      var r = new Regex(@" +");
      newValue = r.Replace(newValue, @" ");
      context.AddOutValue(newValue);

      if (context.IsCheckRulesContext)
        Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
      else
        Console.WriteLine(".... Rule {0} running from {1} was changed", this.GetType().Name, this.PrimaryProperty.Name);
    }
开发者ID:nschonni,项目名称:csla-svn,代码行数:21,代码来源:CollapseSpace.cs

示例10: Execute

        protected override void Execute(RuleContext context)
        {
            var badgeTypeValue = (BadgeType)context.InputPropertyValues[PrimaryProperty];
            var badgeStatusProperty = this.InputProperties.Single(p => p.Name == this.StatusName);
            var badgeStatusValue = (BadgeStatus)context.InputPropertyValues[badgeStatusProperty];
            var approvedByIdProperty = this.InputProperties.Single(p => p.Name == this.ApprovedByIdName);
            var approvedByIdValue = (int)context.InputPropertyValues[approvedByIdProperty];

            if (approvedByIdValue == 0 && (badgeStatusValue == BadgeStatus.AwaitingApproval
                || badgeStatusValue == BadgeStatus.Approved || badgeStatusValue == BadgeStatus.Unset))
            {
                context.AddOutValue(badgeStatusProperty,
                    badgeTypeValue == BadgeType.Community ? BadgeStatus.AwaitingApproval : BadgeStatus.Approved);
            }
        }
开发者ID:Bowman74,项目名称:Badge-Application,代码行数:15,代码来源:DefaultBadgeStatus.cs

示例11: Execute

		protected override void Execute(RuleContext context)
		{
			var dateProperty = this.InputProperties[0];

			var value = context.InputPropertyValues[dateProperty];

			if (value != null)
			{
				if (typeof(DateTime?).GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
				{
					var nullableDate = value as DateTime?;

					if (nullableDate != null)
					{
						context.AddOutValue(dateProperty, nullableDate.Value.ToUniversalTime());
					}
				}
				else if (typeof(DateTime).GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
				{
					var date = (DateTime)context.InputPropertyValues[dateProperty];
					context.AddOutValue(dateProperty, date.ToUniversalTime());
				}
			}
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:24,代码来源:UtcDateRule.cs

示例12: Execute

		protected override void Execute(RuleContext context)
		{
			var pollEndDateProperty = this.InputProperties[0];
			var isActiveProperty = this.InputProperties[1];

			var pollEndDate = (DateTime)context.InputPropertyValues[pollEndDateProperty];
			var isActive = (bool)context.InputPropertyValues[isActiveProperty];

			var now = DateTime.UtcNow;

			if (pollEndDate < now)
			{
				context.AddErrorResult(pollEndDateProperty, "The poll has ended.");
				context.AddOutValue(isActiveProperty, false);
			}
		}
开发者ID:JacobAtchley,项目名称:MyVote,代码行数:16,代码来源:PollSubmissionPollEndDateRule.cs

示例13: Execute

    /// <summary>
    /// Business or validation rule implementation.
    /// </summary>
    /// <param name="context">
    /// Rule context object.
    /// </param>
    protected override void Execute(RuleContext context)
    {
      // Use linq Sum to calculate the sum value
      var sum = context.InputPropertyValues.Sum(property => (dynamic)property.Value);

      // add calculated value to OutValues
      // When rule is completed the RuleEngine will update businessobject
      context.AddOutValue(PrimaryProperty, sum);

      if (context.IsCascadeContext)
         Console.WriteLine(".... Rule {0} running from affected property or input property", this.GetType().Name);
      else if (context.IsCheckRulesContext)
        Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
      else
        Console.WriteLine(".... Rule {0} running from {2} was changed", this.GetType().Name, this.PrimaryProperty.Name);
    }
开发者ID:Jaans,项目名称:csla,代码行数:22,代码来源:CalcSum.cs

示例14: Execute

    /// <summary>
    /// The execute.
    /// </summary>
    /// <param name="context">
    /// The context.
    /// </param>
    protected override void Execute(RuleContext context)
    {
      var id = (int) context.InputPropertyValues[PrimaryProperty];

      // uses the async methods in DataPortal to perform data access on a background thread. 
      LookupCustomerCommand.BeginExecute(id, (o, e) =>
                                               {
                                                 if (e.Error != null)
                                                 {
                                                   context.AddErrorResult(e.Error.ToString());
                                                 }
                                                 else
                                                 {
                                                   context.AddOutValue(NameProperty, e.Object.Name);
                                                 }

                                                 context.Complete();
                                               });
    }
开发者ID:BiYiTuan,项目名称:csla,代码行数:25,代码来源:AsyncLookupCustomer.cs

示例15: Execute

 /// <summary>
 /// Look up State and set the state name 
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
   var stateId = (string)context.InputPropertyValues[PrimaryProperty];
   var state = StatesNVL.GetNameValueList().Where(p => p.Key == stateId).FirstOrDefault();
   context.AddOutValue(StateName, state == null ? "Unknown state" : state.Value);
 }
开发者ID:BiYiTuan,项目名称:csla,代码行数:10,代码来源:SetStateName.cs


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