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);
     }
 }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
예제 #11
0
 public new static bool CanCreate(MetadataObjectView view, string name) => view.VirtualProperties.Find(name) != null;
예제 #12
0
 internal MetadataVirtualPropertyList(MetadataObjectView objectView) => this.ObjectView = objectView;
 internal ObjectViewLoader(MetadataObjectView objectView)
     : base((string)null, (string)null)
     => this.ObjectView = objectView;
예제 #14
0
 public ObjectViewEvaluator(MetadataObjectView view, DataStorage storage)
 {
     this.FObjectView        = view;
     this.FStorage           = storage;
     this.FViewScriptRuntime = new ObjectViewScriptRuntime(storage.Session);
 }
예제 #15
0
 public new static bool CanCreate(MetadataObjectView view, string name) => string.Equals(name, "id", StringComparison.InvariantCultureIgnoreCase);
예제 #16
0
 public bool Contains(MetadataObjectView objectView) => this.FItems.Contains(objectView);
예제 #17
0
 internal void Add(MetadataObjectView item) => this.FItems.Add(item);
예제 #18
0
 public static ObjectViewParameterLoader TryCreate(
     MetadataObjectView view,
     string name)
 {
     return(ObjectViewIdLoader.CanCreate(view, name) ? (ObjectViewParameterLoader) new ObjectViewIdLoader() : (ObjectViewParameterLoader)null);
 }
예제 #19
0
 private string GetView(MetadataObjectView objectView) => this.FStorage.GetObjectViewEvaluator(objectView).GetObjectViewText(this);