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


C# FileInfo.GetFiles方法代码示例

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


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

示例1: IgniteProcess

        /// <summary>
        /// Static initializer.
        /// </summary>
        static IgniteProcess()
        {
            // 1. Locate executable file and related stuff.
            DirectoryInfo dir = new FileInfo(new Uri(typeof(IgniteProcess).Assembly.CodeBase).LocalPath).Directory;

            // ReSharper disable once PossibleNullReferenceException
            ExeDir = dir.FullName;

            var exe = dir.GetFiles(ExeName);

            if (exe.Length == 0)
                throw new Exception(ExeName + " is not found in test output directory: " + dir.FullName);

            ExePath = exe[0].FullName;

            var exeCfg = dir.GetFiles(ExeCfgName);

            if (exeCfg.Length == 0)
                throw new Exception(ExeCfgName + " is not found in test output directory: " + dir.FullName);

            ExeCfgPath = exeCfg[0].FullName;

            ExeCfgBakPath = Path.Combine(ExeDir, ExeCfgBakName);

            File.Delete(ExeCfgBakPath);
        }
开发者ID:dheep-purdessy,项目名称:ignite,代码行数:29,代码来源:IgniteProcess.cs

示例2: Resolve

		/// <summary>
		/// Performs cue-intelligent logic to acquire a file requested by the cue.
		/// Returns the resulting full path(s).
		/// If there are multiple options, it returns them all.
		/// Returns the requested path first in the list (if it was found) for more simple use.
		/// Kind of an unusual design, I know. Consider them sorted by confidence.
		/// </summary>
		public List<string> Resolve(string path)
		{
			string targetFile = Path.GetFileName(path);
			string targetFragment = Path.GetFileNameWithoutExtension(path);

			DirectoryInfo di = null;
			MyFileInfo[] fileInfos;
			if (!string.IsNullOrEmpty(Path.GetDirectoryName(path)))
			{
				di = new FileInfo(path).Directory;
				//fileInfos = di.GetFiles(Path.GetFileNameWithoutExtension(path)); //does this work?
				fileInfos = MyFileInfosFromFileInfos(di.GetFiles()); //we (probably) have to enumerate all the files to do a search anyway, so might as well do this
				//TODO - dont do the search until a resolve fails
			}
			else
			{
				di = diBasedir;
				fileInfos = fisBaseDir;
			}

			var results = new List<FileInfo>();
			foreach (var fi in fileInfos)
			{
				var ext = Path.GetExtension(fi.FullName).ToLowerInvariant();

				//some choices are always bad: (we're looking for things like .bin and .wav)
				//it's a little unclear whether we should go for a whitelist or a blacklist here. 
				//there's similar numbers of cases either way.
				//perhaps we could code both (and prefer choices from the whitelist)
				if (ext == ".cue" || ext == ".sbi" || ext == ".ccd" || ext == ".sub")
					continue;

				//continuing the bad plan: forbid archives (always a wrong choice, not supported anyway)
				//we should have a list prioritized by extension and score that way
				if (ext == ".7z" || ext == ".rar" || ext == ".zip" || ext == ".bz2" || ext == ".gz")
					continue;

				string fragment = Path.GetFileNameWithoutExtension(fi.FullName);
				//match files with differing extensions
				int cmp = string.Compare(fragment, targetFragment, !caseSensitive);
				if (cmp != 0)
					//match files with another extension added on (likely to be mygame.bin.ecm)
					cmp = string.Compare(fragment, targetFile, !caseSensitive);
				if (cmp == 0)
				{
					//take care to add an exact match at the beginning
					if (fi.FullName.ToLowerInvariant() == Path.Combine(baseDir,path).ToLowerInvariant())
						results.Insert(0, fi.FileInfo);
					else
						results.Add(fi.FileInfo);
				}
			}
			var ret = new List<string>();
			foreach (var fi in results)
				ret.Add(fi.FullName);
			return ret;
		}
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:64,代码来源:CueFileResolver.cs

示例3: CopyExecutingAssemblyTo

        internal static void CopyExecutingAssemblyTo(DirectoryInfo to)
        {
            var executingAssemblyDirectory = new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Directory;

            var assemblies = executingAssemblyDirectory.GetFiles("*.dll");

            foreach (var assembly in assemblies)
            {
                File.Copy(assembly.FullName, Path.Combine(to.FullName, assembly.Name));
            }
        }
开发者ID:sjwood,项目名称:EmbeddedFx,代码行数:11,代码来源:GivenAnEmbeddedAssemblyLoader.cs

示例4: SearchingAnInputElementBySeveralSelectingMethods

        public void SearchingAnInputElementBySeveralSelectingMethods()
        {
            Browser b = new Browser();
            b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.FileUpload.htm"));
            HttpRequestLog lastLog = null;
            b.RequestLogged += (br, l) =>
                {
                    lastLog = l;
                };
            var form = b.Select("form");
            var file = b.Select("input[name=theFile]");
            DirectoryInfo dir = new FileInfo(Assembly.GetCallingAssembly().Location).Directory;
            file.Value = dir.GetFiles()[3].FullName;
            form.SubmitForm();

            Assert.NotNull(lastLog);
            Assert.That(lastLog.Method == "POST");
        }
开发者ID:spoike,项目名称:SimpleBrowser,代码行数:18,代码来源:Uploading.cs

示例5: Uploading_A_File_With_Enctype_MultipartMime

		public void Uploading_A_File_With_Enctype_MultipartMime()
		{
			Browser b = new Browser(Helper.GetAllways200RequestMocker());
			b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.FileUpload.htm"));
			HttpRequestLog lastLog = null;
			b.RequestLogged += (br, l) =>
				{
					lastLog = l;
				};
			var form = b.Select("form");
			var file = b.Select("input[name=theFile]");
			DirectoryInfo dir = new FileInfo(Assembly.GetCallingAssembly().Location).Directory;
			file.Value = dir.GetFiles()[3].FullName;
			form.SubmitForm();

			Assert.NotNull(lastLog);
			Assert.That(lastLog.Method == "POST");
		}
开发者ID:AshWilliams,项目名称:SimpleBrowser,代码行数:18,代码来源:Uploading.cs

示例6: getAcceptedIssuers

        public jvm::java.security.cert.X509Certificate[] getAcceptedIssuers()
        {
            // tested by ?
            var dir = new FileInfo(typeof(TrustEveryoneManager).Assembly.Location).Directory;

            // firefox needs a cert here?
            //Console.WriteLine("X509TrustManager getAcceptedIssuers " + new { dir });


            var ff = from f in dir.GetFiles()
                     where f.Name.EndsWith(".crt")

                     //jvm::java.security.cert.CertificateFactory.getInstance("X.509").generateCertificate(
                     //let crt = jvm::java.security.cert.X509Certificate.
                     select f;


            var a = new List<jvm::java.security.cert.X509Certificate> { };
            foreach (var item in ff)
            {
                //Console.WriteLine("X509TrustManager getAcceptedIssuers " + new { item.FullName });

                try
                {
                    var ksfis = new jvm::java.io.FileInputStream(item.FullName);
                    var certificate = (jvm::java.security.cert.X509Certificate)
                      jvm::java.security.cert.CertificateFactory.getInstance("X.509").generateCertificate(ksfis);

                    // Z:\jsc.svn\examples\javascript\ubuntu\UbuntuSSLWebApplication\UbuntuSSLWebApplication\ApplicationWebService.cs

                    a.Add(certificate);
                }
                catch
                {

                }

            }

            //Console.WriteLine("X509TrustManager getAcceptedIssuers " + new { a.Count });
            return a.ToArray();
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:42,代码来源:InternalX509ExtendedKeyManager.cs

示例7: Main

        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");

            string dir = Directory.GetCurrentDirectory();
            Assembly a = Assembly.GetEntryAssembly();
            System.Console.WriteLine("assembly path:"+a.Location);

            int i=Array.IndexOf<string>(args,"-root");
            if (i != -1)
            {
                string rootdir = args[i + 1];
                Directory.SetCurrentDirectory(rootdir);
                System.Console.WriteLine("root directory: " + rootdir);
            }
            else
            {
                DirectoryInfo current = new FileInfo(a.Location).Directory;
                while (current.GetFiles("cheetah_root").Length == 0)
                {
                    if ((current = current.Parent) == null)
                    {
                        throw new Exception("Can't find game root directory. Use -root $directory.");
                    }
                }
                Directory.SetCurrentDirectory(current.FullName);
                System.Console.WriteLine("root directory: " + current.FullName);
            }

            Application.Init ();

                                Root r = new Root(args, false);

                    SpaceWar2006.GameSystem.Mod.Instance.Init();

            MainWindow win = new MainWindow ();
            win.Show ();
            Application.Run ();
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:39,代码来源:Main.cs

示例8: Engine

 static Engine()
 {
     DirectoryInfo rundir = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
     List<Engine> engines = new List<Engine>();
     foreach(FileInfo fi in rundir.GetFiles("*.dll")) {
         try {
             Assembly assy = Assembly.LoadFrom(fi.FullName);
             foreach(Type t in assy.GetExportedTypes()) {
                 if(!t.IsAbstract && typeof(Engine).IsAssignableFrom(t)) {
                     Engine e = (Engine) Activator.CreateInstance(t);
                     if(e.Exists) engines.Add(e);
                 }
             }
         } catch (BadImageFormatException) {
             // do nothing. The dll isn't in the right format, so we'll ignore it.
         } catch (FileLoadException) {
             // do nothing. We tried to load the same assembly twice or the assembly name was longer than MAX_PATH characters.
             // In either case, we can't do anything with it.
         } catch (System.Reflection.ReflectionTypeLoadException) {
             // ignore ReflectionTypeLoadException
         } catch (TypeLoadException) {
             // ignore
         } catch (Exception e) {
             throw new ApplicationException("Could not load math engine plugin " + fi.Name + ":\n\n" + e.Message, e);
         }
     }
     engines.Sort(delegate(Engine a, Engine b) { return a.Name.CompareTo(b.Name); });
     _engines = engines.ToArray();
     Trace.Assert(_engines.Length > 0);
     int ix = 0;
     for(int i = 0; i < _engines.Length; i++) {
         if (_engines[i] is BuiltInEngine) {
         //if(_engines[i] is MMAEngine) {
             ix = i;
             break;
         }
     }
     _current = _engines[ix];
 }
开发者ID:buptkang,项目名称:MathCog,代码行数:39,代码来源:Engine.cs

示例9: treeView1_AfterSelect

 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag == null)
     {
         return;
     }
     DirectoryInfo dirInfo = new FileInfo(workingTocFile).Directory;
     FileInfo currentFile = dirInfo.GetFiles(e.Node.Tag.ToString()).FirstOrDefault();
     this.richTextBox1.Text = currentFile.OpenText().ReadToEnd();
 }
开发者ID:squillace,项目名称:gitwork,代码行数:10,代码来源:Form1.cs

示例10: Main

        static void Main(string[] args)
        {
            bool mail = Array.IndexOf<string>(args, "-mail") != -1;
            if (mail)
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");

                string dir = Directory.GetCurrentDirectory();
                Assembly a = Assembly.GetEntryAssembly();
                System.Console.WriteLine("assembly path:" + a.Location);

                int i = Array.IndexOf<string>(args, "-root");
                if (i != -1)
                {
                    string rootdir = args[i + 1];
                    Directory.SetCurrentDirectory(rootdir);
                    System.Console.WriteLine("root directory: " + rootdir);
                }
                else
                {
                    DirectoryInfo current = new FileInfo(a.Location).Directory;
                    while (current.GetFiles("cheetah_root").Length == 0)
                    {
                        if ((current = current.Parent) == null)
                        {
                            throw new Exception("Can't find game root directory. Use -root $directory.");
                        }
                    }
                    Directory.SetCurrentDirectory(current.FullName);
                    System.Console.WriteLine("root directory: " + current.FullName);
                }

                if (Array.IndexOf<string>(args, "server") != -1)
                {
                    ServerMain(args);
                }
                else if (Array.IndexOf<string>(args, "client") != -1)
                {
                    ClientMain(args);
                }
                else if (Array.IndexOf<string>(args, "clientserver") != -1)
                {
                    System.Console.WriteLine("client started. launching server...");
                    Process server = Process.Start("Game.exe", "server");
                    Thread.Sleep(1000);
                    System.Console.WriteLine("done.");

                    ClientMain(args);

                    server.Kill();
                }
                else if (Array.IndexOf<string>(args, "viewer") != -1)
                {
                    ViewerMain();
                }
                else if (Array.IndexOf<string>(args, "register") != -1)
                {
                    RegisterProtocol();
                }
                else if (Array.IndexOf<string>(args, "convert") != -1)
                {
                    Convert(args);
                }
                else if (Array.IndexOf<string>(args, "convertmodel") != -1)
                {
                    ConvertModel(args);
                }
                else if (Array.IndexOf<string>(args, "search") != -1)
                {
                    ConsoleMain(args);
                }
                else
                {
                    Root r = new Root(args, false);

                    if (mail)
                        System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

                    SpaceWar2006.GameSystem.Mod.Instance.Init();
                    new Spacewar2006.Forms.MainForm().ShowDialog();

                }
            }
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:86,代码来源:program.cs

