Example #1
0
        public void CanCreateProxyInterfaceFromTarget()
        {
            var objectSource = new ObjectSource();
            var testObject   = objectSource.Create <ITestObject>(new TestObject());

            Assert.NotNull(testObject);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvImportBlock"/> class.
 /// The <paramref name="source"/> provides the <see cref="ObjectId"/>, <see cref="ConditionId"/>, and <see cref="SessionId"/>.
 /// </summary>
 /// <param name="source">The <see cref="ObjectSource"/>.</param>
 public CsvImportBlock(ObjectSource source)
 {
     ObjectId    = source.ObjectId;
     SessionId   = source.SessionId;
     ConditionId = source.ConditionId;
     Samples     = new List <Sample>();
 }
        private void SetSource()
        {
            switch (SourceToolStripComboBox.SelectedIndex)
            {
            case 0:    //Objects
                if (_objectSource == null)
                {
                    _objectSource = new ObjectSource();
                }
                _currentSource = _objectSource;
                break;

            case 1:    //DataSet
                if (_dataSetSource == null)
                {
                    _dataSetSource = new DataSetSource();
                }
                _currentSource = _dataSetSource;
                break;

            case 2:    //Linq to SQL
                if (_linqToSQLSource == null)
                {
                    _linqToSQLSource = new LinqSource();
                }
                _currentSource = _linqToSQLSource;
                break;
            }
        }
Example #4
0
        public void Helper_SaveToExcel()
        {
            ObjectSource <Person> data = GetData();
            Helper helper = new Helper();

            helper.SaveToExcel <Person>(data, "Persons", AppDomain.CurrentDomain.BaseDirectory + "\\persons.xlsx");
        }
Example #5
0
        private async Task <TValue> GetInnerAsync <TValue>(string key, Func <Task <TValue> > accessor, Func <DictionaryRow, bool> expirationCheck)
        {
            await InitializeAsync();

            key = KeyPrefix + key;
            TValue value;

            var entry = await GetRowAsync(key);

            if (expirationCheck.Invoke(entry))
            {
                // query it anew and store
                value = await accessor.Invoke();
                await SetAsync(key, value);

                Source = ObjectSource.Live;
            }
            else
            {
                // or just give me the cached data
                value  = Deserialize <TValue>(entry.Value);
                Source = ObjectSource.Cache;
            }

            return(value);
        }
Example #6
0
        public void AddWorkdaysTest()
        {
            var             _engieers = new ObjectSource();
            List <Engineer> ENG       = _engieers.AddShifts();

            Assert.Fail();
        }
Example #7
0
        public ISource CreateObject(params object[] args)
        {
            var source = ObjectSource.CreateObjectSource().Convert <T>();
            BaseObjectSource <T> result = CreateSource(source);

            result.ObjectName  = ObjectName;
            result.UseMetaData = UseMetaData;
            return(result);
        }
Example #8
0
 public CachingDashboardConfigurationLoader(ObjectSource objectSource, HttpContext context)
 {
     dashboardConfiguration = context.Cache[DashboardConfigurationKey] as IDashboardConfiguration;
     if (dashboardConfiguration == null)
     {
         dashboardConfiguration = new DashboardConfigurationLoader(new ObjectionNetReflectorInstantiator(objectSource));
         context.Cache.Add(DashboardConfigurationKey, dashboardConfiguration, null, DateTime.MaxValue, TimeSpan.Zero, CacheItemPriority.Normal, null);
     }
 }
        protected virtual void OnProjectEnginePreloaded(Project.ProjectEnginePreloadedEventArgs message)
        {
            if (mObjectsArePreloaded)
            {
                var engine = message.Engine;

                SourceObjectDatabase = ObjectSource.GetObjectDatabase(engine);
            }
        }
		public CachingDashboardConfigurationLoader(ObjectSource objectSource, HttpContext context)
		{
			dashboardConfiguration = context.Cache[DashboardConfigurationKey] as IDashboardConfiguration;
			if (dashboardConfiguration == null)
			{
				dashboardConfiguration = new DashboardConfigurationLoader(new ObjectionNetReflectorInstantiator(objectSource));
				context.Cache.Add(DashboardConfigurationKey, dashboardConfiguration, null, DateTime.MaxValue, TimeSpan.Zero, CacheItemPriority.Normal, null);
			}
		}
Example #11
0
        private ItemSource CreateItemGenerator(string rootName, int numItems, double mean, double stdev)
        {
            IDoubleDistribution dist        = new NormalDistribution(m_model, "Item Generator", Guid.NewGuid(), mean, stdev);
            IPeriodicity        periodicity = new Periodicity(dist, Periodicity.Units.Minutes);
            bool         autoStart          = true;
            Ticker       ticker             = new Ticker(m_model, periodicity, autoStart, numItems);
            ObjectSource newItem            = new ObjectSource(new Item.ItemFactory(m_model, "Item_", Guid.NewGuid()).NewItem);

            return(new ItemSource(m_model, rootName, Guid.NewGuid(), newItem, ticker));
        }
Example #12
0
        public void CanCreateByFunc()
        {
            var objectSource = new ObjectSource();
            int counter      = 0;

            objectSource.WithGlobalInterceptor(new BeforeInvokeInterceptor(() => counter++));
            var testObject = objectSource.Create(() => new TestObject());

            testObject.NoTestCounter();
            Assert.AreEqual(1, counter);
        }
Example #13
0
        public void CanCreateObjectFromReal()
        {
            var objectSource = new ObjectSource();
            int counter      = 0;

            objectSource.WithGlobalInterceptor(new BeforeInvokeInterceptor(() => counter++));
            var testObject = (TestObject)objectSource.CreateFromReal(new TestObject());

            Assert.NotNull(testObject);
            testObject.HasTestCounter();
            Assert.AreEqual(1, counter);
        }
        protected virtual void OnProjectEngineLoaded(Project.ProjectEngineLoadedEventArgs message)
        {
            if (mObjectsArePreloaded == false)
            {
                var engine = message.Engine;

                SourceObjectDatabase = ObjectSource.GetObjectDatabase(engine);
            }

            // This needs to be setup after Load because the undefined members are modified during load, so there would be a data binding error if we set up after Preload
            SetupSourceObjectDatabaseUndefinedMembers();
        }
        public void Should_error_on_cyclic_dependency()
        {
            var johnDoe  = new Person("John Doe", 65);
            var judyDoe  = new Person("Judy Doe", 22);
            var jamesDoe = new Person("James Doe", 40);

            johnDoe.Children.Add(judyDoe);
            judyDoe.Children.Add(jamesDoe);
            jamesDoe.Children.Add(johnDoe);

            var error = new ObjectSource(johnDoe).Observe().WaitFirstValue(1.Seconds()).error;

            error.Should().NotBeNull().And.BeOfType <ArgumentException>();
        }
Example #16
0
        /// <summary>
        /// 根据对象来源获取表格名称
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        private static string GetSheetNameByObjectSource(ObjectSource source)
        {
            switch (source)
            {
            case ObjectSource.File:
                return("CSharp文件分析结果");

            case ObjectSource.Db:
                return("数据库分析结果");

            default:
                throw new ArgumentOutOfRangeException(nameof(source), source, null);
            }
        }
Example #17
0
 public SiteTemplateActionDecorator(IAction decoratedAction, IVelocityViewGenerator velocityViewGenerator,
                                    ObjectSource objectSource, IVersionProvider versionProvider,
                                    IFingerprintFactory fingerprintFactory, IUrlBuilder urlBuilder,
                                    IPluginConfiguration configuration, ICruiseRequest cruiseRequest)
 {
     this.decoratedAction       = decoratedAction;
     this.velocityViewGenerator = velocityViewGenerator;
     this.objectSource          = objectSource;
     this.versionProvider       = versionProvider;
     this.fingerprintFactory    = fingerprintFactory;
     this.urlBuilder            = urlBuilder;
     this.configuration         = configuration;
     this.cruiseRequest         = cruiseRequest;
 }
 public SiteTemplateActionDecorator(IAction decoratedAction, IVelocityViewGenerator velocityViewGenerator,
                                    ObjectSource objectSource, IVersionProvider versionProvider,
                                    IFingerprintFactory fingerprintFactory, IUrlBuilder urlBuilder,
                                     IPluginConfiguration configuration, ICruiseRequest cruiseRequest)
 {
     this.decoratedAction = decoratedAction;
     this.velocityViewGenerator = velocityViewGenerator;
     this.objectSource = objectSource;
     this.versionProvider = versionProvider;
     this.fingerprintFactory = fingerprintFactory;
     this.urlBuilder = urlBuilder;
     this.configuration = configuration;
     this.cruiseRequest = cruiseRequest;
 }
Example #19
0
        public void CanCreateSimpleProxies()
        {
            var objectSource          = new ObjectSource();
            var attributedInterceptor = new TestInterceptor();

            objectSource.WithAttributedInterceptor(attributedInterceptor);
            var testObject = objectSource.Create <TestObject>();

            Assert.AreEqual(0, attributedInterceptor.Count);
            testObject.HasTestCounter();
            Assert.AreEqual(1, attributedInterceptor.Count);
            testObject.HasTestCounter();
            Assert.AreEqual(2, attributedInterceptor.Count);
            testObject.NoTestCounter();
            Assert.AreEqual(2, attributedInterceptor.Count);
        }
Example #20
0
        private static SourceContext GetSourceContext(Definition definition)
        {
            var result = new SourceContext();

            if (definition.ModelSourceType == SourceType.Object)
            {
                Type modelType;
                Type modelInitializerType = null;
                if (!string.IsNullOrEmpty(definition.ModelTypeAssemblyPath))
                {
                    var myAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(definition.ModelTypeAssemblyPath);
                    modelType = myAssembly.GetType(definition.ModelType);
                    if (!string.IsNullOrEmpty(definition.ModelInitializerType))
                    {
                        modelInitializerType = myAssembly.GetType(definition.ModelInitializerType);
                    }
                }
                else
                {
                    modelType = Type.GetType(definition.ModelType);
                    if (!string.IsNullOrEmpty(definition.ModelInitializerType))
                    {
                        modelInitializerType = Type.GetType(definition.ModelInitializerType);
                    }
                }

                if (modelType == null)
                {
                    throw new ModelException(ModelException.FailValue.CouldNotLoadTypeForModel);
                }

                var json        = File.ReadAllText(definition.Model);
                var jsonOptions = UtilJson.GetDefaultOptions();
                var rawSource   = JsonSerializer.Deserialize(json, modelType, jsonOptions);
                if (modelInitializerType != null)
                {
                    var initializer = (IInitializer)Activator.CreateInstance(modelInitializerType);
                    initializer.Initialize(rawSource);
                }

                var source = new ObjectSource(rawSource);
                result.Source = source;
                result.Type   = modelType;
            }

            return(result);
        }
Example #21
0
        public void CanAddGlobalInterceptor()
        {
            int counter      = 0;
            var interceptor  = new SimpleInterceptor(a => { counter++; a.Proceed(); });
            var objectSource = new ObjectSource();

            objectSource.WithGlobalInterceptor(interceptor);
            var testObject = objectSource.Create <TestObject>();

            Assert.AreEqual(0, counter);
            testObject.HasTestCounter();
            Assert.AreEqual(1, counter);
            testObject.NoTestCounter();
            Assert.AreEqual(2, counter);
            testObject.NotVirtual();
            Assert.AreEqual(2, counter);
        }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectImportHelper"/> class.
 /// </summary>
 /// <param name="source">The <see cref="ObjectSource"/> containing the meta data of the object.</param>
 /// <param name="analysisObject">The <see cref="AnalysisObject"/> already containing the static data of the object.</param>
 public ObjectImportHelper(ObjectSource source, AnalysisObject analysisObject)
 {
     Source                      = source;
     ObjectId                    = source.ObjectId;
     SessionId                   = source.SessionId;
     ConditionId                 = source.ConditionId;
     ImportData                  = new CsvImportBlock(source);
     Parsers                     = new List <ParserFunc>();
     ParserIndices               = new List <int[]>();
     StaticPosition              = analysisObject.LocalPosition;
     StaticOrientation           = analysisObject.LocalRotation;
     StaticScale                 = analysisObject.LocalScale;
     UnitConversionFactor        = analysisObject.UnitConversionFactor;
     RotationFormat              = analysisObject.RotationFormat;
     timeFormat                  = analysisObject.TimeFormat;
     axisTransformationMatrix4x4 = Services.DataManager().AxisTransformationMatrix4x4;
 }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ItemSource"/> class.
        /// </summary>
        /// <param name="model">The model in which this object runs.</param>
        /// <param name="name">The user-friendly name of this object. Typically not required to be unique in a pan-model context.</param>
        /// <param name="guid">The GUID of this object. Typically registered as this object's ModelObject key, and thus, required to be unique in a pan-model context.</param>
        /// <param name="objectSource">The object source.</param>
        /// <param name="pulseSource">The pulse source.</param>
        /// <param name="persistentOutput">If true, then the most recent output value will be returned on any peek or pull.</param>
        public ItemSource(IModel model, string name, Guid guid, ObjectSource objectSource, IPulseSource pulseSource, bool persistentOutput = false)
        {
            InitializeIdentity(model, name, null, guid);

            if (persistentOutput)
            {
                m_output = new SimpleOutputPort(model, "Source", Guid.NewGuid(), this, new DataProvisionHandler(PersistentOutput), new DataProvisionHandler(PersistentOutput));
            }
            else
            {
                m_output = new SimpleOutputPort(model, "Source", Guid.NewGuid(), this, new DataProvisionHandler(VolatileOutput), new DataProvisionHandler(VolatileOutput));
            }
            // m_ports.AddPort(m_output); <-- Done in port's ctor.
            m_objectSource          = objectSource;
            m_pulseSource           = pulseSource;
            pulseSource.PulseEvent += new PulseEvent(OnPulse);

            IMOHelper.RegisterWithModel(this);

            model.Starting += new ModelEvent(delegate(IModel theModel) { m_latestEmission = null; });
        }
Example #24
0
        public void ProcessRequest(HttpContext context)
        {
            CruiseObjectSourceInitializer sourceSetup = (CruiseObjectSourceInitializer)context.Session[CruiseObjectSourceInitializerName];
            ObjectSource objectSource = null;

            if (sourceSetup == null)
            {
                ObjectionStore objectionStore = new ObjectionStore(
                    new CachingImplementationResolver(new NMockAwareImplementationResolver(), new CachedTypeMap(context.Cache, RESOLVED_TYPE_MAP)),
                    new MaxLengthConstructorSelectionStrategy());
                sourceSetup = new CruiseObjectSourceInitializer(objectionStore);
                sourceSetup.SetupObjectSourceForFirstRequest(context);
                context.Session[CruiseObjectSourceInitializerName] = sourceSetup;
            }
            objectSource = sourceSetup.UpdateObjectSourceForRequest(context);

            context.Response.AppendHeader("X-CCNet-Version",
                                          string.Format(System.Globalization.CultureInfo.CurrentCulture, "CruiseControl.NET/{0}", Assembly.GetExecutingAssembly().GetName().Version));
            Assembly.GetExecutingAssembly().GetName().Version.ToString();

            IResponse response = ((RequestController)objectSource.GetByType(typeof(RequestController))).Do();

            response.Process(context.Response);
        }
Example #25
0
        public void SetupObjectSourceForFirstRequest(HttpContext context)
        {
            _objectionManager.AddInstanceForType(typeof(ObjectSource), _objectionManager);

            ObjectSource objectSource = UpdateObjectSourceForRequest(context);

            DefaultUrlBuilder urlBuilder = new DefaultUrlBuilder();

            _objectionManager.AddInstanceForType(typeof(IUrlBuilder),
                                                 new AbsolutePathUrlBuilderDecorator(
                                                     urlBuilder,
                                                     context.Request.ApplicationPath));

            _objectionManager.SetImplementationType(typeof(ICruiseRequest), typeof(RequestWrappingCruiseRequest));

            _objectionManager.SetImplementationType(typeof(IMultiTransformer), typeof(PathMappingMultiTransformer));

            _objectionManager.SetDependencyImplementationForType(typeof(PathMappingMultiTransformer), typeof(IMultiTransformer), typeof(HtmlAwareMultiTransformer));

            IDashboardConfiguration config = GetDashboardConfiguration(objectSource, context);

            _objectionManager.AddInstanceForType(typeof(IDashboardConfiguration), config);

            IRemoteServicesConfiguration remoteServicesConfig = config.RemoteServices;

            _objectionManager.AddInstanceForType(typeof(IRemoteServicesConfiguration), remoteServicesConfig);

            IPluginConfiguration pluginConfig = config.PluginConfiguration;

            _objectionManager.AddInstanceForType(typeof(IPluginConfiguration), pluginConfig);

            ISessionRetriever sessionRetriever = pluginConfig.SessionStore.RetrieveRetriever();

            _objectionManager.AddInstanceForType(typeof(ISessionRetriever), sessionRetriever);

            ISessionStorer sessionStorer = pluginConfig.SessionStore.RetrieveStorer();

            _objectionManager.AddInstanceForType(typeof(ISessionStorer), sessionStorer);

            LoadFarmPlugins(pluginConfig);
            LoadServerPlugins(pluginConfig);
            LoadProjectPlugins(pluginConfig);

            // Even if the user hasn't specified to use this plugin, we still need it registered since there are links to it elsewhere
            try
            {
                objectSource.GetByName(LatestBuildReportProjectPlugin.ACTION_NAME.ToLowerInvariant());
            }
            catch (ApplicationException)
            {
                IPlugin latestBuildPlugin = (IPlugin)objectSource.GetByType(typeof(LatestBuildReportProjectPlugin));
                AddActionInstance(latestBuildPlugin.NamedActions[0])
                .Decorate(typeof(ServerCheckingProxyAction))
                .Decorate(typeof(ProjectCheckingProxyAction))
                .Decorate(typeof(CruiseActionProxyAction))
                .Decorate(typeof(ExceptionCatchingActionProxy))
                .Decorate(typeof(SiteTemplateActionDecorator));
            }

            LoadBuildPlugins(pluginConfig);
            LoadSecurityPlugins(pluginConfig, sessionStorer);

            AddRequiredSecurityAction(LogoutSecurityAction.ActionName.ToLowerInvariant(), typeof(LogoutSecurityAction));
            AddRequiredSecurityAction(ChangePasswordSecurityAction.ActionName.ToLowerInvariant(), typeof(ChangePasswordSecurityAction));

            // ToDo - make this kind of thing specifiable by Plugins (note that this action is not wrapped with a SiteTemplateActionDecorator
            // See BuildLogBuildPlugin for linked todo
            _objectionManager.AddTypeForName(XmlBuildLogAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlBuildLogAction))
            .Decorate(typeof(ServerCheckingProxyAction))
            .Decorate(typeof(BuildCheckingProxyAction))
            .Decorate(typeof(ProjectCheckingProxyAction))
            .Decorate(typeof(CruiseActionProxyAction));

            // TODO - Xml Exceptions?
            _objectionManager.AddTypeForName(ForceBuildXmlAction.ACTION_NAME.ToLowerInvariant(), typeof(ForceBuildXmlAction))
            .Decorate(typeof(ServerCheckingProxyAction))
            .Decorate(typeof(ProjectCheckingProxyAction))
            .Decorate(typeof(CruiseActionProxyAction));

            // Supporting xml project status queries from CCTray or clients earlier than version 1.3
            // Also still used by the web dashboard for displaying farm/server reports
            _objectionManager.AddTypeForName(XmlReportAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlReportAction));
            _objectionManager.AddTypeForName(ProjectXmlReport.ActionName.ToLowerInvariant(), typeof(ProjectXmlReport))
            .Decorate(typeof(CruiseActionProxyAction));

            // Supporting cruise server project and queue status queries from CCTray or clients 1.3 or later
            _objectionManager.AddTypeForName(XmlServerReportAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlServerReportAction));

            // Security handler for CCTray or client 1.5 or later
            _objectionManager.AddTypeForName(XmlServerSecurityAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlServerSecurityAction));

            // RSS publisher
            _objectionManager.AddTypeForName(Plugins.RSS.RSSFeed.ACTION_NAME.ToLowerInvariant(), typeof(Plugins.RSS.RSSFeed))
            .Decorate(typeof(CruiseActionProxyAction));

            // Status data
            _objectionManager.AddTypeForName(ProjectStatusAction.ActionName.ToLowerInvariant(), typeof(ProjectStatusAction))
            .Decorate(typeof(ServerCheckingProxyAction))
            .Decorate(typeof(ProjectCheckingProxyAction))
            .Decorate(typeof(CruiseActionProxyAction));

            // File downloads
            _objectionManager.AddTypeForName(ProjectFileDownload.ActionName.ToLowerInvariant(), typeof(ProjectFileDownload))
            .Decorate(typeof(CruiseActionProxyAction));
            _objectionManager.AddTypeForName(BuildFileDownload.ActionName.ToLowerInvariant(), typeof(BuildFileDownload))
            .Decorate(typeof(CruiseActionProxyAction));

            // Parameters handler for CCTray or client 1.5 or later
            _objectionManager.AddInstanceForName(XmlProjectParametersReportAction.ACTION_NAME.ToLowerInvariant(),
                                                 objectSource.GetByType(typeof(XmlProjectParametersReportAction)));

            // Raw XML request handler
            _objectionManager.AddTypeForName(MessageHandlerPlugin.ActionName.ToLowerInvariant(), typeof(MessageHandlerPlugin))
            .Decorate(typeof(CruiseActionProxyAction));
        }
 public CruiseActionFactory(ObjectSource objectSource)
 {
     this.objectSource = objectSource;
 }
		public ActionInstantiatorWithObjectSource(ObjectSource objectSource)
		{
			this.objectSource = objectSource;
		}
 public void Setup()
 {
     objectSource  = mocks.StrictMock <ObjectSource>();
     actionFactory = new CruiseActionFactory(objectSource);
     request       = mocks.StrictMock <IRequest>();
 }
 private static IDashboardConfiguration GetDashboardConfiguration(ObjectSource objectSource, HttpContext context)
 {
     return(new CachingDashboardConfigurationLoader(objectSource, context));
     //			return (IDashboardConfiguration) objectSource.GetByType(typeof(IDashboardConfiguration));
 }
        // This all needs breaking up a bit (to make it testable, apart from anything else)
        public ObjectSource SetupObjectSourceForRequest(HttpContext context)
        {
            ObjectSource objectSource = (ObjectSource)objectionManager; // Yuch - put this in Object Wizard somewhere

            objectionManager.AddInstanceForType(typeof(ObjectSource), objectionManager);

            objectionManager.AddInstanceForType(typeof(HttpContext), context);
            HttpRequest request = context.Request;

            objectionManager.AddInstanceForType(typeof(HttpRequest), request);

            NameValueCollection parametersCollection = new NameValueCollection();

            parametersCollection.Add(request.QueryString);
            parametersCollection.Add(request.Form);
            objectionManager.AddInstanceForType(typeof(IRequest),
                                                new NameValueCollectionRequest(parametersCollection, request.Headers, request.Path,
                                                                               request.RawUrl, request.ApplicationPath));

            DefaultUrlBuilder urlBuilder = new DefaultUrlBuilder();

            objectionManager.AddInstanceForType(typeof(IUrlBuilder),
                                                new AbsolutePathUrlBuilderDecorator(
                                                    urlBuilder,
                                                    request.ApplicationPath));

            objectionManager.SetImplementationType(typeof(ICruiseRequest), typeof(RequestWrappingCruiseRequest));

            objectionManager.SetImplementationType(typeof(IMultiTransformer), typeof(PathMappingMultiTransformer));

            objectionManager.SetDependencyImplementationForType(typeof(PathMappingMultiTransformer), typeof(IMultiTransformer), typeof(HtmlAwareMultiTransformer));

            IDashboardConfiguration config = GetDashboardConfiguration(objectSource, context);

            objectionManager.AddInstanceForType(typeof(IDashboardConfiguration), config);

            IRemoteServicesConfiguration remoteServicesConfig = config.RemoteServices;

            objectionManager.AddInstanceForType(typeof(IRemoteServicesConfiguration), remoteServicesConfig);

            IPluginConfiguration pluginConfig = config.PluginConfiguration;

            objectionManager.AddInstanceForType(typeof(IPluginConfiguration), pluginConfig);

            ISessionRetriever sessionRetriever = pluginConfig.SessionStore.RetrieveRetriever();

            objectionManager.AddInstanceForType(typeof(ISessionRetriever), sessionRetriever);

            ISessionStorer sessionStorer = pluginConfig.SessionStore.RetrieveStorer();

            objectionManager.AddInstanceForType(typeof(ISessionStorer), sessionStorer);
            urlBuilder.SessionStorer = sessionStorer;


            System.Collections.Generic.List <string> LoadedPlugins = new System.Collections.Generic.List <string>();
            bool UnknownPluginDetected = false;

            foreach (IPlugin plugin in pluginConfig.FarmPlugins)
            {
                if (plugin == null)
                {
                    UnknownPluginDetected = true;
                }
                else
                {
                    LoadedPlugins.Add(plugin.LinkDescription);

                    foreach (INamedAction action in plugin.NamedActions)
                    {
                        if ((action as INoSiteTemplateAction) == null)
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator)).Decorate(typeof(QuerySessionActionDecorator)).Decorate(typeof(NoCacheabilityActionProxy));
                        }
                        else
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(QuerySessionActionDecorator)).Decorate(typeof(NoCacheabilityActionProxy));
                        }
                    }
                }
            }


            if (UnknownPluginDetected)
            {
                ThrowExceptionShouwingLoadedPlugins(LoadedPlugins, "FarmPlugins");
            }
            LoadedPlugins = new System.Collections.Generic.List <string>();

            foreach (IPlugin plugin in pluginConfig.ServerPlugins)
            {
                if (plugin == null)
                {
                    UnknownPluginDetected = true;
                }
                else
                {
                    LoadedPlugins.Add(plugin.LinkDescription);
                    foreach (INamedAction action in plugin.NamedActions)
                    {
                        if ((action as INoSiteTemplateAction) == null)
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator)).Decorate(typeof(QuerySessionActionDecorator)).Decorate(typeof(NoCacheabilityActionProxy));
                        }
                        else
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(QuerySessionActionDecorator)).Decorate(typeof(NoCacheabilityActionProxy));
                        }
                    }
                }
            }

            if (UnknownPluginDetected)
            {
                ThrowExceptionShouwingLoadedPlugins(LoadedPlugins, "ServerPlugins");
            }
            LoadedPlugins = new System.Collections.Generic.List <string>();


            foreach (IPlugin plugin in pluginConfig.ProjectPlugins)
            {
                if (plugin == null)
                {
                    UnknownPluginDetected = true;
                }
                else
                {
                    LoadedPlugins.Add(plugin.LinkDescription);
                    foreach (INamedAction action in plugin.NamedActions)
                    {
                        if ((action as INoSiteTemplateAction) == null)
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator)).Decorate(typeof(QuerySessionActionDecorator));
                        }
                        else
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(QuerySessionActionDecorator));
                        }
                    }
                }
            }

            if (UnknownPluginDetected)
            {
                ThrowExceptionShouwingLoadedPlugins(LoadedPlugins, "ProjectPlugins");
            }


            // Even if the user hasn't specified to use this plugin, we still need it registered since there are links to it elsewhere
            try
            {
                objectSource.GetByName(LatestBuildReportProjectPlugin.ACTION_NAME.ToLowerInvariant());
            }
            catch (ApplicationException)
            {
                IPlugin latestBuildPlugin = (IPlugin)objectSource.GetByType(typeof(LatestBuildReportProjectPlugin));
                objectionManager.AddInstanceForName(latestBuildPlugin.NamedActions[0].ActionName.ToLowerInvariant(), latestBuildPlugin.NamedActions[0].Action)
                .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator)).Decorate(typeof(QuerySessionActionDecorator));
            }


            LoadedPlugins = new System.Collections.Generic.List <string>();

            foreach (IBuildPlugin plugin in pluginConfig.BuildPlugins)
            {
                if (plugin == null)
                {
                    UnknownPluginDetected = true;
                }
                else
                {
                    LoadedPlugins.Add(plugin.LinkDescription);
                    foreach (INamedAction action in plugin.NamedActions)
                    {
                        if ((action as INoSiteTemplateAction) == null)
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant() + "_CONDITIONAL_GET_FINGERPRINT_CHAIN", action.Action)
                            .Decorate(typeof(CruiseActionProxyAction)).Decorate(typeof(SiteTemplateActionDecorator))
                            .Decorate(typeof(QuerySessionActionDecorator));
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(BuildCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction))
                            .Decorate(typeof(CachingActionProxy)).Decorate(typeof(ExceptionCatchingActionProxy)).Decorate(typeof(SiteTemplateActionDecorator))
                            .Decorate(typeof(QuerySessionActionDecorator));
                        }
                        else
                        {
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant() + "_CONDITIONAL_GET_FINGERPRINT_CHAIN", action.Action)
                            .Decorate(typeof(CruiseActionProxyAction))
                            .Decorate(typeof(QuerySessionActionDecorator));
                            objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(BuildCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction))
                            .Decorate(typeof(CachingActionProxy)).Decorate(typeof(ExceptionCatchingActionProxy))
                            .Decorate(typeof(QuerySessionActionDecorator));
                        }
                    }
                }
            }

            if (UnknownPluginDetected)
            {
                ThrowExceptionShouwingLoadedPlugins(LoadedPlugins, "BuildPlugins");
            }
            LoadedPlugins = new System.Collections.Generic.List <string>();

            // Security plugins (for handling authentication)
            foreach (ISecurityPlugin plugin in pluginConfig.SecurityPlugins)
            {
                plugin.SessionStorer = sessionStorer;
                foreach (INamedAction action in plugin.NamedActions)
                {
                    if ((action as INoSiteTemplateAction) == null)
                    {
                        objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                        .Decorate(typeof(ServerCheckingProxyAction))
                        .Decorate(typeof(CruiseActionProxyAction))
                        .Decorate(typeof(ExceptionCatchingActionProxy))
                        .Decorate(typeof(SiteTemplateActionDecorator))
                        .Decorate(typeof(QuerySessionActionDecorator))
                        .Decorate(typeof(NoCacheabilityActionProxy));
                    }
                    else
                    {
                        objectionManager.AddInstanceForName(action.ActionName.ToLowerInvariant(), action.Action)
                        .Decorate(typeof(ServerCheckingProxyAction))
                        .Decorate(typeof(CruiseActionProxyAction))
                        .Decorate(typeof(ExceptionCatchingActionProxy))
                        .Decorate(typeof(QuerySessionActionDecorator))
                        .Decorate(typeof(NoCacheabilityActionProxy));
                    }
                }
            }

            if (UnknownPluginDetected)
            {
                ThrowExceptionShouwingLoadedPlugins(LoadedPlugins, "SecurityPlugins");
            }

            AddRequiredSecurityAction(LogoutSecurityAction.ActionName.ToLowerInvariant(), typeof(LogoutSecurityAction));
            AddRequiredSecurityAction(ChangePasswordSecurityAction.ActionName.ToLowerInvariant(), typeof(ChangePasswordSecurityAction));

            // ToDo - make this kind of thing specifiable by Plugins (note that this action is not wrapped with a SiteTemplateActionDecorator
            // See BuildLogBuildPlugin for linked todo
            objectionManager.AddTypeForName(XmlBuildLogAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlBuildLogAction))
            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(BuildCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction));

            // TODO - Xml Exceptions?
            objectionManager.AddTypeForName(ForceBuildXmlAction.ACTION_NAME.ToLowerInvariant(), typeof(ForceBuildXmlAction))
            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction));

            // Supporting xml project status queries from CCTray or clients earlier than version 1.3
            // Also still used by the web dashboard for displaying farm/server reports
            objectionManager.AddTypeForName(XmlReportAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlReportAction));
            objectionManager.AddTypeForName(ProjectXmlReport.ActionName.ToLowerInvariant(), typeof(ProjectXmlReport)).Decorate(typeof(CruiseActionProxyAction));

            // Supporting cruise server project and queue status queries from CCTray or clients 1.3 or later
            objectionManager.AddTypeForName(XmlServerReportAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlServerReportAction));

            // Security handler for CCTray or client 1.5 or later
            objectionManager.AddTypeForName(XmlServerSecurityAction.ACTION_NAME.ToLowerInvariant(), typeof(XmlServerSecurityAction));

            // RSS publisher
            objectionManager.AddTypeForName(Plugins.RSS.RSSFeed.ACTION_NAME.ToLowerInvariant(), typeof(Plugins.RSS.RSSFeed)).Decorate(typeof(CruiseActionProxyAction));

            // Status data
            objectionManager.AddTypeForName(ProjectStatusAction.ActionName.ToLowerInvariant(), typeof(ProjectStatusAction))
            .Decorate(typeof(ServerCheckingProxyAction)).Decorate(typeof(ProjectCheckingProxyAction)).Decorate(typeof(CruiseActionProxyAction));

            // File downloads
            objectionManager.AddTypeForName(ProjectFileDownload.ActionName.ToLowerInvariant(), typeof(ProjectFileDownload)).Decorate(typeof(CruiseActionProxyAction));
            objectionManager.AddTypeForName(BuildFileDownload.ActionName.ToLowerInvariant(), typeof(BuildFileDownload)).Decorate(typeof(CruiseActionProxyAction));

            // Parameters handler for CCTray or client 1.5 or later
            objectionManager.AddInstanceForName(XmlProjectParametersReportAction.ACTION_NAME.ToLowerInvariant(),
                                                objectSource.GetByType(typeof(XmlProjectParametersReportAction)));

            // Raw XML request handler
            objectionManager.AddTypeForName(MessageHandlerPlugin.ActionName.ToLowerInvariant(),
                                            typeof(MessageHandlerPlugin)).Decorate(typeof(CruiseActionProxyAction));

            return(objectSource);
        }
 public ObjectionNetReflectorInstantiator(ObjectSource objectSource)
 {
     this.objectSource = objectSource;
 }
 private static IDashboardConfiguration GetDashboardConfiguration(ObjectSource objectSource, HttpContext context)
 {
     return new CachingDashboardConfigurationLoader(objectSource, context);
     //			return (IDashboardConfiguration) objectSource.GetByType(typeof(IDashboardConfiguration));
 }
 public ActionInstantiatorWithObjectSource(ObjectSource objectSource)
 {
     this.objectSource = objectSource;
 }
		public void Setup()
		{
			objectSource = mocks.StrictMock<ObjectSource>();
			actionFactory = new CruiseActionFactory(objectSource);
			request = mocks.StrictMock<IRequest>();
		}
		public ObjectionNetReflectorInstantiator(ObjectSource objectSource)
		{
			this.objectSource = objectSource;
		}
 public CruiseActionFactory(ObjectSource objectSource)
 {
     this.objectSource = objectSource;
 }
Example #37
0
 public override void Start()
 {
     ObjectSource = new ObjectSource();
 }