Created
August 15, 2016 09:55
-
-
Save smarenich/39843e1bfe06a08dc29b396c4ce44fc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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