示例11: GetIniContent2

		///// <summary>
		///// Write game settings to INI file.
		///// </summary>
		///// <param name="game"></param>
		//public string GetIniContent(Game game)
		//{
		//	// Get game directory.
		//	var dir = new FileInfo(game.FullPath).Directory;
		//	// Get INI file.
		//	var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
		//	var ini = new Ini(iniFile.FullName);
		//	var optionKeys = new[] { SettingName.PAD1, SettingName.PAD2, SettingName.PAD3, SettingName.PAD4 };
		//	for (int i = 0; i < optionKeys.Length; i++)
		//	{
		//		var optionKey = optionKeys[i];
		//		var mapTo = (MapTo)(i + 1);
		//		// Write PADx.
		//		var mapItem = SettingsMap.FirstOrDefault(x => x.IniSection == OptionsSection && x.IniKey == optionKey);
		//		WriteSettingsToIni(mapItem);
		//		var settings = SettingManager.Settings.Items.Where(x => x.MapTo == (int)mapTo).ToArray();
		//		for (int s = 0; s < settings.Length; s++)
		//		{
		//			var setting = settings[i];
		//			var padSetting = SettingManager.GetPadSetting(setting.PadSettingChecksum);
		//			var padSectionName = string.Format("IG_{0:N}", setting.InstanceGuid);
		//			WritePadSettingsToIni(padSectionName, setting, padSetting);
		//		}
		//	}
		//	return null;
		//}


		/// <summary>
		/// Write game settings to INI file.
		/// </summary>
		/// <param name="game"></param>
		public string GetIniContent2(Game game)
		{
			// Get game directory.
			var dir = new FileInfo(game.FullPath).Directory;
			// Get INI file.
			var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
			var ini = new Ini(iniFile.FullName);
			var optionKeys = new[] { SettingName.PAD1, SettingName.PAD2, SettingName.PAD3, SettingName.PAD4 };
			for (int i = 0; i < optionKeys.Length; i++)
			{
				var optionKey = optionKeys[i];
				var mapTo = (MapTo)(i + 1);
				// Write PADx.
				var mapItem = SettingsMap.FirstOrDefault(x => x.IniSection == OptionsSection && x.IniKey == optionKey);
				WriteSettingsToIni(mapItem);
				var settings = SettingManager.Settings.Items.Where(x => x.MapTo == (int)mapTo).ToArray();
				for (int s = 0; s < settings.Length; s++)
				{
					var setting = settings[i];
					var padSetting = SettingManager.GetPadSetting(setting.PadSettingChecksum);
					var padSectionName = string.Format("IG_{0:N}", setting.InstanceGuid);
					WritePadSettingsToIni(padSectionName, setting, padSetting);
				}
			}
			return null;
		}
开发者ID:XxRaPiDK3LLERxX,项目名称:nucleuscoop,代码行数:62,代码来源:SettingManager.INI.cs

