コード例 #1
0
ファイル: PluginManager.cs プロジェクト: ZHJEE/OpenTAP
        internal static IEnumerable <ResultParameter> GetPluginVersions(IEnumerable <object> allPluginTypes)
        {
            //Stopwatch timer = Stopwatch.StartNew();
            var assemblies = allPluginTypes.Select(item => item.GetType()).Distinct().Select(type => type.Assembly).ToHashSet();

            assemblies.Add(Assembly.GetExecutingAssembly());

            List <ResultParameter> parameters = new List <ResultParameter>();

            foreach (var asm in assemblies)
            {
                try
                {
                    if (!asm.IsDynamic && !string.IsNullOrEmpty(asm.Location))
                    {
                        parameters.Add(AssemblyVersions.Invoke(asm));
                    }
                }
                catch
                {
                    // Silent catch all because we don't care too much about this parameter
                }
            }
            return(new ResultParameters(parameters));
        }
コード例 #2
0
ファイル: PluginManagerTest.cs プロジェクト: ZHJEE/OpenTAP
        public void MemorizerThreadTest()
        {
            List <Task> tasks = new List <Task>();

            // Testing a very short operation in the memorizer
            // With a relatively short running tasks to test if we can break the internals of the memorizer.

            var numberThingTest = new Memorizer <int, int>(thing => thing % 25)
            {
                MaxNumberOfElements = 25, SoftSizeDecayTime = TimeSpan.MaxValue
            };
            var numberRevertThingTest = new Memorizer <int, int>(thing => - thing)
            {
                MaxNumberOfElements = 25, SoftSizeDecayTime = TimeSpan.MaxValue
            };

            for (int i = 0; i < 10; i++)
            {
                int _i = i;
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    for (int j = 0; j < 1000; j++)
                    {
                        var value1 = numberThingTest.Invoke((_i + j) % 71); // ensure collision of keys.
                        var value2 = numberRevertThingTest.Invoke(value1);
                        Assert.IsTrue(value2 == -(((_i + j) % 71) % 25));   // check calculation.
                    }
                }));
            }

            Task.WhenAll(tasks).Wait();
            Task.WaitAll(tasks.ToArray());
        }
コード例 #3
0
ファイル: PluginManager.cs プロジェクト: ZHJEE/OpenTAP
 public string[] FindAssemblies(string fileName)
 {
     SyncFiles();
     return(matching.Invoke(fileName));
 }