Exemplo n.º 1
0
        void AddIdentity(string name, string version, string hintPath)
        {
            if (name.Length == 0)
            {
                throw new PluginLoadException("Identity needs a name");
            }
            foreach (char c in name)
            {
                if (!char.IsLetterOrDigit(c) && c != '.' && c != '_')
                {
                    throw new PluginLoadException("Identity name contains invalid character: '" + c + "'");
                }
            }
            Version v = PluginReference.ParseVersion(version, hintPath);

            if (primaryVersion == null)
            {
                primaryVersion = v;
            }
            if (primaryIdentity == null)
            {
                primaryIdentity = name;
            }
            identities.Add(name, v);
        }
Exemplo n.º 2
0
        public static PluginReference Create(Properties properties, string hintPath)
        {
            PluginReference reference = new PluginReference(properties["addin"]);
            string          version   = properties["version"];

            if (version != null && version.Length > 0)
            {
                int pos = version.IndexOf('-');
                if (pos > 0)
                {
                    reference.minimumVersion = ParseVersion(version.Substring(0, pos), hintPath);
                    reference.maximumVersion = ParseVersion(version.Substring(pos + 1), hintPath);
                }
                else
                {
                    reference.maximumVersion = reference.minimumVersion = ParseVersion(version, hintPath);
                }

                if (reference.Name == "TickZoom")
                {
                    // HACK: SD 3.0 Plugins work with TickZoom 3.1
                    // Because some 3.0 Plugins restrict themselves to SD 3.0, we extend the
                    // supported SD range.
                    if (reference.maximumVersion == new Version("3.0") || reference.maximumVersion == new Version("3.1"))
                    {
                        reference.maximumVersion = new Version(entryVersion.Major + "." + entryVersion.Minor);
                    }
                }
            }
            reference.requirePreload = string.Equals(properties["requirePreload"], "true", StringComparison.OrdinalIgnoreCase);
            return(reference);
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (!(obj is PluginReference))
            {
                return(false);
            }
            PluginReference b = (PluginReference)obj;

            return(name == b.name && minimumVersion == b.minimumVersion && maximumVersion == b.maximumVersion);
        }
Exemplo n.º 4
0
        public void ReadManifestSection(XmlReader reader, string hintPath)
        {
            if (reader.AttributeCount != 0)
            {
                throw new PluginLoadException("Manifest node cannot have attributes.");
            }
            if (reader.IsEmptyElement)
            {
                throw new PluginLoadException("Manifest node cannot be empty.");
            }
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.EndElement:
                    if (reader.LocalName == "Manifest")
                    {
                        return;
                    }
                    break;

                case XmlNodeType.Element:
                    string     nodeName   = reader.LocalName;
                    Properties properties = Properties.ReadFromAttributes(reader);
                    switch (nodeName)
                    {
                    case "Identity":
                        AddIdentity(properties["name"], properties["version"], hintPath);
                        break;

                    case "Dependency":
                        dependencies.Add(PluginReference.Create(properties, hintPath));
                        break;

                    case "Conflict":
                        conflicts.Add(PluginReference.Create(properties, hintPath));
                        break;

                    default:
                        throw new PluginLoadException("Unknown node in Manifest section:" + nodeName);
                    }
                    break;
                }
            }
        }