Exemplo n.º 1
0
        public QpPlugin Read(int id)
        {
            var plugin = QpPluginRepository.GetById(id);

            if (plugin == null)
            {
                throw new ApplicationException(string.Format(QpPluginStrings.PluginNotFound, id));
            }
            return(plugin);
        }
Exemplo n.º 2
0
        public static QpPluginVersion GetMergedVersion(int[] ids, int parentId)
        {
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }
            if (ids.Length != 2)
            {
                throw new ArgumentException("Wrong ids length");
            }

            var parent = QpPluginRepository.GetById(parentId);

            if (parent == null)
            {
                throw new Exception(string.Format(QpPluginStrings.PluginNotFound, parentId));
            }

            var(item1, item2) = GetOrderedIds(ids);
            QpPluginVersion version1, version2;

            version1 = QpPluginVersionRepository.GetById(item1, parentId);
            if (version1 == null)
            {
                throw new Exception(string.Format(QpPluginStrings.PluginVersionNotFound, item1, parentId));
            }

            if (item2 == QpPluginVersion.CurrentVersionId)
            {
                version2    = CreateVersionFromPlugin(parent);
                version2.Id = QpPluginVersion.CurrentVersionId;
            }
            else
            {
                version2 = QpPluginVersionRepository.GetById(item2, parentId);
                if (version2 == null)
                {
                    throw new Exception(string.Format(QpPluginStrings.PluginVersionNotFound, item2, parentId));
                }
            }

            version1.MergeToVersion(version2);
            return(version1);
        }