Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class PXSYProviderSelector : PXCustomSelectorAttribute
{
[Serializable]
public class ProviderRec : IBqlTable
{
#region TypeName
public abstract class typeName : PX.Data.IBqlField { }
[PXString(128, InputMask = "", IsKey = true)]
[PXUIField(DisplayName = "Type Name", Visibility = PXUIVisibility.SelectorVisible)]
public virtual string TypeName { get; set; }
#endregion
#region Description
public abstract class description : PX.Data.IBqlField { }
[PXDBString(128, InputMask = "", IsUnicode = true)]
[PXUIField(DisplayName = "Description", Visibility = PXUIVisibility.SelectorVisible)]
public virtual string Description { get; set; }
#endregion
}
public PXSYProviderSelector()
: base(typeof(ProviderRec.typeName))
{
DescriptionField = typeof(ProviderRec.description);
}
protected IEnumerable GetRecords()
{
foreach (Assembly 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)
{
foreach (Type t in types)
{
if (t != null && typeof(IPXSYProvider).IsAssignableFrom(t) && !t.IsInterface)
{
String description = t.Name;
string defaultFileExtension = null;
try
{
IPXSYProvider prov = (IPXSYProvider)Activator.CreateInstance(t);
description = prov.ProviderName;
defaultFileExtension = prov.DefaultFileExtension;
}
catch{/* Skip Exceptions */}
yield return new ProviderRec { TypeName = t.FullName, Description = description, DefaultFileExtension = defaultFileExtension };
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment