internal void LoadObjectViews() { try { foreach (XmlNode selectNode in this.SourceNode.SelectNodes("object-view")) { MetadataObjectView metadataObjectView = new MetadataObjectView(this, selectNode, this.ObjectViews.Count); try { if (this.ObjectViews.Contains(metadataObjectView.Name)) { throw new MetadataException("Представление объекта уже определено."); } this.ObjectViews.Add(metadataObjectView); } catch (Exception ex) { throw new MetadataException(string.Format("Ошибка загрузки метаданных представления объекта {0}", (object)metadataObjectView.Name), ex); } } } catch (Exception ex) { throw new MetadataException(string.Format("Ошибка загрузки метаданных класса {0}", (object)this.Name), ex); } }
public static ObjectViewParameterLoader TryCreate( MetadataObjectView view, string name) { MetadataVirtualProperty metadataVirtualProperty = view.VirtualProperties.Find(name); if (metadataVirtualProperty == null) { return((ObjectViewParameterLoader)null); } MemberValueGetter memberValueGetter = metadataVirtualProperty.RefMemberType != MetadataClassMember.ObjectView ? (MemberValueGetter) new PropertyValueGetter(metadataVirtualProperty.RefMemberName) : (MemberValueGetter) new ObjectViewTextGetter(metadataVirtualProperty.RefMemberName); if (metadataVirtualProperty.SourceMember is MetadataAssociation sourceMember) { return((ObjectViewParameterLoader) new ObjectViewVirtualPropertyLoader(new Navigator[1] { (Navigator) new AssociationNavigator(sourceMember.Property.Name, (MetadataClass)null) }, memberValueGetter, ObjectViewVirtualPropertyLoader.ValueCardinality.Single)); } if (!(metadataVirtualProperty.SourceMember is MetadataChildRef sourceMember)) { return((ObjectViewParameterLoader) new ObjectViewVirtualPropertyLoader(Navigator.ParseNavigation(view.Class, metadataVirtualProperty.SourceNavigation), memberValueGetter, ObjectViewVirtualPropertyLoader.ValueCardinality.Multiple)); } return((ObjectViewParameterLoader) new ObjectViewVirtualPropertyLoader(new Navigator[1] { (Navigator) new ChildRefNavigator(sourceMember.ChildClass) }, memberValueGetter, ObjectViewVirtualPropertyLoader.ValueCardinality.Multiple)); }
public string GetViewHtml(string viewName) { if (this.IsNull) { return(string.Empty); } this.CheckNotError(); MetadataObjectView metadataObjectView = this.GetMetadataObjectView(viewName); string view = this.GetView(metadataObjectView); return(metadataObjectView.ContentType == ContentType.Text ? HttpUtility.HtmlEncode(view) : view); }
public void EnsureObjectView(string viewName, DataSession session) { if (StrUtils.IsNullOrEmpty(viewName)) { viewName = "default"; } MetadataObjectView metadataObjectView = this.Class.ObjectViews.Need(viewName); if (!this.Views.Contains(metadataObjectView)) { this.Views.Add(metadataObjectView); } this.MergeWith(session[this.Class].GetObjectViewEvaluator(metadataObjectView).GetLoadPlan(session)); }
internal ObjectViewLoader EnsureObjectViewLoader(MetadataObjectView objectView) { for (int index = 0; index < this.ObjectViewLoaders.Count; ++index) { ObjectViewLoader objectViewLoader = this.ObjectViewLoaders[index]; if (objectViewLoader.ObjectView == objectView) { return(objectViewLoader); } } ObjectViewLoader objectViewLoader1 = new ObjectViewLoader(objectView); this.ObjectViewLoaders.Add(objectViewLoader1); return(objectViewLoader1); }
internal ObjectViewEvaluator GetObjectViewEvaluator( MetadataObjectView viewMetadata) { if (this.FObjectViewEvaluators == null) { this.FObjectViewEvaluators = new ObjectViewEvaluator[this.Class.ObjectViews.Count]; } ObjectViewEvaluator objectViewEvaluator = this.FObjectViewEvaluators[viewMetadata.Index]; if (objectViewEvaluator == null) { objectViewEvaluator = new ObjectViewEvaluator(viewMetadata, this); this.FObjectViewEvaluators[viewMetadata.Index] = objectViewEvaluator; } return(objectViewEvaluator); }
public static ObjectViewParameterLoader Create( MetadataObjectView view, string name) { ObjectViewParameterLoader viewParameterLoader1 = ObjectViewIdLoader.TryCreate(view, name); if (viewParameterLoader1 != null) { return(viewParameterLoader1); } ObjectViewParameterLoader viewParameterLoader2 = ObjectViewPropertyLoader.TryCreate(view, name); if (viewParameterLoader2 != null) { return(viewParameterLoader2); } return(ObjectViewVirtualPropertyLoader.TryCreate(view, name) ?? throw new Exception("Невозможно создать загрузчик значения параметра для \"" + name + "\"")); }
internal MetadataVirtualProperty(MetadataObjectView view, XmlNode sourceNode) { this.View = view; this.SourceNode = sourceNode; this.Name = XmlUtils.NeedAttr(sourceNode, "name"); string str; switch (MetadataVirtualProperty.GetOneOf(sourceNode, "association", "aggregation", "navigation", out str)) { case 1: this.SourceMember = (object)view.Class.Associations.Need(str); break; case 2: this.SourceMember = (object)view.Class.Childs.Need(str); break; case 3: this.SourceNavigation = XmlUtils.GetAttr(sourceNode, "navigation", (string)null); break; default: throw new MetadataException(string.Format("Не заданы атрибуты \"association\" или \"aggregation\" или \"navigation\" ({0})", (object)this)); } switch (MetadataVirtualProperty.GetOneOf(sourceNode, "ref-property", "ref-view", (string)null, out this.RefMemberName)) { case 1: this.RefMemberType = MetadataClassMember.Property; break; case 2: this.RefMemberType = MetadataClassMember.ObjectView; break; default: this.RefMemberType = MetadataClassMember.ObjectView; this.RefMemberName = "default"; break; } }
internal void LoadVirtualProperties() { try { for (int index = 0; index < this.ObjectViews.Count; ++index) { MetadataObjectView objectView = this.ObjectViews[index]; try { objectView.LoadVirtualProperties(); } catch (Exception ex) { throw new MetadataException(string.Format("Ошибка загрузки метаданных представления объекта {0}", (object)objectView.Name), ex); } } } catch (Exception ex) { throw new MetadataException(string.Format("Ошибка загрузки метаданных класса {0}", (object)this.Name), ex); } }
public static bool CanCreate(MetadataObjectView view, string name) => ObjectViewIdLoader.CanCreate(view, name) || ObjectViewPropertyLoader.CanCreate(view, name) || ObjectViewVirtualPropertyLoader.CanCreate(view, name);
public new static bool CanCreate(MetadataObjectView view, string name) => view.VirtualProperties.Find(name) != null;
internal MetadataVirtualPropertyList(MetadataObjectView objectView) => this.ObjectView = objectView;
internal ObjectViewLoader(MetadataObjectView objectView) : base((string)null, (string)null) => this.ObjectView = objectView;
public ObjectViewEvaluator(MetadataObjectView view, DataStorage storage) { this.FObjectView = view; this.FStorage = storage; this.FViewScriptRuntime = new ObjectViewScriptRuntime(storage.Session); }
public new static bool CanCreate(MetadataObjectView view, string name) => string.Equals(name, "id", StringComparison.InvariantCultureIgnoreCase);
public bool Contains(MetadataObjectView objectView) => this.FItems.Contains(objectView);
internal void Add(MetadataObjectView item) => this.FItems.Add(item);
public static ObjectViewParameterLoader TryCreate( MetadataObjectView view, string name) { return(ObjectViewIdLoader.CanCreate(view, name) ? (ObjectViewParameterLoader) new ObjectViewIdLoader() : (ObjectViewParameterLoader)null); }
private string GetView(MetadataObjectView objectView) => this.FStorage.GetObjectViewEvaluator(objectView).GetObjectViewText(this);