示例#1
0
 public static bool CheckPluginDependency(PluginDependencyItem dep)
 {
   XmlSerializer xs = new XmlSerializer(typeof(PluginDependencyItem));
   String XmlizedString = null;
   MemoryStream memoryStream = new MemoryStream();
   using (XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII))
   {
     xs.Serialize(xmlTextWriter, dep);
     memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
   }
   XmlizedString = ByteArrayToString(Encoding.ASCII, memoryStream.ToArray());
   XmlDocument doc = new XmlDocument();
   doc.LoadXml(XmlizedString);
   return MediaPortal.Common.Utils.CompatibilityManager.IsPluginCompatible(doc.DocumentElement);
 }
示例#2
0
        public void SetPluginsDependencies()
        {
            PluginDependencies.Items.Clear();
            List <string> providedPlugins = new List <string>();

            System.Globalization.CultureInfo invariantCulture = System.Globalization.CultureInfo.InvariantCulture;
            foreach (FileItem file in UniqueFileList.Items)
            {
                if (file.DestinationFilename.StartsWith("%" + MediaPortal.Configuration.Config.Dir.Plugins + "%", true, invariantCulture) &&
                    file.DestinationFilename.EndsWith(".dll", true, invariantCulture))
                {
                    string asm          = file.LocalFileName;
                    string assemblyPath = asm;
                    if (!Path.IsPathRooted(asm))
                    {
                        assemblyPath = Path.Combine(Path.GetDirectoryName(ProjectSettings.ProjectFilename), assemblyPath);
                        assemblyPath = Path.GetFullPath(assemblyPath);
                    }
                    if (Util.IsPlugin(assemblyPath))
                    {
                        providedPlugins.Add(asm);
                    }
                }
            }
            foreach (string asm in providedPlugins)
            {
                PluginDependencyItem dep = new PluginDependencyItem();
                dep.AssemblyName = Path.GetFileName(asm);
                string assemblyPath = asm;
                if (!Path.IsPathRooted(asm))
                {
                    assemblyPath = Path.Combine(Path.GetDirectoryName(ProjectSettings.ProjectFilename), assemblyPath);
                    assemblyPath = Path.GetFullPath(assemblyPath);
                }
                if (dep.ScanVersionInfo(assemblyPath))
                {
                    PluginDependencies.Add(dep);
                }
            }
        }