Esempio n. 1
0
        private void AddIdentity(string name, string version, string hintPath)
        {
            if (name.IsNullOrEmpty())
            {
                throw new ArgumentNullException("name");
            }

            foreach (char c in name)
            {
                if (!char.IsLetterOrDigit(c) && c != '.' && c != '_')
                {
                    throw new Exception(PlugInConst.ManifestIdentity + " 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void ReadManifest(XmlReader reader, PlugIn plugIn)
        {
            if (reader.AttributeCount != 0)
            {
                throw new Exception(PlugInConst.Manifest + " node cannot have attributes.");
            }
            if (reader.IsEmptyElement)
            {
                throw new Exception(PlugInConst.Manifest + " node cannot be empty.");
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    string     nodeName   = reader.LocalName;
                    Properties properties = Properties.ReadFromAttributes(reader);
                    switch (nodeName)
                    {
                    case PlugInConst.ManifestIdentity:
                        AddIdentity(properties["name"], properties["version"], plugIn.PlugInDir);
                        break;

                    case PlugInConst.ManifestDependency:
                        Dependencies.Add(PlugInReference.Create(properties, plugIn.PlugInDir));
                        break;

                    case PlugInConst.ManifestConflict:
                        Conflicts.Add(PlugInReference.Create(properties, plugIn.PlugInDir));
                        break;

                    default:
                        throw new Exception("Unknown node in " + PlugInConst.Manifest + " section:" + nodeName + " plugIn:" + plugIn.PlugInFile);
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (reader.LocalName == PlugInConst.Manifest)
                    {
                        return;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 4
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);
                }
            }

            reference.RequirePreload = string.Equals(properties["requirePreload"], "true", StringComparison.OrdinalIgnoreCase);

            return(reference);
        }
Esempio n. 5
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);
                }
            }

            reference.RequirePreload = string.Equals(properties["requirePreload"], "true", StringComparison.OrdinalIgnoreCase);

            return reference;
        }