public void AddItemTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(package);
            mc.Add(new Module());
            m = new Module();

            //
            // Run the test.
            //
            mc.Add(m);

            //
            // Verify the test.
            //
            Assert.AreSame(m, mc[1]);
        }
        public void RemoveItemTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(package);
            m       = new Module();
            mc.Add(m);

            //
            // Run the test.
            //
            mc.Remove(m);

            //
            // Verify the test.
            //
            Assert.AreEqual(null, m.Package);
            Assert.AreEqual(0, mc.Count);
        }
        public void SetPackageTest()
        {
            ModuleCollection mc;
            Package          package;
            Module           m;


            //
            // Setup the test.
            //
            package = new Package();
            mc      = new ModuleCollection(null);
            m       = new Module();
            mc.Add(m);

            //
            // Run the test.
            //
            mc.Owner = package;

            //
            // Verify the test.
            //
            Assert.AreSame(package, m.Package);
        }
        public void SetItemTest()
        {
            ModuleCollection mc;
            Package          package, package2;
            Module           m1, m2;


            //
            // Setup the test.
            //
            package    = new Package();
            package2   = new Package();
            mc         = new ModuleCollection(package);
            m1         = new Module();
            m1.Package = package2;
            m2         = new Module();
            mc.Add(m1);

            //
            // Run the test.
            //
            mc[0] = m2;

            //
            // Verify the test.
            //
            Assert.AreSame(m2, mc[0]);
            Assert.AreEqual(1, mc.Count);
            Assert.AreEqual(null, m1.Package);
            Assert.AreEqual(package, m2.Package);
        }
Пример #5
0
        /// <summary>
        /// Load the modules the blackboard will be connected with
        /// </summary>
        /// <param name="path">Path of file containing module information</param>
        /// <returns>True if load was successfull</returns>
        public bool LoadModules(string path)
        {
            char[]       splitChars = { '\r', '\n' };
            string[]     lines;
            ModuleClient m;
            int          i;

            if (!File.Exists(path))
            {
                return(false);
            }
            try
            {
                lines = File.ReadAllText(path).Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
            }
            catch { return(false); }
            for (i = 0; i < lines.Length; ++i)
            {
                if ((m = ModuleClient.FromString(lines[i])) != null)
                {
                    m.Connected    += new ModuleConnectionEH(module_Connected);
                    m.Disconnected += new ModuleConnectionEH(module_Disconnected);
                    modules.Add(m);
                }
            }
            if (i == 0)
            {
                return(false);
            }
            return(true);
        }
        private void ClassifySubDirectory(DirectoryInfo subDirectory)
        {
            if (!subDirectory.Name.Contains(","))
            {
                return;
            }

            var stringSplit = subDirectory.Name.Split(',').ToList();

            var vsModule = new VsModule
            {
                Name     = stringSplit.FirstOrDefault(),
                Version  = stringSplit[1],
                FullPath = subDirectory.FullName
            };

            stringSplit.Remove(vsModule.Name);
            stringSplit.Remove(vsModule.Version);

            if (stringSplit.Any())
            {
                foreach (var item in stringSplit)
                {
                    vsModule.Name = $"{vsModule.Name},{item}";
                }
            }

            ModuleCollection.Add(vsModule);
        }
Пример #7
0
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false)
        {
            var modules = new ModuleCollection();

#if !PORTABLE && !NETSTANDARD1_2
            try {
                int id = 1;
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (!includeDynamic && assembly.IsDynamic)
                    {
                        continue;
                    }

#if !NETSTANDARD1_3 && !NETSTANDARD1_4
                    try {
                        if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                        {
                            continue;
                        }
                    } catch (SecurityException ex) {
                        const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                        log.Error(typeof(ExceptionlessClient), ex, message);
                    }
#endif

                    if (!includeSystem)
                    {
                        try {
                            string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                            if (_msPublicKeyTokens.Contains(publicKeyToken))
                            {
                                continue;
                            }

                            var attrs = assembly.GetCustomAttributes(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute)).ToList();
                            if (attrs.Count > 0)
                            {
                                continue;
                            }
                        } catch {}
                    }

                    var module = assembly.ToModuleInfo();
                    module.ModuleId = id;
                    modules.Add(module);

                    id++;
                }
            } catch (Exception ex) {
                log.Error(typeof(ExceptionlessClient), ex, "Error loading modules: " + ex.Message);
            }
