Exemple #1
0
 public void Init(ILighthouseServiceContainer container)
 {
     Container  = container;
     Identifier = LighthouseComponentLifetime.GenerateSessionIdentifier(this);
     Container.Log(LogLevel.Debug, LogType.ProducerStartup, this);
     Start();
 }
        public WindowsFileSystemProvider(string rootDirectory, ILighthouseServiceContainer container)
        {
            if (string.IsNullOrEmpty(rootDirectory))
            {
                throw new ArgumentException("storageRootDirectory must be specified", nameof(rootDirectory));
            }

            RootDirectory       = rootDirectory;
            LighthouseContainer = container;
            LighthouseContainer.Log(Logging.LogLevel.Info, Logging.LogType.Info, this, $"RootDirectory is {RootDirectory}");
        }
        public IEnumerable <Function> GetFunctions(ILighthouseServiceContainer container, string functionNamespace)
        {
            var functionParser = container.ResolveType <IFunctionParser>();

            if (functionParser == null)
            {
                container.Log(Core.Logging.LogLevel.Debug, Core.Logging.LogType.Error, this, message: "IFunctionParser can't be loaded.");
                throw new ApplicationException("No function parser found.");
            }

            var functions       = new List <Function>();
            var functionStrings = container
                                  .Warehouse?
                                  .Retrieve <IList <string> >(functionNamespace);

            if (functionStrings == null || functionStrings.Count == 0)
            {
                // no functions available
                container.Log(Core.Logging.LogLevel.Debug, Core.Logging.LogType.Info, this, message: "No functions to load");
                return(functions);
            }

            foreach (var functionString in functionStrings)
            {
                if (functionParser.TryParse(functionString, out var function))
                {
                    functions.Add(function);
                }
                else
                {
                    container.Log(
                        Core.Logging.LogLevel.Debug,
                        Core.Logging.LogType.Error,
                        this,
                        message: $"Can't parse function string: {functionString.Substring(0, 100)}"
                        );
                }
            }

            return(functions);
        }