protected Type EditorType(IModelNode node) {
     var modelListView = node as IModelListView;
     if (modelListView != null)
         return modelListView.EditorType;
     var modelColumn = node as IModelColumn;
     if (modelColumn != null)
         return ((IModelListView)modelColumn.ParentView).EditorType;
     throw new NotImplementedException(node.GetType().ToString());
 }
Exemplo n.º 2
0
        public bool IsVisible(IModelNode node, string propertyName)
        {
            var any = node.GetType().GetInterfaces().Any(type => {
                return(type.GetCustomAttributes(typeof(InvisibleLogicPropertyAttribute), false)
                       .Cast <InvisibleLogicPropertyAttribute>()
                       .Any(attribute => attribute.PropertyName == nameof(IContextLogicRule.ExecutionContextGroup)));
            });

            return(!any);
        }
Exemplo n.º 3
0
        public static ITypeInfo GetGenericListArgument(this IModelNode nodeByPath)
        {
            var type = nodeByPath.GetType();

            if (typeof(IEnumerable).IsAssignableFrom(type))
            {
                var genericModelList = type.GetInterfaces().First(type1 => typeof(IEnumerable).IsAssignableFrom(type1) && type1.IsGenericType);
                return(XafTypesInfo.Instance.FindTypeInfo(genericModelList.GetGenericArguments()[0]));
            }
            return(null);
        }
Exemplo n.º 4
0
        public override IDiagramNode CreateDiagramNode(IDiagramShapeResolver diagramShapeResolver, IModelNode modelNode)
        {
            if (modelNode == null)
            {
                throw new ArgumentNullException(nameof(modelNode));
            }

            if (modelNode is TypeNode typeNode)
            {
                return(new TypeDiagramNode(typeNode));
            }

            if (modelNode is PropertyNode propertyNode)
            {
                return(new PropertyDiagramNode(propertyNode));
            }

            throw new ArgumentException($"Unexpected type {modelNode.GetType().Name} in {GetType().Name}");
        }
Exemplo n.º 5
0
        public override IDiagramNode CreateDiagramNode(IDiagramShapeResolver diagramShapeResolver, IModelNode modelNode, IModelNode parentModelNode)
        {
            // TODO: handle parentModelNode

            if (modelNode is IRoslynTypeNode roslynTypeNode)
            {
                return(new RoslynTypeDiagramNode(roslynTypeNode));
            }

            throw new ArgumentException($"Expected {typeof(IRoslynTypeNode).Name} but received {modelNode.GetType().Name}");
        }
Exemplo n.º 6
0
        public bool IsVisible(IModelNode node, string propertyName)
        {
            var criteria = node.GetPropertyAttribute <ModelMapperBrowsableAttribute>(propertyName).Criteria;

            if (criteria != null)
            {
                node = node.GetNode(propertyName);
                var criteriaOperator    = CriteriaOperator.Parse(criteria);
                var expressionEvaluator = new ExpressionEvaluator(new EvaluatorContextDescriptorDefault(node.GetType()), criteriaOperator, customFunctions: CustomFunctions);
                var isVisible           = expressionEvaluator.Evaluate(node);
                if (isVisible != null)
                {
                    return((bool)isVisible);
                }
            }

            return(true);
        }
 public static Type ModelListType(this IModelNode modelNode)
 {
     return(modelNode.GetType().ModelListType());
 }
Exemplo n.º 8
0
 public static System.Type ModelListType(this IModelNode modelNode) => modelNode.GetType().ModelListType();