示例#1
0
 public bool HasChanged(AddinFileSystemExtension fs, string md5)
 {
     if (md5 != null && ScanDataMD5 != null)
     {
         return(md5 != ScanDataMD5);
     }
     return(fs.GetLastWriteTime(File) != LastScan);
 }
示例#2
0
        public List <AddinFileInfo> GetMissingAddins(AddinFileSystemExtension fs)
        {
            var missing = new List <AddinFileInfo> ();

            if (!fs.DirectoryExists(folder))
            {
                // All deleted
                foreach (AddinFileInfo info in files.Values)
                {
                    if (info.IsAddin)
                    {
                        missing.Add(info);
                    }
                }
                files.Clear();
                return(missing);
            }
            ArrayList toDelete = new ArrayList();

            foreach (AddinFileInfo info in files.Values)
            {
                if (!fs.FileExists(info.File))
                {
                    if (info.IsAddin)
                    {
                        missing.Add(info);
                    }
                    toDelete.Add(info.File);
                }
                else if (info.IsAddin && info.Domain != GetDomain(info.IsRoot))
                {
                    missing.Add(info);
                }
            }
            foreach (string file in toDelete)
            {
                files.Remove(file);
            }

            return(missing);
        }
示例#3
0
 public AddinScanner(AddinDatabase database, AddinScanResult scanResult, IProgressStatus monitor)
 {
     this.database = database;
     fs = database.FileSystem;
 }
示例#4
0
 public void UnregisterExtension(object extension)
 {
     extensions.Remove (extension);
     if ((extension as AddinFileSystemExtension) == fs)
         fs = new AddinFileSystemExtension ();
     else
         throw new InvalidOperationException ();
 }
示例#5
0
 public void RegisterExtension(object extension)
 {
     extensions.Add (extension);
     if (extension is AddinFileSystemExtension)
         fs = (AddinFileSystemExtension) extension;
     else
         throw new NotSupportedException ();
 }
示例#6
0
        internal StringCollection Verify(AddinFileSystemExtension fs)
        {
            StringCollection errors = new StringCollection ();

            if (IsRoot) {
                if (OptionalModules.Count > 0)
                    errors.Add ("Root add-in hosts can't have optional modules.");
            }

            if (AddinId.Length == 0 || Version.Length == 0) {
                if (ExtensionPoints.Count > 0)
                    errors.Add ("Add-ins which define new extension points must have an Id and Version.");
            }

            MainModule.Verify ("", errors);
            OptionalModules.Verify ("", errors);
            ExtensionNodeSets.Verify ("", errors);
            ExtensionPoints.Verify ("", errors);
            ConditionTypes.Verify ("", errors);

            foreach (ExtensionNodeSet nset in ExtensionNodeSets) {
                if (nset.Id.Length == 0)
                    errors.Add ("Attribute 'id' can't be empty for global node sets.");
            }

            string bp = null;
            if (BasePath.Length > 0)
                bp = BasePath;
            else if (sourceAddinFile != null && sourceAddinFile.Length > 0)
                bp = Path.GetDirectoryName (AddinFile);
            else if (configFile != null && configFile.Length > 0)
                bp = Path.GetDirectoryName (configFile);

            if (bp != null) {
                foreach (string file in AllFiles) {
                    string asmFile = Path.Combine (bp, file);
                    if (!fs.FileExists (asmFile))
                        errors.Add ("The file '" + asmFile + "' referenced in the manifest could not be found.");
                }
            }

            if (localizer != null && localizer.GetAttribute ("type").Length == 0) {
                errors.Add ("The attribute 'type' in the Location element is required.");
            }

            // Ensure that there are no duplicated properties

            if (properties != null) {
                HashSet<string> props = new HashSet<string> ();
                foreach (var prop in properties) {
                    if (!props.Add (prop.Name + " " + prop.Locale))
                        errors.Add (string.Format ("Property {0} specified more than once", prop.Name + (prop.Locale != null ? " (" + prop.Locale + ")" : "")));
                }
            }

            return errors;
        }
		public ArrayList GetMissingAddins (AddinFileSystemExtension fs)
		{
			ArrayList missing = new ArrayList ();
			
			if (!fs.DirectoryExists (folder)) {
				// All deleted
				foreach (AddinFileInfo info in files.Values) {
					if (info.IsAddin)
						missing.Add (info);
				}
				files.Clear ();
				return missing;
			}
			ArrayList toDelete = new ArrayList ();
			foreach (AddinFileInfo info in files.Values) {
				if (!fs.FileExists (info.File)) {
					if (info.IsAddin)
						missing.Add (info);
					toDelete.Add (info.File);
				}
				else if (info.IsAddin && info.Domain != GetDomain (info.IsRoot)) {
					missing.Add (info);
				}
			}
			foreach (string file in toDelete)
				files.Remove (file);
				
			return missing;
		}