Exemple #1
0
        static void CreateSoundWorldInstance()
        {
            if (string.Compare(EngineSettings.Init.SoundSystemDLL, "null", true) != 0)
            {
                string fullPath = "";
                if (!string.IsNullOrEmpty(EngineSettings.Init.SoundSystemDLL))
                {
                    string fullPath2 = Path.Combine(VirtualFileSystem.Directories.Binaries, EngineSettings.Init.SoundSystemDLL);
                    if (File.Exists(fullPath2))
                    {
                        fullPath = fullPath2;
                    }
                }

                if (fullPath != "")
                {
                    try
                    {
                        Assembly assembly = AssemblyUtility.LoadAssemblyByRealFileName(fullPath, false);

                        Type foundType = null;
                        foreach (Type type in assembly.GetTypes())
                        {
                            if (!type.IsAbstract && typeof(SoundWorld).IsAssignableFrom(type))
                            {
                                foundType = type;
                                break;
                            }
                        }

                        if (foundType == null)
                        {
                            Log.Fatal("SoundWorld: CreateSoundWorldInstance: SoundWorld based class is not available in the assembly \'{0}\'.", assembly.FullName);
                        }

                        ConstructorInfo constructor = foundType.GetConstructor(new Type[0] {
                        });
                        instance = (SoundWorld)constructor.Invoke(null);
                    }
                    catch (Exception e)
                    {
                        Log.Fatal("SoundWorld: CreateSoundWorldInstance: Loading assembly failed \'{0}\' ({1}).", fullPath, e.Message);
                    }
                }
                else
                {
                    //if( SystemSettings.CurrentPlatform != SystemSettings.Platform.UWP )
                    //{

                    //default sound system
                    instance = new OpenALSoundSystem.OpenALSoundWorld();

                    //}
                }
            }
        }
Exemple #2
0
        static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            //!!!!ReflectionOnlyAssemblyResolve event is also exists

            string assemblyName = args.Name;

            if (!string.IsNullOrEmpty(assemblyName))
            {
                string fileName = assemblyName.Substring(0, assemblyName.IndexOf(',')) + ".dll";
                string fullPath = Path.Combine(Directories.Binaries, fileName);
                if (File.Exists(fullPath))
                {
                    return(AssemblyUtility.LoadAssemblyByRealFileName(fullPath, false, loadWithoutLocking: true));
                }
            }

            return(null);
        }
Exemple #3
0
            protected override void Load()
            {
                var realFileName = VirtualPathUtility.GetRealPathByVirtual(Owner.Name);

                if (File.Exists(realFileName))
                {
                    //!!!!!экскепшены?
                    //!!!!virtual name
                    //!!!!reloading

                    assembly = AssemblyUtility.LoadAssemblyByRealFileName(realFileName, false, true, Owner.Name);
                    //if( assembly == null )
                    //{
                    //	//!!!!
                    //	Log.Fatal( "impl" );
                    //}

                    ResultObject = assembly;
                }
            }
Exemple #4
0
        public static void RegisterAssemblies_IncludingFromDefaultSettingConfig()
        {
            //NeoAxis.Core.dll
            AssemblyUtility.RegisterAssembly(Assembly.GetExecutingAssembly(), "");

            //auto load
            foreach (var b in DefaultSettingsConfig.Children)
            {
                if (string.Compare(b.Name, "AutoLoadAssembly", true) == 0)
                {
                    string name = b.GetAttribute("Name");
                    if (!string.IsNullOrEmpty(name))
                    {
                        var ext = Path.GetExtension(name).ToLower();
                        if (ext != ".dll")
                        {
                            name += ".dll";
                        }

                        if (name.Contains("*"))
                        {
                            var files = Directory.GetFiles(Directories.Binaries, name, SearchOption.TopDirectoryOnly);
                            foreach (var fullPath in files)
                            {
                                AssemblyUtility.LoadAssemblyByRealFileName(fullPath, true);
                            }
                        }
                        else
                        {
                            string fullPath = Path.Combine(Directories.Binaries, name);
                            AssemblyUtility.LoadAssemblyByRealFileName(fullPath, true);
                        }
                    }
                }
            }
        }