#endif
            return(modules);
        }
Пример #8
0
        public static ModuleCollection GetUserModule(string userCode, string ptver)
        {
            moduleDT = SystemModule.GetUserPurviewModules(userCode, ptver);
            ModuleCollection modules = new ModuleCollection();

            foreach (DataRow row in moduleDT.Rows)
            {
                modules.Add(DataTableConvertModule(row));
            }
            return(modules);
        }
Пример #9
0
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false)
        {
            var modules = new ModuleCollection();

            int id = 1;

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (!includeDynamic && assembly.IsDynamic)
                {
                    continue;
                }

                try {
                    if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                    {
                        continue;
                    }
                } catch (SecurityException ex) {
                    const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                    log.Error(typeof(ExceptionlessClient), ex, message);
                }

                if (!includeSystem)
                {
                    try {
                        string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                        if (_msPublicKeyTokens.Contains(publicKeyToken))
                        {
                            continue;
                        }

                        object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                        if (attrs.Length > 0)
                        {
                            continue;
                        }
                    } catch {}
                }

                var module = assembly.ToModuleInfo();
                if (module.ModuleId > 0)
                {
                    continue;
                }

                module.ModuleId = id;
                modules.Add(module);

                id++;
            }

            return(modules);
        }
Пример #10
0
        public static ModuleCollection GetOneLevelByID(string strModuleID)
        {
            string           sqlString = string.Concat(new object[] { "select * from pt_mk where ( len(c_mkdm) = ", strModuleID.Length, " or len(c_mkdm) = 2 + ", strModuleID.Length.ToString(), ") and substring(c_mkdm,1,", strModuleID.Length, ") = '", strModuleID, "' order by c_mkdm,i_xh" });
            ModuleCollection modules   = new ModuleCollection();

            using (DataTable table = publicDbOpClass.DataTableQuary(sqlString))
            {
                foreach (DataRow row in table.Rows)
                {
                    modules.Add(DataTableConvertModule(row));
                }
            }
            return(modules);
        }
Пример #11
0
        public static ModuleCollection GetOneLevel()
        {
            string           sqlString = "select * from pt_mk where len(c_mkdm) = 2 order by i_xh,c_mkdm";
            ModuleCollection modules   = new ModuleCollection();

            using (DataTable table = publicDbOpClass.DataTableQuary(sqlString))
            {
                foreach (DataRow row in table.Rows)
                {
                    modules.Add(DataTableConvertModule(row));
                }
            }
            return(modules);
        }
Пример #12
0
        public static ModuleCollection RenderTreeModuleListGather(string strUserID, string ptver)
        {
            ModuleCollection userModule       = GetUserModule(strUserID, ptver);
            ModuleCollection targetCollection = new ModuleCollection();

            for (int i = 0; i < userModule.Count; i++)
            {
                if (userModule[i].ModuleCode.Length == 2)
                {
                    targetCollection.Add(userModule[i]);
                    AddChildNode(userModule[i].ModuleCode, userModule, targetCollection);
                }
            }
            return(targetCollection);
        }
Пример #13
0
        private static void AddChildNode(string ParentId, ModuleCollection SourceCollection, ModuleCollection TargetCollection)
        {
            ModuleCollection modules = new ModuleCollection();

            foreach (Module module in SourceCollection)
            {
                if (((module.ModuleCode.Length - 2) == ParentId.Length) && (module.ModuleCode.Substring(0, ParentId.Length) == ParentId))
                {
                    modules.Add(module);
                }
            }
            if (modules.Count != 0)
            {
                foreach (Module module2 in modules)
                {
                    TargetCollection.Add(module2);
                    AddChildNode(module2.ModuleCode, SourceCollection, TargetCollection);
                }
            }
        }
