public static XElement ObjToXElement(PObject obj) { XElement x = new XElement("obj"); XElement xAttrs = new XElement("attrs"); foreach (string attr in obj._attrs.Keys) { xAttrs.SetElementValue(attr, obj._attrs[attr]); } x.Add(xAttrs); XElement xColls = new XElement("colls"); x.Add(xColls); foreach (PCollection coll in obj._collections.Values) { XElement xColl = new XElement("coll"); xColl.SetAttributeValue("name", coll.Name); xColls.Add(xColl); int cnt = coll.Count; for (int i = 0; i < cnt; i++) { XElement xi = ObjToXElement(coll._items[i]); xi.SetAttributeValue("num", i); xColl.Add(xi); } } return x; }
public PModel(IStorage rep, string model, bool deferredLoad) { this.objectsIndex = new Dictionary<int,IPObject>(); int objectId = rep.RootObjectId(model, -1); if (objectId == -1) throw new Exception(string.Format("Модель с кодом \"{0}\" не найдена", model)); Root = new PObject(rep, objectId, objectsIndex, deferredLoad); _storage = rep; }
internal PCollection(PObject owner, string name, bool deferredLoad) { _items = new List<PObject>(); OwnerObject = owner; Name = name; _loaded = false; _deferredLoad = deferredLoad; if (!deferredLoad) { this.FillWithObjects(deferredLoad); } }
internal PObject InsertObject(PObject obj) { _items.Add(obj); obj._ownerCollection = this; return obj; }