示例12: ReadIniFile

		/// <summary>
		/// Read INI file by game.
		/// </summary>
		/// <param name="game"></param>
		public SearchResult ReadIniFile(Game game)
		{
			var result = new SearchResult();
			var settings = new List<Setting>();
			var padSettings = new List<PadSetting>();
			// Get game directory.
			var dir = new FileInfo(game.FullPath).Directory;
			// Get INI file.
			var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
			if (iniFile != null)
			{
				var ini = new Ini(iniFile.FullName);
				var optionKeys = new[]
				{
					SettingName.PAD1,
					SettingName.PAD2,
					SettingName.PAD3,
					SettingName.PAD4,
				};
				for (int i = 0; i < optionKeys.Length; i++)
				{
					var optionKey = optionKeys[i];
					var mapTo = (MapTo)(i + 1);
					var value = ini.GetValue(OptionsSection, optionKey);
					var padSectionNames = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					foreach (var padSectionName in padSectionNames)
					{
						Setting setting;
						PadSetting padSetting;
						ReadPadSettingsFromIni(padSectionName, out setting, out padSetting);
						setting.MapTo = (int)mapTo;
						// If settings was not added already then...
						if (!settings.Any(x => x.InstanceGuid.Equals(setting.InstanceGuid)))
						{
							settings.Add(setting);
							// If PAD setting was not added already then...
							if (padSettings.Any(x => x.PadSettingChecksum.Equals(x.PadSettingChecksum)))
							{
								padSettings.Add(padSetting);
							}
						}
					}
				}
			}
			return result;
		}
开发者ID:XxRaPiDK3LLERxX,项目名称:nucleuscoop,代码行数:50,代码来源:SettingManager.INI.cs

示例13: SearchAndDestroyPluginsInRootFolder

        private static void SearchAndDestroyPluginsInRootFolder()
        {
            var currentDirectory = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;

            if (currentDirectory == null)
                return;

            var unwantedFiles = currentDirectory.GetFiles("*.dll").Where(f => !rootFiles.Contains(f.Name)).ToList();

            if (unwantedFiles.Any())
            {
                if (DialogResult.Yes == MessageBox.Show(
                    string.Format(
                        "The following unknown file(s) currently exist in the XrmToolBox root folder:\r\n{0}\r\n\r\nThese files could result in unexpected behaviors like preventing the latest version of plugins to load. Would you like to delete these files?",
                        String.Join("\r\n", unwantedFiles.Select(f => "- " + f))), "Warning", MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning))
                {
                    foreach (var file in unwantedFiles)
                    {
                        File.Delete(file.FullName);
                    }
                }
            }
        }
开发者ID:RazDynamics,项目名称:XrmToolBox,代码行数:24,代码来源:Program.cs