Пример #14
0
        private ModuleCollection CreateModules()
        {
            var modules = new ModuleCollection();

            using (var scope = _container.BeginLifetimeScope())
            {
                foreach (var moduleType in _container.ComponentRegistry.Registrations
                         .Where(r => typeof(TypeModule).IsAssignableFrom(r.Activator.LimitType))
                         .Select(r => r.Activator.LimitType).Distinct())
                {
                    if (scope.Resolve(moduleType) is TypeModule module)
                    {
                        modules.Add(module);
                    }
                }
            }

            modules.AddRange(_externalModules);

            return(modules);
        }
        public void DoClassification()
        {
            if (string.IsNullOrWhiteSpace(SelectedFolderPath))
            {
                return;
            }

            ModuleCollection.Clear();
            OldVersionModule.Clear();

            DirectoryInfo dirInfo = new DirectoryInfo(SelectedFolderPath);

            if (dirInfo != null && !dirInfo.Exists)
            {
                Properties.Settings.Default.LastSelectedFolder = "";
                SelectedFolderPath = "";
                return;
            }

            //classification
            DirectoryInfo archiveDirectoryInfo = null;
            var           directories          = dirInfo.GetDirectories();

            foreach (var directory in directories)
            {
                var vsModule = new VSModule();
                if (directory.Name.Contains(","))
                {
                    var stringSplit = directory.Name.Split(',').ToList();
                    vsModule.Name    = stringSplit.FirstOrDefault();
                    vsModule.Version = stringSplit[1];
                    stringSplit.Remove(vsModule.Name);
                    stringSplit.Remove(vsModule.Version);
                    if (stringSplit.Count() > 0)
                    {
                        foreach (var item in stringSplit)
                        {
                            vsModule.Name = vsModule.Name + "," + item;
                        }
                    }
                }
                else if (directory.Name.Equals("Archive"))
                {
                    archiveDirectoryInfo = directory;
                }
                else
                {
                    continue;
                }
                vsModule.FullPath = directory.FullName;
                ModuleCollection.Add(vsModule);
            }

            //Select all the Modules with same name from ModuleCollection
            var duplicateModules =
                ModuleCollection.Where(module =>
                                       ModuleCollection
                                       .Except(new ObservableCollection <VSModule> {
                module
            })
                                       .Any(x => x.Name == module.Name)
                                       ).ToObservableCollection();

            //Get all the old version modules/folder from duplicateModules
            OldVersionModule =
                duplicateModules.Where(module =>
                                       duplicateModules
                                       .Except(new ObservableCollection <VSModule> {
                module
            })
                                       .Any(x => x.Name == module.Name && x.VersionObject.CompareTo(module.VersionObject) > 0)
                                       ).ToObservableCollection();

            //Add archive folder to old version module
            if (archiveDirectoryInfo != null)
            {
                OldVersionModule.Add(new VSModule()
                {
                    FullPath = archiveDirectoryInfo.FullName,
                    Name     = archiveDirectoryInfo.Name
                });
            }
        }
Пример #16
0
 public void RegisterExternalModule(ExternalModule externalModule)
 {
     _externalModules.Add(externalModule);
 }
