예제 #1
0
 public void SetObject(RBaseObject obj)
 {
     this._current = obj;
     foreach (RModelObjectNavigatorPathLevel level in _levels)
     {
         level.Index = 0;
     }
     if (this._current == null)
     {
         this.Pointer = null;
     }
     else
     {
         _updatePointer();
     }
     _enableControls((this._current != null));
 }
예제 #2
0
        public string TransformText(string templateName, RBaseObject obj, ref string path, bool addPath)
        {
            string template = "";

            if (!_items.TryGetValue(templateName.ToLower(), out template))
            {
                template = NotFoundMarks.collections.Begin + templateName + NotFoundMarks.collections.End;
            }
            else
            {
                List<RTemplateAttr> attrs;
                List<RTemplateCollection> fcollects;

                _parse(template, out attrs, out fcollects);

                template = template.Replace("%id%", obj.Id.ToString());
                foreach (var attr in attrs)
                {
                    string val = "";
                    if (!obj.GetAttr(attr.Name, out val))
                        val = NotFoundMarks.attrs.Begin + attr.Name + NotFoundMarks.attrs.End;
                    template = template.Replace(attr.OperatorText, val);
                }

                foreach (var fcollect in fcollects)
                {
                    RCollection coll = obj.GetCollection(fcollect.collectionName, false);
                    if (coll != null)
                    {
                        string val = "";
                        for (int ii = 0; ii < coll.Count(); ii++)
                        {
                            //val += this.PreScript + TransformText(fcollect.templateName, coll.GetObject(ii)) + this.PostStript;

                            RBaseObject cobj =  coll.GetObject(ii);
                            bool addNext = (addPath && fcollect.navigatorLevelText != "");
                            if (addNext)
                            {
                                path += ((path != "")?"/":"") + fcollect.collectionName + ":" + fcollect.navigatorLevelText;
                                addPath = false;
                            }
                            val += this.TransformText(fcollect.templateName, cobj, ref path, addNext);

                        }
                        template = template.Replace(fcollect.OperatorText, val);
                    }
                }
            }

            return template;
        }
예제 #3
0
 public void SetObject(RBaseObject  obj)
 {
     _object = obj;
 }
예제 #4
0
 private void _updatePointer()
 {
     if (this._current == null)
         throw new Exception("Текущий объект не задан");
     RBaseObject o = this._current;
     foreach (RModelObjectNavigatorPathLevel lvl in _levels)
     {
         RCollection coll = o.GetCollection(lvl.CollectionName, false);
         if (coll == null)
         {
             throw new Exception("Указанная в конфигурации коллекция '" + lvl.CollectionName + "' не описана в переданном объекте");
         }
         else
         {
             int index = lvl.Index;
             if (index < 0)
             {
                 index = coll.Count() - 1;
                 lvl.Index = index;
             }
             o = coll.GetObject(index);
             if (o != null)
             {
                 this.Pointer = o;
             }
             else
             {
                 break;
             }
         }
     }
     OnNavigated(this, this.Pointer);
 }