示例14: CleanupPrevRunTempFiles

        private void CleanupPrevRunTempFiles(string fileName)
        {
            try
            {
                DirectoryInfo di = new FileInfo(fileName.Replace(System.Configuration.ConfigurationSettings.AppSettings["InDir"], System.Configuration.ConfigurationSettings.AppSettings["PendDir"])).Directory;
                foreach (FileInfo fi in di.GetFiles(fileName.Substring(fileName.LastIndexOf("\\") + 1, fileName.LastIndexOf(".") - fileName.LastIndexOf("\\") - 1) + ".*"))
                {
                    fi.Delete();
                }

                di = new FileInfo(fileName.Replace(System.Configuration.ConfigurationSettings.AppSettings["InDir"], System.Configuration.ConfigurationSettings.AppSettings["OutDir"])).Directory;
                foreach (FileInfo fi in di.GetFiles(fileName.Substring(fileName.LastIndexOf("\\") + 1, fileName.LastIndexOf(".") - fileName.LastIndexOf("\\") - 1) + ".*"))
                {
                    fi.Delete();
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("SiteLogger").Fatal("CleanupTempFiles(): Failed.", ex);
                //logger.logEntry(this.ToString(), "CleanupTempFiles(): Failed." + ex.Message, LogMsgSeverity.Critical, false);
            }
        }
开发者ID:ssieverts,项目名称:CodeSamples,代码行数:22,代码来源:ProcessorMain.cs

示例15: InitializeCapabilityClasses

        /// <summary>
        /// Dynamically load assemblies into the API based on what interfaces they implement.  Used to allow
        /// 3rd parties to add custom CapabilitySenders and CapabilityViewers without recompiling the application
        /// or changing its source code.
        /// </summary>
        /// <remarks>
        /// Because this section of code frequently excepts when a developer is creating a new Capability and does something wrong,
        /// we both write to the event log and display a message box so that the developer can find the error quickly.  In experience,
        /// just writing to the event log causes failures that new developers don't easily find.
        /// </remarks>
        public static void InitializeCapabilityClasses(out CapabilityViewerClassHashtable capabilityViewerClasses, 
                                                       out CapabilitySenderClassHashtable capabilitySenderClasses)
        {
            // Initialize outbound parameters
            capabilityViewerClasses = new CapabilityViewerClassHashtable();
            capabilitySenderClasses = new CapabilitySenderClassHashtable();

            #region Default RTDocs viewer from app.config

            // Before starting to iterate through .dll's, check to see if a default 
            // RTDocument CapabilityViewer is identified in app.config. If one is 
            // found in app.config, and there is not already a default stored in 
            // the registry, then set this one as the default.
            RegistryKey rtdocskey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft Research\\ConferenceXP\\Client\\" +
                System.Reflection.Assembly.GetEntryAssembly().CodeBase + "\\CapabilityViewers");

            string appconfigEntry;
            if ((appconfigEntry = ConfigurationManager.AppSettings[AppConfig.CXP_RTDocumentViewerDefault]) != null)
            {
                // We only use the app.config setting if there is not already an entry marked as default
                // in the registry
                string[] names = rtdocskey.GetValueNames();
                bool defExists = false;
                foreach (string key in names)
                {
                    object val = rtdocskey.GetValue(key);
                    if (val.ToString() == "default")
                    {
                        defExists = true;
                        break;
                    }
                }

                if (!defExists)
                    rtdocskey.SetValue(appconfigEntry, "default");
            }

            #endregion Default RTDocs viewer from app.config

            // Get the directory of the executing .exe
            DirectoryInfo diExe = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;

            // Find all the DLLs in that directory, looping through them all
            FileInfo[] fis = diExe.GetFiles("*.dll");
            foreach (FileInfo fiDll in fis)
            {
                try
                {
                    // Load each DLL into memory, getting a list of all root types (including classes and interfaces)
                    Type[] types = Assembly.LoadFrom(fiDll.FullName).GetTypes();

                    foreach (Type type in types)
                    {
                        // You can't instantiate an abstract class
                        if (type.IsAbstract)
                            continue;

                        // If the class defines "IsRunable" (inherited through Capability), run it and check
                        // that this class can be run on the current machine.  If not, skip the class.
                        if (type.IsSubclassOf(typeof(MSR.LST.ConferenceXP.Capability)))
                        {
                            PropertyInfo runableProp = type.GetProperty("IsRunable", BindingFlags.Static | BindingFlags.Public);
                            if (runableProp != null) // if the dll was compiled off of old code, it won't have "IsRunable"
                            {
                                MethodInfo getRunableMethod = runableProp.GetGetMethod();
                                object returnObj = getRunableMethod.Invoke(null, null);
                                if (!(returnObj is bool) || (((bool)returnObj) == false))
                                {
                                    continue; // Skip this type becuase its own method says it isn't runable.
                                }
                            }
                        }

                        // Check required capability attributes
                        Type iCV = type.GetInterface("MSR.LST.ConferenceXP.ICapabilityViewer");
                        Type iCS = type.GetInterface("MSR.LST.ConferenceXP.ICapabilitySender");

                        Capability.PayloadTypeAttribute pt = null;
                        Capability.NameAttribute capabilityName = null;

                        if (iCV != null || iCS != null)
                        {
                            pt = (Capability.PayloadTypeAttribute)Attribute.GetCustomAttribute(type,
                                typeof(Capability.PayloadTypeAttribute));

                            capabilityName = (Capability.NameAttribute)Attribute.GetCustomAttribute(type,
                                typeof(Capability.NameAttribute));

                            // Without a payload type and a name, it is invalidly constructed
                            if (null == pt || null == capabilityName)
//.........这里部分代码省略.........
开发者ID:psyCHOder,项目名称:conferencexp,代码行数:101,代码来源:CapabilityUtilities.cs


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