.NET Foundation Classes
System Namespace
Activator Class
Use Cases
Creating an object without knowing the class name at design time
https://stackoverflow.com/questions/5262693/c-sharp-using-activator-createinstance
System.AppDomain
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class AppDomain : MarshalByRefObject, _AppDomain, System.Security.IEvidenceFactory
Process (Runtime host) => multiple AppDomains => multiple Threads
http://www.java2s.com/Tutorial/CSharp/0240__Assembly/0020__AppDomain.htm
Working with application domains in .Net
Use AppDomains To Reduce Memory Consumption in .NET applications
Loading Assemblies in Separate Directories Into a New AppDomain
List all custom data stored in AppDomain
var appDomain = AppDomain.CurrentDomain;
var flags = BindingFlags.NonPublic | BindingFlags.Instance;
var fieldInfo = appDomain.GetType().GetField("_LocalStore", flags);
if (fieldInfo == null)
return;
var localStore = fieldInfo.GetValue(appDomain) as Dictionary<string, object[]>;
if (localStore == null)
return;
foreach (var key in localStore.Keys)
{
var nonNullValues = localStore[key].Where(v => v != null);
Console.WriteLine(key + ": " + string.Join(", ", nonNullValues));
}
System.IO
File
get extension,
System.IO.Path.GetExtension(file)