예제 #1
0
파일: Kernal.cs 프로젝트: rexzh/RexToy
        private object Lookup(IComponentInfo info)
        {
            _log.Info("Start build object [{0}].", info.Id);

            try
            {
                IObjectBuildContext ctx = _b.Build(info);
                if (ctx.LifeCycleManagement)
                {
                    _lifecycleContainer[ctx.Instance] = ctx;
                }
                _log.Info("Build object [{0}] success.", info.Id);
                return(ctx.Instance);
            }
            catch (ObjectBuilderException)
            {
                _log.Warning("Build object [{0}] fail.", info.Id);
                throw;
            }
            catch (ManifestException)
            {
                _log.Warning("Build object [{0}] fail.", info.Id);
                throw;
            }
            catch (Exception ex)
            {
                _log.Warning("Build object [{0}] fail.", info.Id);
                ex.CreateWrapException <ObjectBuilderException>();
                return(null);
            }
        }
예제 #2
0
        public PluginLoader(PluginContext pluginContext,
                            ITimelineTypeRegistry timelineTypeRegistry, ISourceTypeRegistry sourceTypeRegistry,
                            IObjectBuilder objectBuilder, IServiceLocator serviceLocator)
        {
            var timelineType = new TimelineType(pluginContext.Spec, TimelineTypeName, () => DefaultDisplayName)
                               .WithAllowMultipleInstances(true);

            timelineTypeRegistry.RegisterTimeline(timelineType);

            timelineTypeRegistry.RegisterTimelineFactory(TimelineTypeName,
                                                         () => new PluginTimeline(timelineType, TimelineTypeName, TimelineTypeNames.GenericGroup,
                                                                                  t => t.TimelineType.GetDefaultDisplayName()));

            timelineTypeRegistry
            .RegisterTimelineEntityFactory(TimelineTypeName, () => new GenericSingleGroupActivity());

            timelineTypeRegistry.RegisterTimelineEntityFactory(TimelineTypeName, () => new Group(null));

            //register function for loading day view data
            sourceTypeRegistry.RegisterDayViewLoader(SourceTypeName, objectBuilder.Build <PluginDayViewLoader>());

            //register user inferface view
            sourceTypeRegistry.RegisterAddTimelineViewModelFactory(SourceTypeName, serviceLocator.GetInstance <AddPluginTimelineViewModel>);

            sourceTypeRegistry.RegisterSourceType(
                new SourceType(SourceTypeName, () => DefaultDisplayName, 6)
                .WithIcon32Path("pack://application:,,,/TimelinePlugins.Example;component/Images/SourceImage.png")
                .WithGetDescription(() => "This is ManicTime timeline plugin example"));
        }
예제 #3
0
        public void Should_build_object_from_properties()
        {
            // Arrange
            var properties = new List <ConfigurationProperty>
            {
                new ConfigurationProperty
                {
                    Namespace = "ConfigurationProvider.Tests.Unit",
                    Class     = "TestConfigurationObject",
                    Property  = "Path",
                    Value     = "x/y/z"
                },
                new ConfigurationProperty
                {
                    Namespace = "ConfigurationProvider.Tests.Unit",
                    Class     = "TestConfigurationObject",
                    Property  = "IsTest",
                    Value     = "true"
                },
                new ConfigurationProperty
                {
                    Namespace = "ConfigurationProvider.Tests.Unit",
                    Class     = "TestConfigurationObject",
                    Property  = "Port",
                    Value     = "11"
                },
                new ConfigurationProperty
                {
                    Namespace = "Configuration.Provider.Tests.Unit",
                    Class     = "TestConfigurationObject",
                    Property  = "Path",
                    Value     = "x/y/z"
                }
            };

            // Act
            var config = _sut.Build <TestConfigurationObject>(properties);

            // Assert
            config.Should().NotBeNull();
            config.Path.Should().Be("x/y/z");
            config.IsTest.Should().BeTrue();
            config.Port.Should().Be(11);
        }
예제 #4
0
        public T GetConfiguration <T>(EnvironmentType env)
        {
            var objectProperties = _dataProvider.GetProperties(env);

            return(_objectBuilder.Build <T>(objectProperties));
        }