Пример #1
0
 private static void _LoadGraphEngineExtensions()
 {
     // Sometimes even if the assembly is tagged with the import extension attribute,
     // the extension assembly still won't get loaded. To alleviate this, we acquire
     // all currently loaded assemblies (including the one that calls into Trinity.Core and references the extension),
     // and forcibly enumerate its custom attributes. When the import extension
     // attribute is enumerated, it will trigger CLR to load its assembly, and thus
     // AppDomain.CurrentDomain.GetAssemblies will contain the extension assembly.
     Log.WriteLine(LogLevel.Info, "Loading Graph Engine Extensions.");
     AssemblyUtility.LoadReferences();
     AssemblyUtility.ForAllAssemblies(_ => _.GetCustomAttributes().ToList());
 }
Пример #2
0
        /// <returns>E_SUCCESS or E_FAILURE</returns>
        private static TrinityErrorCode _ScanForTSLStorageExtension()
        {
            Log.WriteLine(LogLevel.Info, "Scanning for TSL storage extension.");

            var loaded_tuple = AssemblyUtility
                               .ForAllAssemblies(_LoadTSLStorageExtension)
                               .Where(_ => _.Item1 != null && _.Item2 != null)
                               .OrderByDescending(_ => _.Item3)
                               .FirstOrDefault();

            if (loaded_tuple == default(Tuple <IGenericCellOperations, IStorageSchema, int>))
            {
                Log.WriteLine(LogLevel.Info, "No TSL storage extension loaded.");
                _RegisterTSLStorageExtension(new DefaultGenericCellOperations(), new DefaultStorageSchema());
                return(TrinityErrorCode.E_FAILURE);
            }
            else
            {
                Log.WriteLine(LogLevel.Info, "TSL storage extension loaded.");
                _RegisterTSLStorageExtension(loaded_tuple.Item1, loaded_tuple.Item2);
                return(TrinityErrorCode.E_SUCCESS);
            }
        }