Exemplo n.º 1
0
    public DataBindingConnection(BaseViewModel viewModel, DataBindInfo dataBindInfo)
    {
        this.dataBindInfo = dataBindInfo;
        this.viewModel    = viewModel;


        _getProperty = ReflectionTool.GetVmPropertyByName(viewModel.GetType(), dataBindInfo.propertyName);
        if (_getProperty == null)
        {
            Debug.LogErrorFormat("get property null {0}:{1}", viewModel.GetType(), dataBindInfo.propertyName);
        }

        ReflectionMethodItem item = ReflectionTool.GetComponentMethod(dataBindInfo.component.GetType(), dataBindInfo.invokeFunctionName, _getProperty.PropertyType);

        if (item == null)
        {
            Debug.LogErrorFormat("get invokeMethod null {0}", dataBindInfo.invokeFunctionName);
        }

        _invokeMethod = item.methodInfo;

        foreach (var bindingParameter in dataBindInfo.parameters)
        {
            _lstParameter.Add(new BindingParameterInfo(bindingParameter, viewModel));
        }

        ps    = new object[dataBindInfo.parameters.Length + 2];
        ps[0] = dataBindInfo.component;
    }
Exemplo n.º 2
0
 public BindingParameterInfo(BindingParameter paramter, BaseViewModel model)
 {
     this.model = model;
     if (paramter.dataFrom == DataFrom.VM)
     {
         propertyInfo = ReflectionTool.GetVmPropertyByName(model.GetType(), paramter.paramStr);
     }
     else
     {
         Type t = Type.GetType(paramter.paramType);
         constValue = Convert.ChangeType(paramter.paramStr, t);
     }
 }