Exemple #1
0
        public bool Subscribe(NguiBaseBinding binding, NotifyPropertyChanged handler) {
            var context = binding.GetContext(Text);
            if (context == null) {
                return false;
            }

            var properties = new Dictionary<Type, Property>() {
                {typeof(bool), context.FindProperty<bool>(Text, binding)},
                {typeof(int), context.FindProperty<int>(Text, binding)},
                {typeof(float), context.FindProperty<float>(Text, binding)},
                {typeof(double), context.FindProperty<double>(Text, binding)}
            };
            var pair = properties.FirstOrDefault(x => x.Value != null);
            if (pair.Equals(default(KeyValuePair<Type, Property>))) {
                return false;
            }

            type = pair.Key;
            property = pair.Value;

            //Предотвращеие двойной подписи
            property.OnChange -= handler;
            property.OnChange += handler;

            return true;
        }
Exemple #2
0
    public EZData.Property <T> FindProperty <T>(string path, NguiBaseBinding binding)
    {
        if (_context == null)
        {
            return(null);
        }
        try
        {
            var context = _context as EZData.Context;
            if (context != null)
            {
                return(context.FindProperty <T>(binding.GetFullCleanPath(path), binding));
            }

            var mbContext = _context as EZData.MonoBehaviourContext;
            if (mbContext != null)
            {
                return(mbContext.FindProperty <T>(binding.GetFullCleanPath(path), binding));
            }

            Debug.LogWarning("Unsupported context implementation");
            return(null);
        }
        catch (Exception ex)
        {
            Debug.LogError("Failed to find property " + path + "\n" + ex);
            return(null);
        }
    }
Exemple #3
0
 public EZData.Collection FindCollection(string path, NguiBaseBinding binding)
 {
     if (_context == null)
     {
         return(null);
     }
     try
     {
         return(_context.FindCollection(binding.GetFullCleanPath(path), binding));
     }
     catch (Exception ex)
     {
         Debug.LogError("Failed to find collection " + path + "\n" + ex);
         return(null);
     }
 }
Exemple #4
0
 public System.Delegate FindCommand(string path, NguiBaseBinding binding)
 {
     if (_context == null)
     {
         return(null);
     }
     try
     {
         return(_context.FindCommand(binding.GetFullCleanPath(path), binding));
     }
     catch (Exception ex)
     {
         Debug.LogError("Failed to find command " + path + "\n" + ex);
         return(null);
     }
 }
Exemple #5
0
 public EZData.Property <int> FindEnumProperty(string path, NguiBaseBinding binding)
 {
     if (_context == null)
     {
         return(null);
     }
     try
     {
         return(_context.FindEnumProperty(binding.GetFullCleanPath(path), binding));
     }
     catch (Exception ex)
     {
         Debug.LogError("Failed to find enum property " + path + "\n" + ex);
         return(null);
     }
 }