Esempio n. 1
0
 /// <summary>
 /// Create api model from service model
 /// </summary>
 /// <param name="model"></param>
 public FilterOperandApiModel(FilterOperandModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     NodeId      = model.NodeId;
     AttributeId = model.AttributeId;
     BrowsePath  = model.BrowsePath;
     IndexRange  = model.IndexRange;
     Index       = model.Index;
     Alias       = model.Alias;
     Value       = model.Value;
     NodeId      = model.NodeId;
 }
Esempio n. 2
0
 /// <summary>
 /// Create service model from api model
 /// </summary>
 public static FilterOperandApiModel ToApiModel(
     this FilterOperandModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new FilterOperandApiModel {
         Index = model.Index,
         Alias = model.Alias,
         Value = model.Value,
         NodeId = model.NodeId,
         AttributeId = (Core.Models.NodeAttribute?)model.AttributeId,
         BrowsePath = model.BrowsePath,
         IndexRange = model.IndexRange
     });
 }
 /// <summary>
 /// Convert to stack model
 /// </summary>
 /// <param name="model"></param>
 /// <param name="encoder"></param>
 /// <param name="onlySimpleAttributeOperands"></param>
 /// <returns></returns>
 public static FilterOperand Decode(this IVariantEncoder encoder,
                                    FilterOperandModel model, bool onlySimpleAttributeOperands = false)
 {
     if (model == null)
     {
         return(null);
     }
     if (model.Index != null)
     {
         return(new ElementOperand {
             Index = model.Index.Value
         });
     }
     if (model.Value != null)
     {
         return(new LiteralOperand {
             Value = encoder.Decode(model.Value, null)
         });
     }
     if (model.Alias != null && !onlySimpleAttributeOperands)
     {
         return(new AttributeOperand {
             Alias = model.Alias,
             NodeId = model.NodeId.ToNodeId(encoder.Context),
             AttributeId = (uint)(model.AttributeId ?? NodeAttribute.Value),
             BrowsePath = model.BrowsePath.ToRelativePath(encoder.Context),
             IndexRange = model.IndexRange
         });
     }
     return(new SimpleAttributeOperand {
         TypeDefinitionId = model.NodeId.ToNodeId(encoder.Context),
         AttributeId = (uint)(model.AttributeId ?? NodeAttribute.Value),
         BrowsePath = new QualifiedNameCollection(model.BrowsePath == null ?
                                                  Enumerable.Empty <QualifiedName>() :
                                                  model.BrowsePath?.Select(n => n.ToQualifiedName(encoder.Context))),
         IndexRange = model.IndexRange
     });
 }