Example #1
0
        private void LoadSections()
        {
            SectionList loadedSections = _loader.Load();

            CheckForPresenseOfGlobalSection(loadedSections);
            _sections.AddRange(loadedSections);
        }
Example #2
0
        /// <summary>
        /// The context constructor should only be called once. After the context has been created call GetContext for specific copies
        /// </summary>
        /// <param name="loader">The loader used to load classes.</param>
        /// <param name="datas">Custom data handlers.</param>
        public Context(IConfigurationLoader loader, IEnumerable <AbstractSitecoreDataHandler> datas)
        {
            //the setup must only run if the context has not been setup
            //second attempts to setup a context should throw an error
            if (!_contextLoaded)
            {
                lock (_lock)
                {
                    if (!_contextLoaded)
                    {
                        //load all classes
                        var classes = loader.Load().ToDictionary();

                        datas = LoadDefaultDataHandlers(datas);

                        InstanceContext instance = new InstanceContext(classes, datas);
                        StaticContext = instance;

                        //now assign a data handler to each property
                        foreach (var cls in classes)
                        {
                            IList <AbstractSitecoreDataHandler> handlers = new List <AbstractSitecoreDataHandler>();

                            foreach (var prop in cls.Value.Properties)
                            {
                                var handler = instance.GetDataHandler(prop);

                                //set the ID property of the class
                                //the ID property is needed later for writing and page editing,
                                //saves time having to look it
                                if (prop.Attribute is SitecoreIdAttribute)
                                {
                                    cls.Value.IdProperty = prop;
                                }
                                else if (prop.Attribute is SitecoreInfoAttribute &&
                                         prop.Attribute.CastTo <SitecoreInfoAttribute>().Type == SitecoreInfoType.Language)
                                {
                                    cls.Value.LanguageProperty = prop;
                                }
                                else if (prop.Attribute is SitecoreInfoAttribute &&
                                         prop.Attribute.CastTo <SitecoreInfoAttribute>().Type == SitecoreInfoType.Version)
                                {
                                    cls.Value.VersionProperty = prop;
                                }


                                handlers.Add(handler);
                            }
                            cls.Value.DataHandlers = handlers;
                        }
                    }
                }
            }
            else
            {
                throw new MapperException("Context already loaded");
            }
        }
        /// <summary>
        /// The context constructor should only be called once. After the context has been created call GetContext for specific copies
        /// </summary>
        /// <param name="loader">The loader used to load classes.</param>
        /// <param name="datas">Custom data handlers.</param>
        public Context(IConfigurationLoader loader, IEnumerable<AbstractSitecoreDataHandler> datas)
        {
            //the setup must only run if the context has not been setup
            //second attempts to setup a context should throw an error
            if (!_contextLoaded)
            {
                lock (_lock)
                {
                    if (!_contextLoaded)
                    {

                        //load all classes
                        var classes = loader.Load().ToDictionary();

                        datas = LoadDefaultDataHandlers(datas);

                        InstanceContext instance = new InstanceContext(classes, datas);
                        StaticContext = instance;

                        //now assign a data handler to each property
                        foreach (var cls in classes)
                        {
                            IList<AbstractSitecoreDataHandler> handlers = new List<AbstractSitecoreDataHandler>();

                            foreach (var prop in cls.Value.Properties)
                            {
                                
                                var handler =  instance.GetDataHandler(prop);
                              
                                //set the ID property of the class
                                //the ID property is needed later for writing and page editing, 
                                //saves time having to look it
                                if (prop.Attribute is SitecoreIdAttribute)
                                    cls.Value.IdProperty = prop;
                                else if (prop.Attribute is SitecoreInfoAttribute
                                    && prop.Attribute.CastTo<SitecoreInfoAttribute>().Type == SitecoreInfoType.Language)
                                    cls.Value.LanguageProperty = prop;
                                else if (prop.Attribute is SitecoreInfoAttribute
                                   && prop.Attribute.CastTo<SitecoreInfoAttribute>().Type == SitecoreInfoType.Version)
                                    cls.Value.VersionProperty = prop;

                                
                                handlers.Add(handler);

                            }
                            cls.Value.DataHandlers = handlers;
                        }
                        
                       

                    }
                }
            }
            else
                throw new MapperException ("Context already loaded");
        }
Example #4
0
        public void Register(IServiceCollection services)
        {
            var dataConfiguration = _configurationLoader.Load <DataConfiguration>();

            if (dataConfiguration == null)
            {
                throw new InjectionException();
            }

            services.AddSingleton(dataConfiguration);

            //services.AddScoped<CardRepository>();
        }
Example #5
0
        private async Task <TConfigurationStore> LoadConfiguration()
        {
            try
            {
                var config = await _configLoader.Load(_configKey);

                return(_configurationPreprocessor(config));
            }
            catch (Exception e)
            {
                _log.Error("Error while downloading configuration: {Exception}", e);
                throw;
            }
        }
    public WorkspaceConfig GetConfigTree(ConfiguratorPaths paths)
    {
        var file = new FileInfo(Path.GetFullPath(paths.WorkspacePath));

        var rootDir = file.DirectoryName;

        return(Populate(file.Name, null, rootDir));

        WorkspaceConfig Populate(string path, WorkspaceConfig parent, string currentDirectory)
        {
            var fullPath = Path.IsPathRooted(path) ? path : Path.Combine(currentDirectory, path);
            var c        = _loader.Load <WorkspaceConfig>(fullPath);

            if (c == null)
            {
                return(new WorkspaceConfig());
            }

            c.Parent = parent;
            c.path   = fullPath;

            foreach (var r in c.Elements <IRunnableConfig>())
            {
                if (r is IUseWorkingDir wd)
                {
                    wd.WorkingDir = new FileInfo(c.path).DirectoryName;
                }
                r.DeclaredPaths.Add(fullPath);
            }
            if (c.import == null)
            {
                return(c);
            }
            for (var i = 0; i < c.import.Length; i++)
            {
                ref var w = ref c.import[i];
                w = Populate(w.path, c, new FileInfo(fullPath).DirectoryName);
            }

            return(c);
        }
 public SpecFlowConfiguration LoadConfiguration(SpecFlowConfiguration specFlowConfiguration)
 {
     return(_configurationLoader.Load(specFlowConfiguration));
 }
 public virtual SpecFlowConfiguration LoadConfiguration(SpecFlowConfiguration specFlowConfiguration, SpecFlowConfigurationHolder specFlowConfigurationHolder)
 {
     return(_configurationLoader.Load(specFlowConfiguration, specFlowConfigurationHolder));
 }