protected IEnumerable <Type> GetMatchingValues() { if (_matchingValues == null) { IList <Type> allTypes = new List <Type>(); foreach (var ass in AppDomain.CurrentDomain.GetAssemblies()) { if (PXSubstManager.IsSuitableTypeExportAssembly(ass, true)) { Type[] types = null; try { if (!ass.IsDynamic) { types = ass.GetExportedTypes(); } } catch (ReflectionTypeLoadException te) { types = te.Types; } catch { continue; } if (types != null) { allTypes.AddRange(types.Where(ty => predicate(ty))); } } } _matchingValues = allTypes.Distinct(); } return(_matchingValues); }
protected virtual IEnumerable licences() { foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false)) { Type[] types = null; try { if (!ass.IsDynamic) { types = ass.GetExportedTypes(); } } catch (ReflectionTypeLoadException te) { types = te.Types; } catch { continue; } if (types != null) { foreach (Type t in types) { if (t != null && typeof(IProjectLicense).IsAssignableFrom(t) && t != typeof(IProjectLicense)) { var projectLicense = (IProjectLicense)Activator.CreateInstance(t); var existingLicence = (ClientLicencingSetup)ExistingLicences.SelectWindowed(0, 1, projectLicense.ProjectID); if (existingLicence != null) { yield return(existingLicence); } else { var licence = new ClientLicencingSetup() { CustomizationID = projectLicense.ProjectID, Description = projectLicense.ProjectDescription, Url = projectLicense.LicenseServerUrl, Username = projectLicense.LicenseServerUsername, Password = projectLicense.LicenseServerPassword, WindowDays = projectLicense.LicenseWindowDays, }; Licences.Insert(licence); yield return(licence); } } } } } } }
protected virtual IEnumerable GetRecords() { foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false)) { Type[] types = null; try { if (!ass.IsDynamic) { types = ass.GetExportedTypes(); } } catch (ReflectionTypeLoadException te) { types = te.Types; } catch { continue; } if (types != null) { foreach (Type t in types) { if (t != null && _MainProviderType.IsAssignableFrom(t) && t != _MainProviderType) { var dependents = _DependentProviderType.Where(dt => dt.IsAssignableFrom(t)).ToList(); if (dependents.Any()) { var nonBaseDependents = dependents.Where(dt => dt != t).ToList(); if (nonBaseDependents.Any()) { yield return(new ProviderRec { TypeName = t.FullName, ProviderName = nonBaseDependents.Select(nbd => nbd.Name).LastOrDefault() }); } } else { yield return(new ProviderRec { TypeName = t.FullName, ProviderName = _MainProviderType.Name }); } } } } } } }
public static IEnumerable <ProviderRec> GetProviderRecs(params Type[] providerInterfaceTypes) { if (providerInterfaceTypes == null) { yield break; } foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { if (PXSubstManager.IsSuitableTypeExportAssembly(ass, false)) { Type[] types = null; try { if (!ass.IsDynamic) { types = ass.GetExportedTypes(); } } catch (ReflectionTypeLoadException te) { types = te.Types; } catch { continue; } if (types != null) { foreach (var type in types .Where(assemblyType => providerInterfaceTypes .Any(interfaceType => interfaceType.IsAssignableFrom(assemblyType) && assemblyType != interfaceType))) { Attribute attribute = type.GetCustomAttributes().FirstOrDefault(a => a is PXDisplayTypeNameAttribute); string displayName = (attribute as PXDisplayTypeNameAttribute)?.Name ?? type.FullName; yield return(new ProviderRec { TypeName = type.FullName, DisplayTypeName = displayName }); } } } } }