Esempio n. 1
0
        private void UpdateType(JSC.JSValue type, JSC.JSValue val)
        {
            _value = val;

            #region Trace

            /*{
             * StringBuilder sb = new StringBuilder();
             * sb.Append(this.ToString());
             * sb.Append(" $UpdateType( m{");
             * if(type == null) {
             *  sb.Append("null");
             * } else {
             *  foreach(var kv in type) {
             *    sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString());
             *  }
             *  sb.Append("}");
             *  if(type.__proto__.ValueType == JSC.JSValueType.Object && type.__proto__.Any()) {
             *    sb.Append(" mp{");
             *    foreach(var kv in type.__proto__) {
             *      sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString());
             *    }
             *    sb.Append("}");
             *  }
             * }
             * if(val!=null && val.ValueType == JSC.JSValueType.Object) {
             *  sb.Append(", s{");
             *  foreach(var kv in val) {
             *    sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString());
             *  }
             *  sb.Append("}");
             *  if(val.__proto__.ValueType == JSC.JSValueType.Object && val.__proto__.Any()) {
             *    sb.Append(" proto{");
             *    foreach(var kv in val.__proto__) {
             *      sb.AppendFormat("{0}:{1},", kv.Key, kv.Value.ValueType == JSC.JSValueType.Object ? "Object" : kv.Value.ToString());
             *    }
             *    sb.Append("}");
             *  }
             * } else {
             *  sb.Append(", s=" + JSL.JsLib.Stringify(_value, null, null));
             * }
             * sb.Append(")");
             * Log.Debug("{0}", sb.ToString());
             * }*/
            #endregion Trace

            bool o_hc = _items.Any();
            base.UpdateType(type);
            base.editor.ValueChanged(_value);

            if (_value.ValueType == JSC.JSValueType.Object)
            {
                InManifest  vc;
                int         i;
                JSC.JSValue cs, cs_mi, cs_p;
                foreach (var kv in _value.OrderBy(z => z.Key))
                {
                    if (_manifest == null || _manifest.ValueType != JSC.JSValueType.Object || _manifest.Value == null || (cs_mi = _manifest["mi"]).ValueType != JSC.JSValueType.Object || cs_mi.Value == null || (cs = cs_mi[kv.Key]).ValueType != JSC.JSValueType.Object || cs.Value == null)
                    {
                        cs = JSC.JSObject.CreateObject();
                    }
                    if ((cs_mi = (IsGroupHeader ? _value : _manifest)["mi"]).ValueType == JSC.JSValueType.Object && cs_mi.Value != null)
                    {
                        if ((cs_p = cs_mi[kv.Key]).ValueType == JSC.JSValueType.Object && cs_p.Value != null && cs != cs_p)
                        {
                            if (cs["mi"].ValueType == JSC.JSValueType.Object)
                            {
                                cs["mi"].__proto__ = cs_p["mi"].ToObject();
                            }
                            cs.__proto__ = cs_p.ToObject();
                        }
                    }
                    vc = _items.OfType <InManifest>().FirstOrDefault(z => z.name == kv.Key);
                    if (vc != null)
                    {
                        vc.UpdateType(cs, kv.Value);
                    }
                    else
                    {
                        var ni = new InManifest(this, kv.Key, kv.Value, cs);
                        for (i = _items.Count - 1; i >= 0; i--)
                        {
                            if (string.Compare(_items[i].name, kv.Key) < 0)
                            {
                                break;
                            }
                        }
                        _items.Insert(i + 1, ni);
                        if (_isVisible && _isExpanded)
                        {
                            _collFunc(ni, true);
                        }
                    }
                }
                var keys = _value.Select(z => z.Key).ToArray();
                for (i = _items.Count - 1; i >= 0; i--)
                {
                    if (!keys.Contains(_items[i].name))
                    {
                        if (_isVisible && _isExpanded)
                        {
                            _items[i].Deleted();
                        }
                        _items.RemoveAt(i);
                    }
                }
            }
            if (o_hc != _items.Any())
            {
                if (o_hc) // now has now children
                {
                    IsExpanded = false;
                }
                PropertyChangedReise("HasChildren");
            }
        }
