Example #1
0
 public static void UpdateValue <T>(this T targetNode, IModelNode sourceNode, params Expression <Func <T, object> >[] expressions) where T : IModelNode
 {
     foreach (var expression in expressions)
     {
         var attributeName = targetNode.GetPropertyName(expression);
         if (sourceNode.HasValue(attributeName))
         {
             var value = sourceNode.GetValue <T>(attributeName);
             sourceNode.ClearValue(attributeName);
             targetNode.SetValue(attributeName, value);
         }
     }
 }
Example #2
0
        public static bool HasValue(this IModelNode modelNode, params Type[] interfacesToSearch)
        {
            var valueInfos = ((ModelNode)modelNode).NodeInfo.ValuesInfo;

            string[] namesToSearch = valueInfos.Select(info => info.Name).ToArray();
            if (interfacesToSearch != null)
            {
                namesToSearch = interfacesToSearch.SelectMany(type => type.Properties()).Select(info => info.Name).ToArray();
            }
            return(valueInfos.Where(info => namesToSearch.Contains(info.Name)).Select(info => modelNode.HasValue(info.Name)).Any());
        }
Example #3
0
 protected virtual object GetNodeValueCore(IModelNode modelNode, string name)
 {
     return(modelNode.HasValue(name) ? modelNode.GetValue(name) : null);
 }