本文整理汇总了C#中HeD.Engine.Translation.TranslationContext.TransformModelType方法的典型用法代码示例。如果您正苦于以下问题:C# TranslationContext.TransformModelType方法的具体用法?C# TranslationContext.TransformModelType怎么用?C# TranslationContext.TransformModelType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeD.Engine.Translation.TranslationContext
的用法示例。
在下文中一共展示了TranslationContext.TransformModelType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Translate
public object Translate(TranslationContext context, ASTNode node)
{
// Model mapping
var result = new CREFModel.RequestExpression();
if (node.ResultType == null)
{
throw new InvalidOperationException("Clinical request expression has no result type.");
}
var cardinality = (RequestCardinality)Enum.Parse(typeof(RequestCardinality), node.Attributes["cardinality"].ToString(), true);
result.Cardinality = cardinality == RequestCardinality.Single ? CREFModel.RequestCardinality.Single : CREFModel.RequestCardinality.Multiple;
result.CardinalitySpecified = true;
var requestListType = node.ResultType as ListType;
var requestType = (requestListType == null ? node.ResultType : requestListType.ElementType) as ObjectType;
if (requestType == null)
{
throw new InvalidOperationException(String.Format("Unable to determine request type from source type: '{0}'.", node.ResultType.Name));
}
result.Type = GetQueryType(context.TransformModelType(requestType));
result.TypeSpecified = true;
// Translate Codes
var codes = node.Children.Where(n => n.Name == "codes").FirstOrDefault();
if (codes != null)
{
var codesResult = context.TranslateNode(codes);
result.Items.Add(codesResult);
}
// Translate DateRange
var dateRange = node.Children.Where(n => n.Name == "dateRange").FirstOrDefault();
if (dateRange != null)
{
var dateRangeResult = context.TranslateNode(dateRange);
result.Items.Add(dateRangeResult);
}
// Validate idProperty, dateProperty, and codeProperty
ValidateIdProperty(requestType, node.GetAttribute<string>("idProperty"));
ValidateDateProperty(requestType, node.GetAttribute<string>("dateProperty"));
ValidateCodeProperty(requestType, node.GetAttribute<string>("codeProperty"));
// Add status filters if necessary
var filterValue = GetStatusFilterValue(requestType);
if (!String.IsNullOrEmpty(filterValue))
{
var filter = new CREFModel.FilterExpression();
filter.Items.Add(result);
var condition = new CREFModel.BinaryExpression();
condition.Operator = CREFModel.BinaryOperator.opEqual;
condition.OperatorSpecified = true;
condition.Items.Add(new CREFModel.PropertyExpression() { Path = "Status" });
condition.Items.Add(new CREFModel.ValueExpression() { Type = CREFModel.ValueType.String, TypeSpecified = true, Value = filterValue });
filter.Items.Add(condition);
return filter;
}
return result;
}