当前位置: 首页>>代码示例>>C#>>正文


C# IProgressStatus.Log方法代码示例

本文整理汇总了C#中IProgressStatus.Log方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressStatus.Log方法的具体用法?C# IProgressStatus.Log怎么用?C# IProgressStatus.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgressStatus的用法示例。


在下文中一共展示了IProgressStatus.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddinScanner

        public AddinScanner(AddinDatabase database, AddinScanResult scanResult, IProgressStatus monitor)
        {
            this.database = database;
            if (!scanResult.CheckOnly) {

                // If there is a local copy of the cecil reflector, use it instead of the one in the gac
                Type t;
                string asmFile = Path.Combine (Path.GetDirectoryName (GetType().Assembly.Location), "Mono.Addins.CecilReflector.dll");
                if (File.Exists (asmFile)) {
                    Assembly asm = Assembly.LoadFrom (asmFile);
                    t = asm.GetType ("Mono.Addins.CecilReflector.Reflector");
                }
                else {
                    string refName = GetType().Assembly.FullName;
                    int i = refName.IndexOf (',');
                    refName = "Mono.Addins.CecilReflector.Reflector, Mono.Addins.CecilReflector" + refName.Substring (i);
                    t = Type.GetType (refName, false);
                }
                if (t != null)
                    reflector = (IAssemblyReflector) Activator.CreateInstance (t);
                else
                    reflector = new DefaultAssemblyReflector ();

                if (monitor.LogLevel > 1)
                    monitor.Log ("Using assembly reflector: " + reflector.GetType ());
                reflector.Initialize (scanResult);
                coreAssembly = reflector.LoadAssembly (GetType().Assembly.Location);
            }
        }
开发者ID:NALSS,项目名称:Telegraph,代码行数:29,代码来源:AddinScanner.cs

示例2: ScanSingleFile

        public AddinDescription ScanSingleFile(IProgressStatus monitor, string file, AddinScanResult scanResult)
        {
            AddinDescription config = null;

            if (monitor.LogLevel > 1)
                monitor.Log ("Scanning file: " + file);

            monitor.Log ("plog:scan:" + file);

            try {
                string ext = Path.GetExtension (file).ToLower ();
                bool scanSuccessful;

                if (ext == ".dll" || ext == ".exe")
                    scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
                else
                    scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);

                if (scanSuccessful && config != null) {

                    config.Domain = "global";
                    if (config.Version.Length == 0)
                        config.Version = "0.0.0.0";

                    if (config.LocalId.Length == 0) {
                        // Generate an internal id for this add-in
                        config.LocalId = database.GetUniqueAddinId (file, "", config.Namespace, config.Version);
                    }
                }
            }
            catch (Exception ex) {
                monitor.ReportError ("Unexpected error while scanning file: " + file, ex);
            } finally {
                monitor.Log ("plog:endscan");
            }
            return config;
        }
开发者ID:JamesChan,项目名称:mono-addins,代码行数:37,代码来源:AddinScanner.cs