Esempio n. 2
0
 private void UpdateData(JSC.JSValue val) {
   _value = val;
   if(_value.ValueType == JSC.JSValueType.Object) {
     InValue vc;
     int i;
     foreach(var kv in _value.OrderBy(z => z.Key)) {
       vc = _items.OfType<InValue>().FirstOrDefault(z => z.name == kv.Key);
       if(vc != null) {
         vc.UpdateData(kv.Value);
       } else {
         for(i = _items.Count - 1; i >= 0; i--) {
           if(string.Compare(_items[i].name, kv.Key) < 0) {
             break;
           }
         }
         JSC.JSValue cs;
         {
           JSC.JSValue pr;
           if(_schema == null || (pr = _schema["Properties"] as JSC.JSValue).ValueType != JSC.JSValueType.Object || (cs = pr[kv.Key]).ValueType != JSC.JSValueType.Object) {
             cs = null;
           }
         }
         var ni= new InValue(_data, this, kv.Key, kv.Value, cs, _collFunc);
         _items.Insert(i + 1, ni);
         if(_isVisible && _isExpanded) {
           _collFunc(ni, true);
         }
       }
     }
     var keys = _value.Select(z => z.Key).ToArray();
     for(i = _items.Count - 1; i >= 0; i--) {
       if(!keys.Contains(_items[i].name)) {
         if(_isVisible && _isExpanded) {
           _items[i].Deleted();
         }
         _items.RemoveAt(i);
       }
     }
   }
   if(editor == null) {
     editor = InspectorForm.GetEdititor(_view, this, _schema);
     PropertyChangedReise("editor");
   } else {
     editor.ValueChanged(_value);
   }
 }
Esempio n. 3
0
        private void UpdateData(JSC.JSValue val)
        {
            bool o_hc = HasChildren;

            _value = val;
            if (_value.ValueType == JSC.JSValueType.Object)
            {
                InValue vc;
                int     i;
                foreach (var kv in _value.OrderBy(z => z.Key))
                {
                    vc = _items.OfType <InValue>().FirstOrDefault(z => z.name == kv.Key);
                    if (vc != null)
                    {
                        vc.UpdateData(kv.Value);
                    }
                    else
                    {
                        for (i = _items.Count - 1; i >= 0; i--)
                        {
                            if (string.Compare(_items[i].name, kv.Key) < 0)
                            {
                                break;
                            }
                        }
                        JSC.JSValue cs;
                        {
                            JSC.JSValue pr;
                            if (_manifest == null || (pr = _manifest["Fields"]).ValueType != JSC.JSValueType.Object || (cs = pr[kv.Key]).ValueType != JSC.JSValueType.Object)
                            {
                                cs = null;
                            }
                        }
                        var ni = new InValue(_data, this, kv.Key, kv.Value, cs, _collFunc);
                        _items.Insert(i + 1, ni);
                        if (_isVisible && _isExpanded)
                        {
                            _collFunc(ni, true);
                        }
                    }
                }
                var keys = _value.Select(z => z.Key).ToArray();
                for (i = _items.Count - 1; i >= 0; i--)
                {
                    if (!keys.Contains(_items[i].name))
                    {
                        if (_isVisible && _isExpanded)
                        {
                            _items[i].Deleted();
                        }
                        _items.RemoveAt(i);
                    }
                }
            }
            if (editor == null)
            {
                editor = InspectorForm.GetEditor(_editorName, this, _manifest);
                PropertyChangedReise("editor");
            }
            else
            {
                editor.ValueChanged(_value);
            }
            if (o_hc != this.HasChildren)
            {
                PropertyChangedReise("HasChildren");
            }
        }