protected override Task <int> ExecuteCoreAsync() { if (!Parent.Checker.Check(ExtensionFilePaths.Values)) { Error.WriteLine($"Extensions could not be loaded. See output for details."); return(Task.FromResult(ExitCodeFailure)); } // Loading all of the extensions should succeed as the dependency checker will have already // loaded them. var extensions = new RazorExtension[ExtensionNames.Values.Count]; for (var i = 0; i < ExtensionNames.Values.Count; i++) { extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); } var version = RazorLanguageVersion.Parse(Version.Value()); var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); var sourceItems = GetSourceItems(ProjectDirectory.Value(), Sources.Values, Outputs.Values, RelativePaths.Values, DocumentKinds.Values); var result = ExecuteCore( configuration: configuration, projectDirectory: ProjectDirectory.Value(), tagHelperManifest: TagHelperManifest.Value(), sourceItems: sourceItems); return(Task.FromResult(result)); }
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action <RazorProjectEngineBuilder> configure) { // Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly. var assemblyName = new AssemblyName(typeof(LegacyProjectEngineFactory_3_0).Assembly.FullName); assemblyName.Name = AssemblyName; var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName)); var initializer = extension.CreateInitializer(); return(RazorProjectEngine.Create(configuration, fileSystem, b => { CompilerFeatures.Register(b); initializer.Initialize(b); configure?.Invoke(b); // See comments on MangleClassNames var componentDocumentClassifier = b.Features.OfType <ComponentDocumentClassifierPass>().FirstOrDefault(); if (componentDocumentClassifier != null) { componentDocumentClassifier.MangleClassNames = true; } })); }
public void AfterConsoleLoaded(PythonConsoleHost host) { Console.SetVariable("CPU", CPU); Console.SetVariable("VIEW", this); var LoadedDlls = AssemblyExtension.GetLoadedAssemblyWithoutDynamic(); Console.SetVariable("LoadedDlls", LoadedDlls); Console.UpdateVariables(); Console.Console.ExecuteFile(@"IronPythonTask\Init.ipy"); }
public void GetPath_Test() { Assembly assembly = typeof(AssemblyDescriptorTests).Assembly; string assemblyPath = assembly.Location; Assert.IsTrue(File.Exists(assemblyPath)); var assembly1 = AssemblyExtension.SafeLoadFile(assemblyPath); Assert.AreNotSame(assembly, assembly1); var type = assembly1.GetType("Moonlit.TestFixtures.AssemblyDescriptor_Test"); Assert.IsNotNull(type); }
public void GetAllAssembliesTest() { var ass = Assembly.GetExecutingAssembly(); var assArr1 = Directory.GetFiles(AssemblyExtension.FindPath(ass), "*.dll").Select(Assembly.LoadFrom).ToArray(); var typesToRegisterN = assArr1.SelectMany(n => n.GetTypes() .Where(type => !String.IsNullOrEmpty(type.Namespace)) .Where(type => type.BaseType == typeof(BaseEntity))); var assArr = AppDomain.CurrentDomain.GetAssemblies(); var testArr = ass.GetAllAssemblies(); Assert.Equal(assArr.Length <= testArr.Length, true); }
public RazorProjectEngine Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action <RazorProjectEngineBuilder> configure) { // Rewrite the assembly name into a full name just like this one, but with the name of the MVC design time assembly. var assemblyName = new AssemblyName(typeof(RazorProjectEngine).Assembly.FullName); assemblyName.Name = AssemblyName; var extension = new AssemblyExtension(configuration.ConfigurationName, Assembly.Load(assemblyName)); var initializer = extension.CreateInitializer(); return(RazorProjectEngine.Create(configuration, fileSystem, b => { initializer.Initialize(b); configure?.Invoke(b); })); }
protected override Task <int> ExecuteCoreAsync() { // Loading all of the extensions should succeed as the dependency checker will have already // loaded them. var extensions = new RazorExtension[ExtensionNames.Values.Count]; for (var i = 0; i < ExtensionNames.Values.Count; i++) { extensions[i] = new AssemblyExtension(ExtensionNames.Values[i], Parent.Loader.LoadFromPath(ExtensionFilePaths.Values[i])); } var version = RazorLanguageVersion.Parse(Version.Value()); var configuration = RazorConfiguration.Create(version, Configuration.Value(), extensions); var result = ExecuteCore( configuration: configuration, projectDirectory: ProjectDirectory.Value(), outputFilePath: TagHelperManifest.Value(), assemblies: Assemblies.Values.ToArray()); return(Task.FromResult(result)); }
/// <summary> /// Create object and add to it component of type "T", and return that instance. /// </summary> /// <returns>Reference to component.</returns> public static T CreateInstanceOfAbstractType <T>() where T : MonoBehaviour { Type providerType = typeof(T); if (!providerType.IsAbstract) { Debug.LogErrorFormat("Provided type {0} is not abstract.", providerType.Name); return(null); } Type[] types = AssemblyExtension.GetDerivedTypes <T>(); if (types != null && types.Length > 0) { GameObject newGameObject = new GameObject(); newGameObject.name = types[0].Name; return(newGameObject.AddComponent(types[0]) as T); } else { Debug.LogErrorFormat("There is no class that extends abstract class {0}.", typeof(T).Name); } return(null); }
public bool CreateFactoryItemInstance(string factoryItemName, Type instanceType, dynamic parameters = null) { if (FactoryItems.ContainsKey(factoryItemName)) { return(false); } else { try { object newObject = AssemblyExtension.CreateObject(instanceType, parameters); if (newObject != null) { FactoryItems[factoryItemName] = (T)newObject; return(true); } } catch (Exception ex) { throw ex; } } return(false); }