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); }
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)); }
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); } } }
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); }
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")); } }
/// <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); }
public static object GetValue <T>(this IModelNode modelNode, Expression <Func <T, object> > property) { var name = typeof(T).GetMemberInfo(property).Name; return(modelNode.GetValue(name)); }
protected virtual object GetNodeValueCore(IModelNode modelNode, string name) { return(modelNode.HasValue(name) ? modelNode.GetValue(name) : null); }
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); }