コード例 #1
0
 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);
        }
コード例 #7
0
        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 + "\""));
        }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
 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;
コード例 #13
0
 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);