protected string GenerateAgent(AgentType agentType, SystemType systemType)
        {
            var agentFactory = new AgentFactory();
            var agent        = agentFactory.CreateAgent(agentType, systemType);

            return(agent.ToString());
        }
Пример #2
0
        public static void TestClassInitialize(TestContext testContext)
        {
            Test.Info(string.Format("{0} Class Initialize", testContext.FullyQualifiedTestClassName));
            Test.FullClassName = testContext.FullyQualifiedTestClassName;

            //add the common initialization
            if (StorageAccount == null)
            {
                StorageAccount = GetCloudStorageAccountFromConfig(useHttps: useHttps);
                Test.Info("Got storage account from config: {0}", StorageAccount.ToString(true));
            }

            //init the blob helper for blob related operations
            blobUtil  = new CloudBlobUtil(StorageAccount);
            queueUtil = new CloudQueueUtil(StorageAccount);
            tableUtil = new CloudTableUtil(StorageAccount);
            fileUtil  = new CloudFileUtil(StorageAccount);
            random    = new Random();

            SetCLIEnv(testContext);

            if (null == CommandAgent)
            {
                CommandAgent = AgentFactory.CreateAgent(testContext.Properties);
            }
        }
        private string GenerateAgent()
        {
            var randAgent  = GenerateRandomNumber(2);
            var randSystem = GenerateRandomNumber(3);

            var agentFactory = new AgentFactory();

            return(agentFactory.CreateAgent((AgentType)randAgent, (SystemType)randSystem).ToString());
        }
Пример #4
0
        public override void InitAgent()
        {
            CommandAgent = AgentFactory.CreateAgent(TestContext.Properties);

            SetCLIEnv(TestContext);

            Test.Start(TestContext.FullyQualifiedTestClassName, TestContext.TestName);
            OnTestSetup();
        }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        var agent = (Citizen)AgentFactory.CreateAgent(AgentClass.Adult);

        agent.setAgent_name("Joe Smith");

        AgentFactory.CreateAgent(AgentClass.Adult);

        BuildingFactory.createBuilding(BuildingClass.Residential);
    }
Пример #6
0
        protected JsonResult Json <TAgent, TViewModel, TRequestData>(Guid itemId, TRequestData agentParameters)
            where TAgent : Agent <TViewModel>
            where TViewModel : BaseViewModel, new()
        {
            var agentContext = new AgentContext(IgnitionControllerContext, SitecoreContext, new NullPage(), SitecoreContext.GetItem <IModelBase>(itemId))
            {
                AgentParameters = agentParameters,
            };
            var agent = AgentFactory.CreateAgent <TAgent, TViewModel>(agentContext);

            agent.PopulateModel();

            return(Json(agent.ViewModel));
        }
Пример #7
0
        protected ViewResult View <TAgent, TViewModel, TParams>(object agentParameters)
            where TAgent : Agent <TViewModel>
            where TViewModel : BaseViewModel, new()
            where TParams : class, IParamsBase
        {
            var moduleName = GetType().Name.Replace(GetType().Namespace ?? string.Empty, string.Empty).Replace("Controller", string.Empty);

            Context.ContextPage         = GetContextItem <IPage>(true, true);
            Context.ModuleWrapperName   = moduleName;
            Context.RenderingParameters = GetRenderingParameters <TParams>();
            Context.AgentParameters     = agentParameters;
            var agent = AgentFactory.CreateAgent <TAgent, TViewModel>(Context);

            agent.PopulateModel();
            return(View(agent.ViewPath, agent.ViewModel));
        }
Пример #8
0
        protected ActionResult GetViewResult <TAgent, TViewModel, TParams>(TParams parameters, Dictionary <string, object> viewdata)
            where TAgent : Agent <TViewModel>
            where TViewModel : BaseViewModel, new()
            where TParams : IParamsBase
        {
            var moduleName = GetType().Name.Replace(GetType().Namespace ?? string.Empty, string.Empty).Replace("Controller", string.Empty);

            Context.ContextPage         = GetContextItem <IPage>(true, true);
            Context.ModuleWrapperName   = moduleName;
            Context.RenderingParameters = parameters;
            Context.ViewData            = viewdata;
            var agent = AgentFactory.CreateAgent <TAgent, TViewModel>(Context);

            agent.PopulateModel();
            return(View(agent.ViewPath, agent.ViewModel));
        }
Пример #9
0
        protected ViewResult View <TAgent, TViewModel, TParams>(object agentParameters)
            where TAgent : Agent <TViewModel>
            where TViewModel : BaseViewModel, new()
            where TParams : class, IParamsBase
        {
            var contextPage         = GetContextItem <IPage>(true, true) ?? new NullPage();
            var datasourceItem      = GetDataSourceItem();
            var renderingParameters = GetRenderingParameters <TParams>();
            var agentContext        = new AgentContext(IgnitionControllerContext, SitecoreContext, contextPage, datasourceItem)
            {
                AgentParameters     = agentParameters,
                RenderingParameters = renderingParameters
            };

            var agent = AgentFactory.CreateAgent <TAgent, TViewModel>(agentContext);

            agent.PopulateModel();

            return(View(agent.ViewPath, agent.ViewModel));
        }
Пример #10
0
        private Agent CreateAgentInstance(AgentRecord agentRecord)
        {
            AgentFactory agentFactory = this.settings.AgentFactories[agentRecord.Id];
            object       state        = (this.hostState == null) ? null : this.hostState.Clone();
            Agent        agent;

            try
            {
                agent = agentFactory.CreateAgent(agentRecord.Type, state);
            }
            catch (LocalizedException ex)
            {
                MExDiagnostics.EventLog.LogEvent(EdgeExtensibilityEventLogConstants.Tuple_MExAgentInstanceCreationFailure, null, new object[]
                {
                    agentRecord.Name,
                    ex.Message
                });
                throw;
            }
            if (agent == null || agent.Id != null)
            {
                string error             = (agent == null) ? "agent instance cannot be null" : "agent instance already in use";
                ApplicationException ex2 = new ApplicationException(MExRuntimeStrings.AgentCreationFailure(agentRecord.Name, error));
                MExDiagnostics.EventLog.LogEvent(EdgeExtensibilityEventLogConstants.Tuple_MExAgentInstanceCreationFailure, null, new object[]
                {
                    agentRecord.Name,
                    ex2.Message
                });
                throw ex2;
            }
            agent.Id              = agent.GetHashCode().ToString(CultureInfo.InvariantCulture);
            agent.Name            = agentRecord.Name;
            agent.SnapshotEnabled = this.settings.MonitoringOptions.MessageSnapshotEnabled;
            agent.HostState       = state;
            ExTraceGlobals.DispatchTracer.Information <string, string>((long)this.GetHashCode(), this.InstanceNameFormatted + "agent '{0}' created from factory '{1}'", agent.GetType().FullName, agentFactory.GetType().FullName);
            return(agent);
        }