Пример #17
0
        public HeapSnapshot(int index, DateTime when, string filename, string text)
        {
            MemoryStatistics memory = new MemoryStatistics();
            bool             scanningForStart = true, scanningForMemory = false;
            Heap             scanningHeap = null;

            var regexes = new Regexes();

            int groupModule        = regexes.SnapshotModule.GroupNumberFromName("module");
            int groupModuleOffset  = regexes.SnapshotModule.GroupNumberFromName("offset");
            int groupModuleSize    = regexes.SnapshotModule.GroupNumberFromName("size");
            int groupHeaderId      = regexes.HeapHeader.GroupNumberFromName("id");
            int groupAllocOffset   = regexes.Allocation.GroupNumberFromName("offset");
            int groupAllocSize     = regexes.Allocation.GroupNumberFromName("size");
            int groupAllocOverhead = regexes.Allocation.GroupNumberFromName("overhead");
            int groupAllocId       = regexes.Allocation.GroupNumberFromName("id");

            Match m;

            // Instead of allocating a tiny new UInt32[] for every traceback we read in,
            //  we store groups of tracebacks into fixed-size buffers so that the GC has
            //  less work to do when performing collections. Tracebacks are read-only after
            //  being constructed, and all the tracebacks from a snapshot have the same
            //  lifetime, so this works out well.
            var frameBuffer      = new UInt32[FrameBufferSize];
            int frameBufferCount = 0;

            var lr = new LineReader(text);

            LineReader.Line line;

            while (lr.ReadLine(out line))
            {
                if (scanningHeap != null)
                {
                    if (line.StartsWith("*-") && line.Contains("End of data for heap"))
                    {
                        scanningHeap.Allocations.TrimExcess();
                        scanningHeap = null;
                    }
                    else if (regexes.Allocation.TryMatch(ref line, out m))
                    {
                        var       tracebackId = UInt32.Parse(m.Groups[groupAllocId].Value, NumberStyles.HexNumber);
                        Traceback traceback;

                        if (!Tracebacks.TryGetValue(tracebackId, out traceback))
                        {
                            // If the frame buffer could fill up while we're building our traceback,
                            //  let's allocate a new one.
                            if (frameBufferCount >= frameBuffer.Length - MaxTracebackLength)
                            {
                                frameBuffer      = new UInt32[frameBuffer.Length];
                                frameBufferCount = 0;
                            }

                            int firstFrame = frameBufferCount;

                            // This is only valid if every allocation is followed by an empty line
                            while (lr.ReadLine(out line))
                            {
                                if (line.StartsWith("\t"))
                                {
                                    frameBuffer[frameBufferCount++] = UInt32.Parse(
                                        line.ToString(), NumberStyles.HexNumber | NumberStyles.AllowLeadingWhite
                                        );
                                }
                                else
                                {
                                    lr.Rewind(ref line);
                                    break;
                                }
                            }

                            Tracebacks.Add(traceback = new Traceback(
                                               tracebackId, new ArraySegment <UInt32>(frameBuffer, firstFrame, frameBufferCount - firstFrame)
                                               ));
                        }

                        scanningHeap.Allocations.Add(new Allocation(
                                                         UInt32.Parse(m.Groups[groupAllocOffset].Value, NumberStyles.HexNumber),
                                                         UInt32.Parse(m.Groups[groupAllocSize].Value, NumberStyles.HexNumber),
                                                         UInt32.Parse(m.Groups[groupAllocOverhead].Value, NumberStyles.HexNumber),
                                                         traceback.ID
                                                         ));
                    }
                }
                else if (scanningForMemory)
                {
                    if (regexes.HeapHeader.TryMatch(ref line, out m))
                    {
                        scanningHeap = new Heap(index, UInt32.Parse(m.Groups[groupHeaderId].Value, NumberStyles.HexNumber));
                        Heaps.Add(scanningHeap);
                    }
                    else if (line.StartsWith("// Memory="))
                    {
                        memory            = new MemoryStatistics(line.ToString());
                        scanningForMemory = false;
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (scanningForStart)
                {
                    if (line.Contains("Loaded modules"))
                    {
                        scanningForStart = false;
                    }
                    else if (line.Contains("Start of data for heap"))
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    if (!regexes.SnapshotModule.TryMatch(ref line, out m))
                    {
                        if (line.Contains("Process modules enumerated"))
                        {
                            scanningForMemory = true;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        var modulePath = Path.GetFullPath(m.Groups[groupModule].Value).ToLowerInvariant();
                        Modules.Add(new Module(
                                        modulePath,
                                        UInt32.Parse(m.Groups[groupModuleOffset].Value, System.Globalization.NumberStyles.HexNumber),
                                        UInt32.Parse(m.Groups[groupModuleSize].Value, System.Globalization.NumberStyles.HexNumber)
                                        ));
                    }
                }
            }

            foreach (var heap in Heaps)
            {
                heap.Allocations.Sort(
                    (lhs, rhs) => lhs.Address.CompareTo(rhs.Address)
                    );
                heap.ComputeStatistics();
            }

            Info = new HeapSnapshotInfo(index, when, filename, memory, this);
        }
Пример #18
0
        public void ConfigureServices(IServiceCollection services)
        {
            var modules    = new List <string>();
            var collection = new ModuleCollection();

            IMvcBuilder builder = services.AddMvc(o =>
            {
                o.ModelMetadataDetailsProviders.Add(new ModelRequiredBinding());
                o.Filters.Add(new Filters.APIKeyFilter());
                o.Filters.Add(new Filters.ModelStateFilter());
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
                                  .AddJsonOptions(o =>
            {
                o.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
                o.SerializerSettings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            });

            Configuration.Bind("Modules", modules);
            foreach (var s in modules)
            {
                collection.Add(ModuleHelper.InjectModule(services, Configuration, builder, s));
            }
            var str = Configuration.GetConnectionString("Default");

            if (str.StartsWith("mysql:"))
            {
                services.AddDbContext <Data.Context>(o => o.UseLazyLoadingProxies()
                                                     .UseMySql(str.Substring(str.IndexOf(":") + 1)));
            }
            else
            {
                services.AddDbContext <Data.Context>(o => o.UseLazyLoadingProxies()
                                                     .UseSqlServer(str));
            }
            services.AddHttpContextAccessor();
            services.AddScoped <IUser>(o => new StandardUser(o.GetService <IHttpContextAccessor>(), o.GetService <Data.Context>()));
            services.AddCors(o =>
                             o.AddPolicy("AllowAll", p =>
                                         p.AllowAnyHeader()
                                         .AllowAnyMethod()
                                         .AllowAnyOrigin()
                                         )
                             );

            services.AddSingleton <IModuleCollection>(collection);

            services.AddSwaggerGen(c =>
            {
                c.TagActionsBy(api =>
                {
                    var ctrl = api.ActionDescriptor as ControllerActionDescriptor;
                    return(new List <string>()
                    {
                        ctrl.ControllerTypeInfo.Namespace.Replace("WikiLibs.API.", "") + "." + ctrl.ControllerName
                    });
                });
                c.SwaggerDoc("v1", new Info {
                    Title = "WikiLibs API", Version = Assembly.GetExecutingAssembly().GetName().Version.ToString()
                });
                c.CustomSchemaIds(x => x.Assembly.IsDynamic ? "Dynamic." + x.FullName : x.FullName);
                c.AddSecurityDefinition("Bearer", new ApiKeyScheme()
                {
                    Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                    Name        = "Authorization",
                    In          = "header",
                    Type        = "apiKey"
                });
                c.AddSecurityDefinition("APIKey", new ApiKeyScheme()
                {
                    Description = "API Key scheme. Example: \"Authorization: {token}\"",
                    Name        = "Authorization",
                    In          = "header",
                    Type        = "apiKey"
                });
                c.OperationFilter <AuthorizationSwagger>();
                c.OperationFilter <ErrorMiddlewareSwagger>();
            });
        }
        private static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool includeSystem = false, bool includeDynamic = false) {
            var modules = new ModuleCollection();

            try {
                int id = 1;
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
                    if (!includeDynamic && assembly.IsDynamic)
                        continue;

                    try {
                        if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                            continue;
                    } catch (SecurityException ex) {
                        const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
                        log.Error(typeof(ExceptionlessClient), ex, message);
                    }

                    if (!includeSystem) {
                        try {
                            string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                            if (_msPublicKeyTokens.Contains(publicKeyToken))
                                continue;

                            object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                            if (attrs.Length > 0)
                                continue;
                        } catch {}
                    }

                    var module = assembly.ToModuleInfo();
                    module.ModuleId = id;
                    modules.Add(module);

                    id++;
                }
            } catch (Exception ex) {
                log.Error(typeof(ExceptionlessClient), ex, "Error loading modules: " + ex.Message);
            }

            return modules;
        }
Пример #20
0
        private static ModuleCollection GetLoadedModules(
#if EMBEDDED
            IExceptionlessLog log,
#endif
            bool includeSystem = false, bool includeDynamic = false)
        {
            var modules = new ModuleCollection();

            int id = 1;

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
#if PFX_LEGACY_3_5
                try {
                    if (!includeDynamic && assembly.ManifestModule is System.Reflection.Emit.MethodBuilder)
                    {
                        continue;
                    }
                } catch (NotImplementedException ex) {
#if EMBEDDED
                    log.Error(ex, "An error occurred while checking if the current assembly is a dynamic assembly.");
#endif
                }
#else
                if (!includeDynamic && assembly.IsDynamic)
                {
                    continue;
                }

                try {
                    if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                    {
                        continue;
                    }
                } catch (SecurityException ex) {
                    const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
#if EMBEDDED
                    log.Error(typeof(ExceptionlessClient), ex, message);
#else
                    Trace.WriteLine(String.Format("{0} Exception: {1}", message, ex));
#endif
                }
#endif

                if (!includeSystem)
                {
                    try {
                        string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                        if (_msPublicKeyTokens.Contains(publicKeyToken))
                        {
                            continue;
                        }

                        object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                        if (attrs.Length > 0)
                        {
                            continue;
                        }
                    } catch {}
                }

#if EMBEDDED
                var module = assembly.ToModuleInfo(log);
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo(log));
#else
                var module = assembly.ToModuleInfo();
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo());
#endif
                id++;
            }

            return(modules);
        }
        private static ModuleCollection GetLoadedModules(
#if EMBEDDED
            IExceptionlessLog log,
#endif
            bool includeSystem = false, bool includeDynamic = false) {
            var modules = new ModuleCollection();

            int id = 1;
            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
#if PFX_LEGACY_3_5
                try {
                    if (!includeDynamic && assembly.ManifestModule is System.Reflection.Emit.MethodBuilder)
                        continue;   
                } catch (NotImplementedException ex) {
#if EMBEDDED
                    log.Error(ex, "An error occurred while checking if the current assembly is a dynamic assembly.");  
#endif
                }
#else
                if (!includeDynamic && assembly.IsDynamic)
                    continue;

                try {
                    if (!includeDynamic && String.IsNullOrEmpty(assembly.Location))
                        continue;
                } catch (SecurityException ex) {
                    const string message = "An error occurred while getting the Assembly.Location value. This error will occur when when you are not running under full trust.";
#if EMBEDDED
                    log.Error(typeof(ExceptionlessClient), ex, message);
#else
                    Trace.WriteLine(String.Format("{0} Exception: {1}", message, ex));
#endif
                }

#endif

                if (!includeSystem) {
                    try {
                        string publicKeyToken = assembly.GetAssemblyName().GetPublicKeyToken().ToHex();
                        if (_msPublicKeyTokens.Contains(publicKeyToken))
                            continue;

                        object[] attrs = assembly.GetCustomAttributes(typeof(GeneratedCodeAttribute), true);
                        if (attrs.Length > 0)
                            continue;
                    } catch {}
                }

#if EMBEDDED
                var module = assembly.ToModuleInfo(log);
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo(log));
#else
                var module = assembly.ToModuleInfo();
                module.ModuleId = id;
                modules.Add(assembly.ToModuleInfo());
#endif
                id++;
            }

            return modules;
        }