コード例 #1
0
ファイル: Executor.cs プロジェクト: r-koubou/asmdef2uml
        static public void Execute(string baseDir, ITranspiler transpiler, List <string> excludeRegexList = null)
        {
            List <AssemblyDefinition>         asmdefList = new List <AssemblyDefinition>();
            IDictionary <string, AssemblyRef> refs       = new Dictionary <string, AssemblyRef>();

            string[] files = Directory.GetFiles(baseDir, "*.asmdef", SearchOption.AllDirectories);
            foreach (var i in files)
            {
                var asm = new AssemblyDefinition(i);
                asmdefList.Add(asm);
                refs[asm.AssemblyName] = new AssemblyRef(asm);
            }

            foreach (var r in refs.Values)
            {
                try
                {
                    r.ScanDependency(refs);
                }
                catch (StackOverflowException ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }

            transpiler.Output(refs, excludeRegexList);
        }
コード例 #2
0
        /// <summary>
        /// Gets the Windows Management Instrumentation (WMI) objects by subject.
        /// </summary>0
        /// <typeparam name="T">Type of callback.</typeparam>
        /// <param name="subject">The subject which you want to get.</param>
        /// <param name="transpiler">Uses the <seealso cref="Transpiler.Dynamic"/> or <seealso cref="Transpiler.ReadOnlyDictionary"/> to get the value.</param>
        /// <param name="localOnly">finds only local fields.</param>
        /// <returns></returns>
        public static IReadOnlyList <T> Get <T>(WmiSubject subject, ITranspiler <T> transpiler, bool localOnly = true, TimeSpan?timeout = null)
        {
            var searcher = new ManagementObjectSearcher($"select * from {subject}");

            if (timeout is TimeSpan ts)
            {
                searcher.Options.Timeout = ts;
            }

            var collection = default(ManagementObjectCollection);

            try
            {
                collection = searcher.Get();
                var list = new List <T>(collection.Count);

                foreach (ManagementObject mo in collection)
                {
                    var dict = transpiler.Create();
                    try
                    {
                        foreach (var pd in mo.Properties)
                        {
                            if ((localOnly && pd.IsLocal) || !localOnly)
                            {
                                var name = pd.Name;
                                if (!CimTypeConverter.TryConvert(pd.Type, pd.IsArray, pd.Value, out var value))
                                {
                                    continue;
                                }
                                // todo: makes filter optional.
                                if (value == null || (value is string s && string.IsNullOrWhiteSpace(s)))
                                {
                                    continue;
                                }
                                dict.Add(name, value);
                            }
                        }
                    }
                    catch
                    {
                        continue;
                    }
                    list.Add(transpiler.Convert(dict));
                }
                return(list);
            }
            catch
            {
                return(DefaultCache <T> .Array);
            }
            finally
            {
                (collection as IDisposable)?.Dispose();
            }
        }
コード例 #3
0
ファイル: ICompiler.cs プロジェクト: ziachap/Quack
 public Compiler(IFileReader reader,
                 ISourceSanitizer sanitizer,
                 ILexer lexer,
                 IParser parser,
                 ISemanticAnalyzer semanticValidator,
                 ITranspiler transpiler,
                 IFileWriter writer)
 {
     _reader            = reader;
     _sanitizer         = sanitizer;
     _lexer             = lexer;
     _parser            = parser;
     _semanticValidator = semanticValidator;
     _transpiler        = transpiler;
     _writer            = writer;
 }
コード例 #4
0
 public static async Task <IReadOnlyList <T> > GetAsync <T>(WmiSubject subject, ITranspiler <T> transpiler, bool localOnly = true, TimeSpan?timeout = null, CancellationToken token = default(CancellationToken))
 {
     return(await Task.Factory.StartNew(() => Get(subject, transpiler, localOnly, timeout), token, TaskCreationOptions.LongRunning, Task.Factory.Scheduler));
 }
コード例 #5
0
 public void Initialize()
 {
     _lexicalAnalyzer = new LexicalAnalyzer();
     _transpiler      = new Transpiler(_lexicalAnalyzer);
 }