Exemple #1
0
        /*--------------------------------------------------------------*/

        public void RegisterLibrary(ALibrary library)
        {
            // TODO: add something interesting here
            if (library == null)
            {
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.UNSPECIFIED_ERROR));
            }

            // do not allow to library reregistration
            if (_libraries.ContainsKey(library.Name))
            {
                throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.LIBRARY_REREGISTRATION));
            }

            // add the new library to the library stack
            _libraries.Add(library.Name, library);

            // add a refference to the library to a global object "library.Name"
            var libraryObject = RegisterGlobalObject(library.Name);

            libraryObject.Value = new TableRefValue(library.LibraryData);

            // let the library register it's members
            library.Register();
        }
Exemple #2
0
    void Awake()
    {
        if (I == null)
        {
            I = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        foreach (T def in definitions)
        {
            //Find first field value
            T2 type = (T2)typeof(T).GetFields()[0].GetValue(def);
            dict.Add(type, def);
        }
    }
Exemple #3
0
        public static void RegisterLibraryFiles(Program program, Schema.Library library, Schema.LoadedLibrary loadedLibrary)
        {
            // Register each assembly with the DAE
                        #if !LOADFROMLIBRARIES
            foreach (Schema.FileReference file in ALibrary.Files)
            {
                if ((file.Environments.Count == 0) || file.Environments.Contains(Environments.WindowsServer))
                {
                    string sourceFile = Path.IsPathRooted(file.FileName) ? file.FileName : Path.Combine(ALibrary.GetLibraryDirectory(((Server.Server)AProgram.ServerProcess.ServerSession.Server).LibraryDirectory), file.FileName);
                    string targetFile = Path.Combine(PathUtility.GetBinDirectory(), Path.GetFileName(file.FileName));

                    if (!File.Exists(sourceFile))
                    {
                        throw new System.IO.IOException(String.Format("File \"{0}\" not found.", sourceFile));
                    }
                    try
                    {
                                                #if !RESPECTREADONLY
                        FileUtility.EnsureWriteable(targetFile);
                                                #endif
                        if ((File.GetLastWriteTimeUtc(sourceFile) > File.GetLastWriteTimeUtc(targetFile)))                         // source newer than target
                        {
                            File.Copy(sourceFile, targetFile, true);
                        }
                    }
                    catch (IOException)
                    {
                        // Ignore this exception so that assembly copying does not fail if the assembly is already loaded
                    }
                }
            }
                        #endif

            // Load assemblies after all files are copied in so that multi-file assemblies and other dependencies are certain to be present
            foreach (Schema.FileReference file in library.Files)
            {
                if ((file.Environments.Count == 0) || file.Environments.Contains(Environments.WindowsServer))
                {
                                        #if LOADFROMLIBRARIES
                    string sourceFile = Path.IsPathRooted(file.FileName) ? file.FileName : Path.Combine(library.GetLibraryDirectory(((Server.Server)program.ServerProcess.ServerSession.Server).LibraryDirectory), file.FileName);
                    if (FileUtility.IsAssembly(sourceFile))
                    {
                        Assembly assembly = Assembly.LoadFrom(sourceFile);
                                        #else
                    string targetFile = Path.Combine(PathUtility.GetBinDirectory(), Path.GetFileName(file.FileName));
                    if (FileUtility.IsAssembly(targetFile))
                    {
                        Assembly assembly = Assembly.LoadFrom(targetFile);
                    #endif
                        if (file.IsAssembly)
                        {
                            program.CatalogDeviceSession.RegisterAssembly(loadedLibrary, assembly);
                        }
                    }
                }
            }
        }