NAnt.DotNet.Tasks.AssemblyInfoTask.CodeProvider.GetTypedValue C# (CSharp) Method

GetTypedValue() private method

private GetTypedValue ( AssemblyAttribute attribute, StringCollection assemblies, StringCollection imports ) : object
attribute NAnt.DotNet.Types.AssemblyAttribute
assemblies System.Collections.Specialized.StringCollection
imports System.Collections.Specialized.StringCollection
return object
            private object GetTypedValue(AssemblyAttribute attribute, StringCollection assemblies, StringCollection imports)
            {
                // locate type assuming TypeName is fully qualified typename
                #if NET_4_0
                PermissionSet domainPermSet = new PermissionSet(PermissionState.Unrestricted);
                AppDomain newDomain = AppDomain.CreateDomain("TypeGatheringDomain", AppDomain.CurrentDomain.Evidence,
                    AppDomain.CurrentDomain.SetupInformation, domainPermSet);

                TypedValueGatherer typedValueGatherer = (TypedValueGatherer)
                    newDomain.CreateInstanceAndUnwrap(typeof(TypedValueGatherer).Assembly.FullName,
                    typeof(TypedValueGatherer).FullName, false, BindingFlags.Public | BindingFlags.Instance,
                    null, new object[0], CultureInfo.InvariantCulture, new object[0]);
                #else
                AppDomain newDomain = AppDomain.CreateDomain("TypeGatheringDomain",
                    AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);

                TypedValueGatherer typedValueGatherer = (TypedValueGatherer)
                    newDomain.CreateInstanceAndUnwrap(typeof(TypedValueGatherer).Assembly.FullName,
                    typeof(TypedValueGatherer).FullName, false, BindingFlags.Public | BindingFlags.Instance,
                    null, new object[0], CultureInfo.InvariantCulture, new object[0],
                    AppDomain.CurrentDomain.Evidence);
                #endif

                object typedValue = typedValueGatherer.GetTypedValue(
                    assemblies, imports, attribute.TypeName, attribute.Value);

                // unload newly created AppDomain
                AppDomain.Unload(newDomain);

                return typedValue;
            }