示例#1
0
        public void ApplyModel(object theObject, IModelNode modelNode)
        {
            var value    = modelNode.GetValue(_modelNodePath);
            var typeInfo = value as ITypeInfo;

            if (typeInfo != null)
            {
                value = typeInfo.Type;
            }
            SetValue(theObject, value);
        }
示例#2
0
        public static Tuple <ModelValueInfo, IModelNode> GetModelValueInfo(this IModelNode modelNode, string propertyName)
        {
            if (propertyName.Contains("."))
            {
                var split   = propertyName.Split('.');
                var strings = string.Join(".", split.Skip(1));
                var node    = ((IModelNode)modelNode.GetValue(split.First()));
                return(node.GetModelValueInfo(strings));
            }
            var modelValueInfo = ((ModelNode)modelNode).GetValueInfo(propertyName);

            return(new Tuple <ModelValueInfo, IModelNode>(modelValueInfo, modelNode));
        }
示例#3
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);
         }
     }
 }
示例#4
0
        IModelNode GetOptionNode(IModelNode modelListViewMainViewOptionsInterfaceType)
        {
            Type modelListViewMainViewOptionsType = GetModelOptionsType();

            for (int i = 0; i < modelListViewMainViewOptionsInterfaceType.NodeCount; i++)
            {
                IModelNode modelNode = modelListViewMainViewOptionsInterfaceType.GetNode(i);
                var        id        = modelNode.GetValue <string>("Id");
                if (id == modelListViewMainViewOptionsType.GetProperties()[0].Name)
                {
                    return(modelNode);
                }
            }
            return(null);
        }
示例#5
0
        private void CheckIfAdditionalViewControlsModuleIsRegister()
        {
            bool found = false;

            for (int i = 0; i < View.Model.Application.NodeCount; i++)
            {
                IModelNode modelNode = View.Model.Application.GetNode(i);
                if (modelNode.GetValue <string>("Id") == "AdditionalViewControls")
                {
                    found = true;
                    break;
                }
            }

            if (!(found))
            {
                throw new UserFriendlyException(new Exception("AdditionalViewControlsProvider module not found"));
            }
        }
示例#6
0
        /// <summary>
        /// Refreshes the <see cref="ObservableNode"/> corresponding to the given <see cref="IModelNode"/>, if an <see cref="ObservableViewModel"/>
        /// is available in the current.<see cref="IViewModelServiceProvider"/>.
        /// </summary>
        /// <param name="modelNode">The model node to use to fetch a corresponding <see cref="ObservableNode"/>.</param>
        /// <param name="index">The index at which the actual value to update is stored.</param>
        protected virtual void Refresh(IModelNode modelNode, object index)
        {
            if (modelNode == null)
            {
                throw new ArgumentNullException(nameof(modelNode));
            }

            var observableNode = Service.ResolveObservableNode(Identifier, ObservableNodePath) as ObservableModelNode;

            // No node matches this model node
            if (observableNode == null)
            {
                return;
            }

            var newValue = modelNode.GetValue(index);

            observableNode.ForceSetValue(newValue);
            observableNode.Owner.NotifyNodeChanged(observableNode.Path);
        }
示例#7
0
        public static object GetValue <T>(this IModelNode modelNode, Expression <Func <T, object> > property)
        {
            var name = typeof(T).GetMemberInfo(property).Name;

            return(modelNode.GetValue(name));
        }
示例#8
0
 protected virtual object GetNodeValueCore(IModelNode modelNode, string name)
 {
     return(modelNode.HasValue(name) ? modelNode.GetValue(name) : null);
 }
示例#9
0
 public bool IsReadOnly(IModelNode node, string propertyName)
 {
     return(node.GetValue <bool>(propertyName));
 }
        /// <summary>
        /// Refreshes the <see cref="ObservableNode"/> corresponding to the given <see cref="IModelNode"/>, if an <see cref="ObservableViewModel"/>
        /// is available in the current.<see cref="IViewModelServiceProvider"/>.
        /// </summary>
        /// <param name="modelNode">The model node to use to fetch a corresponding <see cref="ObservableNode"/>.</param>
        /// <param name="index">The index at which the actual value to update is stored.</param>
        protected virtual void Refresh(IModelNode modelNode, object index)
        {
            if (modelNode == null) throw new ArgumentNullException(nameof(modelNode));

            var observableNode = Service.ResolveObservableNode(Identifier, ObservableNodePath) as ObservableModelNode;
            // No node matches this model node
            if (observableNode == null)
                return;

            var newValue = modelNode.GetValue(index);

            observableNode.ForceSetValue(newValue);
            observableNode.Owner.NotifyNodeChanged(observableNode.Path);
        }