示例3: ScanFolder

        public void ScanFolder(IProgressStatus monitor, string path, string domain, AddinScanResult scanResult)
        {
            path = Path.GetFullPath (path);

            // Avoid folders including each other
            if (!scanResult.VisitFolder (path))
                return;

            AddinScanFolderInfo folderInfo;
            if (!database.GetFolderInfoForPath (monitor, path, out folderInfo)) {
                // folderInfo file was corrupt.
                // Just in case, we are going to regenerate all relation data.
                if (!fs.DirectoryExists (path))
                    scanResult.RegenerateRelationData = true;
            } else {
                // Directory is included but it doesn't exist. Ignore it.
                if (folderInfo == null && !fs.DirectoryExists (path))
                    return;
            }

            // if domain is null it means that a new domain has to be created.

            bool sharedFolder = domain == AddinDatabase.GlobalDomain;
            bool isNewFolder = folderInfo == null;

            if (isNewFolder) {
                // No folder info. It is the first time this folder is scanned.
                // There is no need to store this object if the folder does not
                // contain add-ins.
                folderInfo = new AddinScanFolderInfo (path);
            }

            if (!sharedFolder && (folderInfo.SharedFolder || folderInfo.Domain != domain)) {
                // If the folder already has a domain, reuse it
                if (domain == null && folderInfo.RootsDomain != null && folderInfo.RootsDomain != AddinDatabase.GlobalDomain)
                    domain = folderInfo.RootsDomain;
                else if (domain == null) {
                    folderInfo.Domain = domain = database.GetUniqueDomainId ();
                    scanResult.RegenerateRelationData = true;
                }
                else {
                    folderInfo.Domain = domain;
                    if (!isNewFolder) {
                        // Domain has changed. Update the folder info and regenerate everything.
                        scanResult.RegenerateRelationData = true;
                        scanResult.RegisterModifiedFolderInfo (folderInfo);
                    }
                }
            }
            else if (!folderInfo.SharedFolder && sharedFolder) {
                scanResult.RegenerateRelationData = true;
            }

            folderInfo.SharedFolder = sharedFolder;

            // If there is no domain assigned to the host, get one now
            if (scanResult.Domain == AddinDatabase.UnknownDomain)
                scanResult.Domain = domain;

            // Discard folders not belonging to the required domain
            if (scanResult.Domain != null && domain != scanResult.Domain && domain != AddinDatabase.GlobalDomain) {
                return;
            }

            if (monitor.LogLevel > 1 && !scanResult.LocateAssembliesOnly)
                monitor.Log ("Checking: " + path);

            if (fs.DirectoryExists (path))
            {
                IEnumerable<string> files = fs.GetFiles (path);

                // First of all, look for .addin files. Addin files must be processed before
                // assemblies, because they may add files to the ignore list (i.e., assemblies
                // included in .addin files won't be scanned twice).
                foreach (string file in files) {
                    if (file.EndsWith (".addin.xml") || file.EndsWith (".addin")) {
                        RegisterFileToScan (monitor, file, scanResult, folderInfo);
                    }
                }

                // Now scan assemblies. They can also add files to the ignore list.

                foreach (string file in files) {
                    string ext = Path.GetExtension (file).ToLower ();
                    if (ext == ".dll" || ext == ".exe") {
                        RegisterFileToScan (monitor, file, scanResult, folderInfo);
                        scanResult.AddAssemblyLocation (file);
                    }
                }

                // Finally scan .addins files

                foreach (string file in files) {
                    if (Path.GetExtension (file).EndsWith (".addins")) {
                        ScanAddinsFile (monitor, file, domain, scanResult);
                    }
                }
            }
            else if (!scanResult.LocateAssembliesOnly) {
                // The folder has been deleted. All add-ins defined in that folder should also be deleted.
//.........这里部分代码省略.........
开发者ID:JamesChan,项目名称:mono-addins,代码行数:101,代码来源:AddinScanner.cs

示例4: ScanFile

        public void ScanFile(IProgressStatus monitor, string file, AddinScanFolderInfo folderInfo, AddinScanResult scanResult)
        {
            if (scanResult.IgnorePath (file)) {
                // The file must be ignored. Maybe it caused a crash in a previous scan, or it
                // might be included by a .addin file (in which case it will be scanned when processing
                // the .addin file).
                folderInfo.SetLastScanTime (file, null, false, fs.GetLastWriteTime (file), true);
                return;
            }

            if (monitor.LogLevel > 1)
                monitor.Log ("Scanning file: " + file);

            // Log the file to be scanned, so in case of a process crash the main process
            // will know what crashed
            monitor.Log ("plog:scan:" + file);

            string scannedAddinId = null;
            bool scannedIsRoot = false;
            bool scanSuccessful = false;
            AddinDescription config = null;

            try {
                string ext = Path.GetExtension (file).ToLower ();

                if (ext == ".dll" || ext == ".exe")
                    scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
                else
                    scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);

                if (config != null) {

                    AddinFileInfo fi = folderInfo.GetAddinFileInfo (file);

                    // If version is not specified, make up one
                    if (config.Version.Length == 0) {
                        config.Version = "0.0.0.0";
                    }

                    if (config.LocalId.Length == 0) {
                        // Generate an internal id for this add-in
                        config.LocalId = database.GetUniqueAddinId (file, (fi != null ? fi.AddinId : null), config.Namespace, config.Version);
                        config.HasUserId = false;
                    }

                    // Check errors in the description
                    StringCollection errors = config.Verify (fs);

                    if (database.IsGlobalRegistry && config.AddinId.IndexOf ('.') == -1) {
                        errors.Add ("Add-ins registered in the global registry must have a namespace.");
                    }

                    if (errors.Count > 0) {
                        scanSuccessful = false;
                        monitor.ReportError ("Errors found in add-in '" + file + ":", null);
                        foreach (string err in errors)
                            monitor.ReportError (err, null);
                    }

                    // Make sure all extensions sets are initialized with the correct add-in id

                    config.SetExtensionsAddinId (config.AddinId);

                    scanResult.ChangesFound = true;

                    // If the add-in already existed, try to reuse the relation data it had.
                    // Also, the dependencies of the old add-in need to be re-analized

                    AddinDescription existingDescription = null;
                    bool res = database.GetAddinDescription (monitor, folderInfo.Domain, config.AddinId, config.AddinFile, out existingDescription);

                    // If we can't get information about the old assembly, just regenerate all relation data
                    if (!res)
                        scanResult.RegenerateRelationData = true;

                    string replaceFileName = null;

                    if (existingDescription != null) {
                        // Reuse old relation data
                        config.MergeExternalData (existingDescription);
                        Util.AddDependencies (existingDescription, scanResult);
                        replaceFileName = existingDescription.FileName;
                    }

                    // If the scanned file results in an add-in version different from the one obtained from
                    // previous scans, the old add-in needs to be uninstalled.
                    if (fi != null && fi.IsAddin && fi.AddinId != config.AddinId) {
                        database.UninstallAddin (monitor, folderInfo.Domain, fi.AddinId, fi.File, scanResult);

                        // If the add-in version has changed, regenerate everything again since old data can't be reused
                        if (Addin.GetIdName (fi.AddinId) == Addin.GetIdName (config.AddinId))
                            scanResult.RegenerateRelationData = true;
                    }

                    // If a description could be generated, save it now (if the scan was successful)
                    if (scanSuccessful) {

                        // Assign the domain
                        if (config.IsRoot) {
                            if (folderInfo.RootsDomain == null) {
//.........这里部分代码省略.........
开发者ID:JamesChan,项目名称:mono-addins,代码行数:101,代码来源:AddinScanner.cs

示例5: SafeDeleteDir

 public bool SafeDeleteDir(IProgressStatus monitor, string dir)
 {
     try {
         fileDatabase.DeleteDir (dir);
         return true;
     }
     catch (Exception ex) {
         if (monitor.LogLevel > 1) {
             monitor.Log ("Could not delete directory: " + dir);
             monitor.Log (ex.ToString ());
         }
         return false;
     }
 }
开发者ID:mono,项目名称:mono-addins,代码行数:14,代码来源:AddinDatabase.cs

示例6: GenerateAddinExtensionMapsInternal

		void GenerateAddinExtensionMapsInternal (IProgressStatus monitor, ArrayList addinsToUpdate, ArrayList removedAddins)
		{
			AddinUpdateData updateData = new AddinUpdateData (this, monitor);
			
			// Clear cached data
			cachedAddinSetupInfos.Clear ();
			
			// Collect all information
			
			AddinIndex addinHash = new AddinIndex ();
			
			if (monitor.LogLevel > 1)
				monitor.Log ("Generating add-in extension maps");
			
			Hashtable changedAddins = null;
			ArrayList descriptionsToSave = new ArrayList ();
			ArrayList files = new ArrayList ();
			
			bool partialGeneration = addinsToUpdate != null;
			string[] domains = GetDomains ();
			
			// Get the files to be updated
			
			if (partialGeneration) {
				changedAddins = new Hashtable ();
				foreach (string sa in addinsToUpdate) {
					changedAddins [sa] = sa;
					
					// Look for all versions of the add-in, because this id may be the id of a reference,
					// and the exact reference version may not be installed.
					string s = sa;
					int i = s.LastIndexOf (',');
					if (i != -1)
						s = s.Substring (0, i);
					s += ",*";
					
					// Look for the add-in in any of the existing folders
					foreach (string domain in domains) {
						string mp = GetDescriptionPath (domain, s);
						string dir = Path.GetDirectoryName (mp);
						string pat = Path.GetFileName (mp);
						foreach (string fmp in fileDatabase.GetDirectoryFiles (dir, pat)) {
							if (files.Contains (fmp))
								continue;
							files.Add (fmp);
							string an = Path.GetFileNameWithoutExtension (fmp);
							changedAddins [an] = an;
						}
					}
				}
				foreach (string s in removedAddins)
					changedAddins [s] = s;
			}
			else {
				foreach (string dom in domains)
					files.AddRange (fileDatabase.GetDirectoryFiles (Path.Combine (AddinCachePath, dom), "*.maddin"));
			}
			
			// Load the descriptions.
			foreach (string file in files) {
			
				AddinDescription conf;
				if (!ReadAddinDescription (monitor, file, out conf)) {
					SafeDelete (monitor, file);
					continue;
				}

				// If the original file does not exist, the description can be deleted
				if (!File.Exists (conf.AddinFile)) {
					SafeDelete (monitor, file);
					continue;
				}
				
				// Remove old data from the description. If changedAddins==null, removes all data.
				// Otherwise, removes data only from the addins in the table.
				
				conf.UnmergeExternalData (changedAddins);
				descriptionsToSave.Add (conf);
				
				addinHash.Add (conf);
			}

			// Sort the add-ins, to make sure add-ins are processed before
			// all their dependencies
			ArrayList sorted = addinHash.GetSortedAddins ();

			// Register extension points and node sets
			foreach (AddinDescription conf in sorted)
				CollectExtensionPointData (conf, updateData);
			
			// Register extensions
			foreach (AddinDescription conf in sorted)
				CollectExtensionData (conf, updateData);
			
			// Save the maps
			foreach (AddinDescription conf in descriptionsToSave)
				conf.SaveBinary (fileDatabase);
			
			if (monitor.LogLevel > 1) {
				monitor.Log ("Addin relation map generated.");
//.........这里部分代码省略.........
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:101,代码来源:AddinDatabase.cs

示例7: InternalScanFolders

		void InternalScanFolders (IProgressStatus monitor, AddinScanResult scanResult)
		{
			DateTime tim = DateTime.Now;
			
			DatabaseInfrastructureCheck (monitor);
			if (monitor.IsCanceled)
				return;
			
			try {
				scanResult.HostIndex = GetAddinHostIndex ();
			}
			catch (Exception ex) {
				if (scanResult.CheckOnly) {
					scanResult.ChangesFound = true;
					return;
				}
				monitor.ReportError ("Add-in root index is corrupt. The add-in database will be regenerated.", ex);
				scanResult.RegenerateAllData = true;
			}
			
			AddinScanner scanner = new AddinScanner (this);
			
			// Check if any of the previously scanned folders has been deleted
			
			foreach (string file in Directory.GetFiles (AddinFolderCachePath, "*.data")) {
				AddinScanFolderInfo folderInfo;
				bool res = ReadFolderInfo (monitor, file, out folderInfo);
				if (!res || !Directory.Exists (folderInfo.Folder)) {
					if (res) {
						// Folder has been deleted. Remove the add-ins it had.
						scanner.UpdateDeletedAddins (monitor, folderInfo, scanResult);
					}
					else {
						// Folder info file corrupt. Regenerate all.
						scanResult.ChangesFound = true;
						scanResult.RegenerateRelationData = true;
					}
					
					if (!scanResult.CheckOnly)
						SafeDelete (monitor, file);
					else
						return;
				}
			}
			
			// Look for changes in the add-in folders
			
			foreach (string dir in registry.AddinDirectories) {
				if (dir == registry.DefaultAddinsFolder)
					scanner.ScanFolderRec (monitor, dir, scanResult);
				else
					scanner.ScanFolder (monitor, dir, scanResult);
				if (scanResult.CheckOnly) {
					if (scanResult.ChangesFound || monitor.IsCanceled)
						return;
				}
			}
			
			if (scanResult.CheckOnly)
				return;
			
			// Scan the files which have been modified
			
			currentScanResult = scanResult;

			foreach (FileToScan file in scanResult.FilesToScan)
				scanner.ScanFile (monitor, file.File, file.AddinScanFolderInfo, scanResult);

			// Save folder info
			
			foreach (AddinScanFolderInfo finfo in scanResult.ModifiedFolderInfos)
				SaveFolderInfo (monitor, finfo);

			if (monitor.VerboseLog)
				monitor.Log ("Folders scan completed (" + (int) (DateTime.Now - tim).TotalMilliseconds + " ms)");

			SaveAddinHostIndex ();
			ResetCachedData ();
			
			if (!scanResult.ChangesFound) {
				if (monitor.VerboseLog)
					monitor.Log ("No changes found");
				return;
			}
			
			tim = DateTime.Now;
			try {
				if (scanResult.RegenerateRelationData)
					scanResult.AddinsToUpdateRelations = null;
				
				GenerateAddinExtensionMapsInternal (monitor, scanResult.AddinsToUpdateRelations, scanResult.RemovedAddins);
			}
			catch (Exception ex) {
				fatalDatabseError = true;
				monitor.ReportError ("The add-in database could not be updated. It may be due to file corruption. Try running the setup repair utility", ex);
			}
			
			if (monitor.VerboseLog)
				monitor.Log ("Add-in relations analyzed (" + (int) (DateTime.Now - tim).TotalMilliseconds + " ms)");
			
//.........这里部分代码省略.........
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:101,代码来源:AddinDatabase.cs

示例8: SafeDelete

		public bool SafeDelete (IProgressStatus monitor, string file)
		{
			try {
				fileDatabase.Delete (file);
				return true;
			}
			catch (Exception ex) {
				if (monitor.VerboseLog) {
					monitor.Log ("Could not delete file: " + file);
					monitor.Log (ex.ToString ());
				}
				return false;
			}
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:14,代码来源:AddinDatabase.cs

示例9: GenerateAddinExtensionMapsInternal

        void GenerateAddinExtensionMapsInternal(IProgressStatus monitor, string domain, List<string> addinsToUpdate, List<string> addinsToUpdateRelations, List<string> removedAddins)
        {
            AddinUpdateData updateData = new AddinUpdateData (this, monitor);

            // Clear cached data
            cachedAddinSetupInfos.Clear ();

            // Collect all information

            AddinIndex addinHash = new AddinIndex ();

            if (monitor.LogLevel > 1)
                monitor.Log ("Generating add-in extension maps");

            Hashtable changedAddins = null;
            ArrayList descriptionsToSave = new ArrayList ();
            ArrayList files = new ArrayList ();

            bool partialGeneration = addinsToUpdate != null;
            string[] domains = GetDomains ().Where (d => d == domain || d == GlobalDomain).ToArray ();

            // Get the files to be updated

            if (partialGeneration) {
                changedAddins = new Hashtable ();

                if (monitor.LogLevel > 2)
                    monitor.Log ("Doing a partial registry update.\nAdd-ins to be updated:");
                // Get the files and ids of all add-ins that have to be updated
                // Include removed add-ins: if there are several instances of the same add-in, removing one of
                // them will make other instances to show up. If there is a single instance, its files are
                // already removed.
                foreach (string sa in addinsToUpdate.Union (removedAddins)) {
                    changedAddins [sa] = sa;
                    if (monitor.LogLevel > 2)
                        monitor.Log (" - " + sa);
                    foreach (string file in GetAddinFiles (sa, domains)) {
                        if (!files.Contains (file)) {
                            files.Add (file);
                            string an = Path.GetFileNameWithoutExtension (file);
                            changedAddins [an] = an;
                            if (monitor.LogLevel > 2 && an != sa)
                                monitor.Log (" - " + an);
                        }
                    }
                }

                if (monitor.LogLevel > 2)
                    monitor.Log ("Add-ins whose relations have to be updated:");

                // Get the files and ids of all add-ins whose relations have to be updated
                foreach (string sa in addinsToUpdateRelations) {
                    foreach (string file in GetAddinFiles (sa, domains)) {
                        if (!files.Contains (file)) {
                            if (monitor.LogLevel > 2) {
                                string an = Path.GetFileNameWithoutExtension (file);
                                monitor.Log (" - " + an);
                            }
                            files.Add (file);
                        }
                    }
                }
            }
            else {
                foreach (var dom in domains)
                    files.AddRange (fileDatabase.GetDirectoryFiles (Path.Combine (AddinCachePath, dom), "*.maddin"));
            }

            // Load the descriptions.
            foreach (string file in files) {

                AddinDescription conf;
                if (!ReadAddinDescription (monitor, file, out conf)) {
                    SafeDelete (monitor, file);
                    continue;
                }

                // If the original file does not exist, the description can be deleted
                if (!fs.FileExists (conf.AddinFile)) {
                    SafeDelete (monitor, file);
                    continue;
                }

                // Remove old data from the description. Remove the data of the add-ins that
                // have changed. This data will be re-added later.

                conf.UnmergeExternalData (changedAddins);
                descriptionsToSave.Add (conf);

                addinHash.Add (conf);
            }

            // Sort the add-ins, to make sure add-ins are processed before
            // all their dependencies

            var sorted = addinHash.GetSortedAddins ();

            // Register extension points and node sets
            foreach (AddinDescription conf in sorted)
                CollectExtensionPointData (conf, updateData);
//.........这里部分代码省略.........
开发者ID:mono,项目名称:mono-addins,代码行数:101,代码来源:AddinDatabase.cs

示例10: BuildPackage

        /// <summary>
        /// Packages an add-in
        /// </summary>
        /// <param name="statusMonitor">
        /// Progress monitor where to show progress status
        /// </param>
        /// <param name="targetDirectory">
        /// Directory where to generate the package
        /// </param>
        /// <param name="filePaths">
        /// Paths to the add-ins to be packaged. Paths can be either the main assembly of an add-in, or an add-in
        /// manifest (.addin or .addin.xml).
        /// </param>
        /// <remarks>
        /// This method can be used to create a package for an add-in, which can then be pushed to an on-line
        /// repository. The package will include the main assembly or manifest of the add-in and any external
        /// file declared in the add-in metadata.
        /// </remarks>
        public void BuildPackage(IProgressStatus monitor, string outFilePath, string filePath)
        {
            AddinDescription conf = registry.GetAddinDescription (monitor, filePath);
            if (conf == null) {
                monitor.ReportError ("Could not read add-in file: " + filePath, null);
                return;
            }

            var basePath = Path.GetDirectoryName(outFilePath);

            ZipOutputStream s = new ZipOutputStream(File.Create(outFilePath));
            s.SetLevel(5);

            // Generate a stripped down description of the add-in in a file, since the complete
            // description may be declared as assembly attributes

            XmlDocument doc = new XmlDocument ();
            doc.PreserveWhitespace = false;
            doc.LoadXml (conf.SaveToXml ().OuterXml);
            CleanDescription (doc.DocumentElement);
            MemoryStream ms = new MemoryStream ();
            XmlTextWriter tw = new XmlTextWriter (ms, System.Text.Encoding.UTF8);
            tw.Formatting = Formatting.Indented;
            doc.WriteTo (tw);
            tw.Flush ();
            byte[] data = ms.ToArray ();

            ZipEntry infoEntry = new ZipEntry ("addin.info");
            s.PutNextEntry (infoEntry);
            s.Write (data, 0, data.Length);

            // Now add the add-in files

            ArrayList list = new ArrayList ();
            if (!conf.AllFiles.Contains (Path.GetFileName (filePath)))
                list.Add (Path.GetFileName (filePath));
            foreach (string f in conf.AllFiles) {
                list.Add (f);
            }

            foreach (var prop in conf.Properties) {
                try {
                    if (File.Exists (Path.Combine (basePath, prop.Value)))
                        list.Add (prop.Value);
                } catch {
                    // Ignore errors
                }
            }

            monitor.Log ("Creating package " + Path.GetFileName (outFilePath));

            foreach (string file in list) {
                string fp = Path.Combine (basePath, file);
                using (FileStream fs = File.OpenRead (fp)) {
                    byte[] buffer = new byte [fs.Length];
                    fs.Read (buffer, 0, buffer.Length);

                    ZipEntry entry = new ZipEntry (file);
                    s.PutNextEntry (entry);
                    s.Write (buffer, 0, buffer.Length);
                }
            }

            s.Finish();
            s.Close();
        }
开发者ID:aBothe,项目名称:mono-addins,代码行数:84,代码来源:SetupService.cs

示例11: MonitorProcessStatus

		public static void MonitorProcessStatus (IProgressStatus monitor, TextReader reader, StringCollection progessLog)
		{
			string line;
			string exceptionText = null;
			while ((line = reader.ReadLine ()) != null) {
				int i = line.IndexOf (':');
				if (i != -1) {
					string tag = line.Substring (0, i);
					string txt = line.Substring (i+1);
					bool wasTag = true;
					
					switch (tag) {
						case "process-ps-msg":
							monitor.SetMessage (Decode (txt));
							break;
						case "process-ps-progress":
							monitor.SetProgress (double.Parse (txt));
							break;
						case "process-ps-log":
							monitor.Log (Decode (txt));
							break;
						case "process-ps-warning":
							monitor.ReportWarning (Decode (txt));
							break;
						case "process-ps-exception":
							exceptionText = Decode (txt);
							if (exceptionText == string.Empty)
								exceptionText = null;
							break;
						case "process-ps-error":
							string err = Decode (txt);
							if (err == string.Empty) err = null;
							monitor.ReportError (err, exceptionText != null ? new Exception (exceptionText) : null);
							break;
						case "process-ps-cancel":
							monitor.Cancel ();
							break;
						case "process-ps-plog":
							progessLog.Add (Decode (txt));
							break;
						default:
							wasTag = false;
							break;
					}
					if (wasTag)
						continue;
				}
				Console.WriteLine (line);
			}
		}
开发者ID:wanglehui,项目名称:mono-addins,代码行数:50,代码来源:ProcessProgressStatus.cs

示例12: ScanFolder

		public void ScanFolder (IProgressStatus monitor, string path, AddinScanResult scanResult)
		{
			path = Util.GetFullPath (path);
			
			// Avoid folders including each other
			if (!scanResult.VisitFolder (path))
				return;
			
			if (monitor.VerboseLog && !scanResult.LocateAssembliesOnly)
				monitor.Log ("Checking: " + path);
			
			AddinScanFolderInfo folderInfo;
			if (!database.GetFolderInfoForPath (monitor, path, out folderInfo)) {
				// folderInfo file was corrupt.
				// Just in case, we are going to regenerate all relation data.
				if (!Directory.Exists (path))
					scanResult.RegenerateRelationData = true;
			} else {
				if (folderInfo == null && !Directory.Exists (path))
					return;
			}
			
			if (folderInfo == null)
				folderInfo = new AddinScanFolderInfo (path);
			
			if (Directory.Exists (path))
			{
				foreach (string file in Directory.GetFiles (path)) {
					if (file.EndsWith (".addin.xml")) {
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						continue;
					}
					switch (Path.GetExtension (file)) {
					case ".dll":
					case ".exe":
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						scanResult.AddAssemblyLocation (file);
						break;
					case ".addin":
						RegisterFileToScan (monitor, file, scanResult, folderInfo);
						break;
					case ".addins":
						ScanAddinsFile (monitor, file, scanResult);
						break;
					}
				}
			}
			else if (!scanResult.LocateAssembliesOnly) {
				// The folder has been deleted. All add-ins defined in that folder should also be deleted.
				scanResult.RegenerateRelationData = true;
				scanResult.ChangesFound = true;
				if (scanResult.CheckOnly)
					return;
				database.DeleteFolderInfo (monitor, folderInfo);
			}
			
			if (scanResult.LocateAssembliesOnly)
				return;
			
			// Look for deleted add-ins.
			
			UpdateDeletedAddins (monitor, folderInfo, scanResult);
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:63,代码来源:AddinScanner.cs

示例13: ScanDescription

		bool ScanDescription (IProgressStatus monitor, AddinDescription config, Assembly rootAssembly, AddinScanResult scanResult)
		{
			// First of all scan the main module
			
			ArrayList assemblies = new ArrayList ();
			ArrayList hostExtensionClasses = new ArrayList ();
			
			try {
				foreach (string s in config.MainModule.Assemblies) {
					string asmFile = Path.Combine (config.BasePath, s);
					Assembly asm = Util.LoadAssemblyForReflection (asmFile);
					assemblies.Add (asm);
				}
				
				foreach (Assembly asm in assemblies)
					ScanAssemblyAddinHeaders (config, asm, scanResult);
				
				// The add-in id and version must be already assigned at this point
				
				// Clean host data from the index. New data will be added.
				if (scanResult.HostIndex != null)
					scanResult.HostIndex.RemoveHostData (config.AddinId, config.AddinFile);

				foreach (Assembly asm in assemblies)
					ScanAssemblyContents (config, asm, hostExtensionClasses, scanResult);
				
				if (config.IsRoot && scanResult.HostIndex != null) {
					// If the add-in is a root, register its assemblies
					foreach (Assembly asm in assemblies) {
						string asmFile = new Uri (asm.CodeBase).LocalPath;
						scanResult.HostIndex.RegisterAssembly (asmFile, config.AddinId, config.AddinFile);
					}
				}
				
			} catch (Exception ex) {
				if (monitor.VerboseLog)
					monitor.Log ("Could not load some add-in assemblies: " + ex.Message);
				scanResult.AddFileToWithFailure (config.AddinFile);
				return false;
			}
			
			foreach (Type t in hostExtensionClasses) {
				RegisterHostTypeNode (config, t, assemblies);
			}
			
			// Extension node types may have child nodes declared as attributes. Find them.
			
			Hashtable internalNodeSets = new Hashtable ();
			
			foreach (ExtensionNodeSet eset in config.ExtensionNodeSets)
				ScanNodeSet (config, eset, assemblies, internalNodeSets);
			
			foreach (ExtensionPoint ep in config.ExtensionPoints) {
				ScanNodeSet (config, ep.NodeSet, assemblies, internalNodeSets);
			}
		
			// Now scan all modules
			
			if (!config.IsRoot) {
				foreach (ModuleDescription mod in config.OptionalModules) {
					try {
						assemblies.Clear ();
						foreach (string s in mod.Assemblies) {
							string asmFile = Path.Combine (config.BasePath, s);
							Assembly asm = Util.LoadAssemblyForReflection (asmFile);
							assemblies.Add (asm);
						}
						foreach (Assembly asm in assemblies)
							ScanAssemblyContents (config, asm, null, scanResult);
				
						if (config.IsRoot && scanResult.HostIndex != null) {
							// If the add-in is a root, register its assemblies
							foreach (Assembly asm in assemblies) {
								string asmFile = new Uri (asm.CodeBase).LocalPath;
								scanResult.HostIndex.RegisterAssembly (asmFile, config.AddinId, config.AddinFile);
							}
						}
						
					} catch (Exception ex) {
						if (monitor.VerboseLog)
							monitor.Log ("Could not load some add-in assemblies: " + ex.Message);
						scanResult.AddFileToWithFailure (config.AddinFile);
					}
				}
			}
			
			return true;
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:88,代码来源:AddinScanner.cs

示例14: ScanFile

		public void ScanFile (IProgressStatus monitor, string file, AddinScanFolderInfo folderInfo, AddinScanResult scanResult)
		{
			if (monitor.VerboseLog)
				monitor.Log ("Scanning file: " + file);
				
			string scannedAddinId = null;
			bool scannedIsRoot = false;
			bool scanSuccessful = false;
			
			try {
				string ext = Path.GetExtension (file);
				AddinDescription config = null;
				
				if (ext == ".dll" || ext == ".exe")
					scanSuccessful = ScanAssembly (monitor, file, scanResult, out config);
				else
					scanSuccessful = ScanConfigAssemblies (monitor, file, scanResult, out config);

				if (config != null) {
					
					AddinFileInfo fi = folderInfo.GetAddinFileInfo (file);
					
					// If version is not specified, make up one
					if (config.Version.Length == 0) {
						config.Version = "0.0.0.0";
					}
					
					if (config.LocalId.Length == 0) {
						// Generate an internal id for this add-in
						config.LocalId = database.GetUniqueAddinId (file, (fi != null ? fi.AddinId : null), config.Namespace, config.Version);
						config.HasUserId = false;
					}
					
					// Check errors in the description
					StringCollection errors = config.Verify ();
					
					if (database.IsGlobalRegistry && config.AddinId.IndexOf ('.') == -1) {
						errors.Add ("Add-ins registered in the global registry must have a namespace.");
					}
					    
					if (errors.Count > 0) {
						scanSuccessful = false;
						monitor.ReportError ("Errors found in add-in '" + file + ":", null);
						foreach (string err in errors)
							monitor.ReportError (err, null);
					}
				
					// Make sure all extensions sets are initialized with the correct add-in id
					
					config.SetExtensionsAddinId (config.AddinId);
					
					scanResult.ChangesFound = true;
					
					// If the add-in already existed, try to reuse the relation data it had.
					// Also, the dependencies of the old add-in need to be re-analized
					
					AddinDescription existingDescription = null;
					bool res;
					
					if (config.IsRoot)
						res = database.GetHostDescription (monitor, config.AddinId, config.AddinFile, out existingDescription);
					else
						res = database.GetAddinDescription (monitor, config.AddinId, out existingDescription);
					
					// If we can't get information about the old assembly, just regenerate all relation data
					if (!res)
						scanResult.RegenerateRelationData = true;
					
					string replaceFileName = null;
					
					if (existingDescription != null) {
						// Reuse old relation data
						config.MergeExternalData (existingDescription);
						Util.AddDependencies (existingDescription, scanResult);
						replaceFileName = existingDescription.FileName;
					}
					
					// If the scanned file results in an add-in version different from the one obtained from
					// previous scans, the old add-in needs to be uninstalled.
					if (fi != null && fi.AddinId != null && fi.AddinId != config.AddinId) {
						if (fi.IsRoot)
							database.UninstallRootAddin (monitor, fi.AddinId, file, scanResult);
						else
							database.UninstallAddin (monitor, fi.AddinId, scanResult);
						
						// If the add-in version has changed, regenerate everything again since old data can't be reused
						if (Addin.GetIdName (fi.AddinId) == Addin.GetIdName (config.AddinId))
							scanResult.RegenerateRelationData = true;
					}
					
					// If a description could be generated, save it now (if the scan was successful)
					if (scanSuccessful) {
						if (database.SaveDescription (monitor, config, replaceFileName)) {
							// The new dependencies also have to be updated
							Util.AddDependencies (config, scanResult);
							scanResult.AddAddinToUpdateRelations (config.AddinId);
							scannedAddinId = config.AddinId;
							scannedIsRoot = config.IsRoot;
							return;
						}
//.........这里部分代码省略.........
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:101,代码来源:AddinScanner.cs

示例15: GetReflector

 IAssemblyReflector GetReflector(IProgressStatus monitor, AddinScanResult scanResult, string filePath)
 {
     IAssemblyReflector reflector = fs.GetReflectorForFile (scanResult, filePath);
     object coreAssembly;
     if (!coreAssemblies.TryGetValue (reflector, out coreAssembly)) {
         if (monitor.LogLevel > 1)
             monitor.Log ("Using assembly reflector: " + reflector.GetType ());
         coreAssemblies [reflector] = coreAssembly = reflector.LoadAssembly (GetType().Assembly.Location);
     }
     return reflector;
 }
开发者ID:JamesChan,项目名称:mono-addins,代码行数:11,代码来源:AddinScanner.cs


注:本文中的IProgressStatus.Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。