• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Translation.TranslationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Translate

		public object Translate(Artifact source)
		{
			var result = new CREFModel.DynamicRule();

			var context = new TranslationContext(this);

			// Metadata
			var identifier = source.MetaData.Children.First(c => c.Name == "identifiers").Children.First(c => c.Name == "identifier");
			result.Name = identifier.GetAttribute<string>("root");
			result.Description = source.MetaData.Children.First(c => c.Name == "title").GetAttribute<string>("value");
			result.SeverityID = "MED"; // TODO: HeD does not have an artifact level severity indicator.

			// Named Expressions
			result.DynamicRuleNamedExpressions = 
				(
					from expression in source.Expressions
						select TranslateNamedExpression(context, expression)
				).ToList();

			// Criteria
			result.DynamicRuleCriteria = TranslateCriteria(context, source.Conditions.First());

			// TODO: Assertion
			result.DynamicRuleAssertion = TranslateAssertion(context, source.ActionGroup);

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:27,代码来源:CREFTranslator.cs


示例2: Translate

		public object Translate(TranslationContext context, ASTNode node)
		{
			var result = new SQLModel.TableExpression();
			var sqlContext = (SQLTranslationContext)context;
			result.TableName = sqlContext.GetExpressionObjectName(String.Format("{0}.{1}", node.GetAttribute<string>("libraryName", sqlContext.ArtifactName), node.GetAttribute<string>("name")));

			// If the expression being referenced is scalar, it will be automatically promoted to a query by the expression def translation
			// In this case, it must be demoted back to a scalar expression with a subquery access.
			if (!(node.ResultType is ListType) && !(node.ResultType is ObjectType))
			{
				var selectExpression = new SQLModel.SelectExpression();
				selectExpression.SelectClause = new SQLModel.SelectClause();
				selectExpression.SelectClause.Columns.Add(new SQLModel.ColumnExpression(new SQLModel.QualifiedFieldExpression("value")));
				selectExpression.FromClause = new SQLModel.CalculusFromClause(new SQLModel.TableSpecifier(result));

				// If the result type is also boolean, the expression will be converted to a 1 or 0, so it must be demoted back to an actual boolean-valued expression
				if (DataTypes.Equal(node.ResultType, DataTypes.Boolean))
				{
					return SQLTranslationUtilities.DemoteBooleanValuedExpression(selectExpression);
				}

				return selectExpression;
			}

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:26,代码来源:Translators.cs


示例3: TranslateClinicalAssertion

		private CREFModel.ClinicalAssertion TranslateClinicalAssertion(TranslationContext context, Node node)
		{
			// node is expected to be an ActionGroup
			// Action types determine the assertion to be created
				// CreateAction - MissingDataAssertion
				// UpdateAction - MissingDataAssertion
				// MessageAction - OutOfRangeAssertion
				// CollectInformationAction - MissingDataAssertion
				// Any other action cannot be represented

			var assertions = new List<CREFModel.ClinicalAssertion>();

			var subElements = node.Children.FirstOrDefault(c => c.Name == "subElements");

			if (subElements != null)
			{
				foreach (var element in subElements.Children)
				{
					if (element.Name == "simpleAction")
					{
						switch (element.NodeType.GetLocalName())
						{
							case "CreateAction" : assertions.Add(TranslateCreateAction(context, element)); break;
							case "UpdateAction" : assertions.Add(TranslateUpdateAction(context, element)); break;
							case "MessageAction" : assertions.Add(TranslateMessageAction(context, element)); break;
							case "CollectInformationAction" : assertions.Add(TranslateCollectInformationAction(context, element)); break;
							default: throw new NotSupportedException(String.Format("Translation of {0} actions is not supported.", element.NodeType.GetLocalName()));
						}
					}
					else if (element.Name == "actionGroup")
					{
						assertions.Add(TranslateClinicalAssertion(context, element));
					}
					else if (element.Name == "actionGroupReference")
					{
						throw new NotSupportedException("Translation of action group references is not supported.");
					}
				}
			}

			if (assertions.Count > 1)
			{
				var compositeAssertion = new CREFModel.CompositeAssertion();

				compositeAssertion.CompositionType = GetCompositionType(GetGroupSelectionBehavior(node));

				var descriptionNode = node.Children.FirstOrDefault(c => c.Name == "Description");
				if (descriptionNode != null)
				{
					compositeAssertion.Description = descriptionNode.GetAttribute<string>("value");
				}

				compositeAssertion.CompositeAssertionAssertions.AddRange(assertions);

				return compositeAssertion;
			}

			return assertions[0];
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:59,代码来源:CREFTranslator.cs


示例4: TranslateAssertion

		private CREFModel.DynamicRuleDynamicRuleAssertion TranslateAssertion(TranslationContext context, Node node)
		{
			var result = new CREFModel.DynamicRuleDynamicRuleAssertion();

			result.Item = TranslateClinicalAssertion(context, node);

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:8,代码来源:CREFTranslator.cs


示例5: TranslateCriteria

		private CREFModel.DynamicRuleDynamicRuleCriteria TranslateCriteria(TranslationContext context, ASTNode condition)
		{
			var result = new CREFModel.DynamicRuleDynamicRuleCriteria();

			result.Item = context.TranslateNode(condition);

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:8,代码来源:CREFTranslator.cs


示例6: TranslateNamedExpression

		private CREFModel.NamedExpression TranslateNamedExpression(TranslationContext context, ExpressionDef expression)
		{
			var result = new CREFModel.NamedExpression();

			result.Name = expression.Name;
			result.Item = context.TranslateNode(expression.Expression);

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:9,代码来源:CREFTranslator.cs


示例7: GetFirstExpression

		protected object GetFirstExpression(TranslationContext context, object source)
		{
			var first = new SQLModel.UnaryExpression();

			first.Item = source;
			first.Operator = SQLModel.UnaryOperator.opFirst;
			first.OperatorSpecified = true;

			return first;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:10,代码来源:ModelTranslators.cs


示例8: TranslateCodeReference

		protected object TranslateCodeReference(TranslationContext context, ObjectType sourceType, ASTNode node, string path)
		{
			// Reference the Codes property with a First expression
			var result = GetPropertyExpression(context, node, "Codes");

			result = GetFirstExpression(context, result);

			// TODO: Issue a warning that an arbitrary Code is being selected

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:11,代码来源:ModelTranslators.cs


示例9: GetPropertyExpression

		protected object GetPropertyExpression(TranslationContext context, ASTNode node, string path)
		{
			var result = new SQLModel.PropertyExpression();
			result.Path = path;

			if (node.Children.Count > 0)
			{
				result.Item = context.TranslateNode(node.Children[0]);
			}

			return result;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:12,代码来源:ModelTranslators.cs


示例10: Translate

        public object Translate(TranslationContext context, ASTNode node)
        {
            var result = new CREFModel.BinaryExpression();
            result.Operator = GetOperator();
            result.OperatorSpecified = true;

            foreach (var child in node.Children)
            {
                result.Items.Add(context.TranslateNode(child));
            }

            return result;
        }
开发者ID:suesse,项目名称:healthedecisions,代码行数:13,代码来源:Translators.cs


示例11: GetCalculateAgeExpression

		protected object GetCalculateAgeExpression(TranslationContext context, object result)
		{
			var calculateAge = new SQLModel.CalculateAge();

			calculateAge.Items.Add(result);

			var binaryExpression = new SQLModel.BinaryExpression();

			// Returns as years, so multiply by days/year to get consistent results with the physical quantity translator
			binaryExpression.Operator = SQLModel.BinaryOperator.opMultiply;
			binaryExpression.OperatorSpecified = true;
			binaryExpression.Items.Add(calculateAge);

			var multiplier = new SQLModel.ValueExpression();
			multiplier.Type = SQLModel.ValueType.Decimal;
			multiplier.TypeSpecified = true;
			multiplier.Value = Convert.ToString(365.25m);

			binaryExpression.Items.Add(multiplier);

			return binaryExpression;
		}
开发者ID:GuntherM1466,项目名称:healthedecisions,代码行数:22,代码来源:ModelTranslators.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.List类代码示例发布时间:2022-05-26
下一篇:
C# Model.ASTNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap