public IRun Run(IOperationNode operationNode, IModelHolder modelHolder)
        {
            IOperation operation = operationNode as IOperation;
            if (null == operation)
            {
                throw new WrongTypeException(typeof(IOperation), operationNode);
            }

            IRun retValue = new Run(operationNode, modelHolder, RunStatusEnumeration.Waiting);

            try
            {
                retValue.RunStatus = RunStatusEnumeration.Running;

                operation.Execute(modelHolder);

                retValue.RunStatus = RunStatusEnumeration.Finished;
            }
            catch (Exception ex)
            {
                retValue.RunStatus = RunStatusEnumeration.Errored;

                throw ex;
            }

            return retValue;
        }
        protected TModel GetModelFromProvider(UnityEngine.Object potentialProvider)
        {
            TModel model = null;
            IModelProvider <TModel> modelProvider = null;
            IModelHolder <TModel>   modelHolder   = null;

            try
            {
                modelProvider = (IModelProvider <TModel>)potentialProvider;
            }
            catch (System.InvalidCastException)
            {
            }

            try
            {
                modelHolder = (IModelHolder <TModel>)potentialProvider;
            }
            catch (System.InvalidCastException)
            {
            }

            if (modelProvider != null)
            {
                model = modelProvider.Model();
            }
            else if (modelHolder != null)
            {
                model = modelHolder.Model;
            }

            return(model);
        }
Beispiel #3
0
 public BackgroundTaskQueue(
     IModelHolder modelHolder,
     IConfiguration configuration,
     ILogger <BackgroundTaskQueue> logger)
 {
     _logger      = logger;
     _modelHolder = modelHolder;
 }
Beispiel #4
0
        public Run(IOperationNode operationNode, IModelHolder modelHolder, RunStatusEnumeration runStatus)
        {
            OperaionNode = operationNode;
            ModelHolder = modelHolder;
            RunStatus = runStatus;

            Setup();
        }
 public static LabelSuggestion Predict(PrModel issue, ILogger logger, IModelHolder modelHolder)
 {
     if (modelHolder.UseIssuesForPrsToo)
     {
         return(Predict(issue, modelHolder.IssuePredEngine, logger));
     }
     return(Predict(issue, modelHolder.PrPredEngine, logger));
 }
Beispiel #6
0
        public static T CreateClientModel <T>(IModelHolder modelHolder) where T : class
        {
            var dynamicType    = GetWrapper(typeof(T));
            var dynamicWrapper = (ModelBase)Activator.CreateInstance(dynamicType);

            dynamicWrapper.ModelHolder = modelHolder;

            return(dynamicWrapper as T);
        }
        public IRun Run(IOperationNode operationNode, IModelHolder modelHolder)
        {
            IOperationPipeline pipeline = operationNode as IOperationPipeline;
            if (null == pipeline)
            {
                throw new WrongTypeException(typeof(IOperationPipeline), operationNode);
            }

            IRun retValue = new Run(operationNode, modelHolder, RunStatusEnumeration.Waiting);

            IModelHolder pipelineModelHolder = pipeline.GetModelHolderFromParentModelHolder(modelHolder);

            BasicOperationRunner basicOperationRunner = new BasicOperationRunner();

            retValue.RunStatus = RunStatusEnumeration.Starting;

            for (int iOperationNode = 0; iOperationNode < pipeline.Count; iOperationNode++)
            {
                IOperationNode curNode = pipeline[iOperationNode];

                IRun curRun;
                if (curNode is IOperation)
                {
                    curRun = basicOperationRunner.Run(curNode, pipelineModelHolder);
                }
                else
                {
                    // Assume if the node is not an operation, it's an operation pipeline. Recurse.
                    curRun = this.Run(curNode, pipelineModelHolder);
                }

                retValue.SubRuns.Add(curRun);

                // Allow stopping on errors.
                if (curRun.RunStatus == RunStatusEnumeration.Errored)
                {
                    if (curNode.OnErrorBlock)
                    {
                        break;
                    }
                }
            }

            pipeline.SetModelHolderInParentModelHolder(pipelineModelHolder, modelHolder);

            if (HasErroredSubNodeOperations(retValue))
            {
                retValue.RunStatus = RunStatusEnumeration.Errored;
            }
            else
            {
                retValue.RunStatus = RunStatusEnumeration.Finished;
            }

            return retValue;
        }
Beispiel #8
0
        protected override void Start()
        {
            base.Start();

            if (targetingProvider != null)
            {
                IModelHolder <TargetingModel> holder = (IModelHolder <TargetingModel>)targetingProvider;

                targetingModel = holder.Model;

                targetingModel.registerTurret(Model);
            }
        }
 public WebhookIssueController(
     ILabeler labeler,
     ILogger <WebhookIssueController> logger,
     IConfiguration configuration,
     IModelHolder modelHolder,
     IBackgroundTaskQueue backgroundTaskQueue)
 {
     _modelHolder         = modelHolder;
     _labeler             = labeler;
     Logger               = logger;
     _backgroundTaskQueue = backgroundTaskQueue;
     _owner               = configuration["RepoOwner"];
     _repo = configuration["RepoName"];
 }
Beispiel #10
0
 public Labeler(
     IConfiguration configuration,
     IHttpClientFactory httpClientFactory,
     ILogger <Labeler> logger,
     IModelHolder modelHolder,
     IGitHubClientWrapper gitHubClientWrapper,
     IPredictor predictor,
     IDiffHelper diffHelper)
 {
     _logger                   = logger;
     _httpClientFactory        = httpClientFactory;
     _gitHubClientWrapper      = gitHubClientWrapper;
     _predictor                = predictor;
     _diffHelper               = diffHelper;
     _modelHolder              = modelHolder;
     _useIssueLabelerForPrsToo = configuration.GetSection(("UseIssueLabelerForPrsToo")).Get <bool>();
 }
        protected virtual void Start()
        {
            if (model == null)
            {
                BuildModel();
            }

            View = publicView;

            if (View != null)
            {
                try
                {
                    IControllerHolder <TController> holder = (IControllerHolder <TController>)View;

                    holder.Controller = (TController)this;

                    //Debug.Log(this + " -- " + holder + " : " + holder.Controller);
                } catch (InvalidCastException)
                {
                    Debug.LogWarning("Controller: invalid View to ControllerHolder cast");
                }
            }

            if (view != null)
            {
                try
                {
                    IModelHolder <TModel> holder = (IModelHolder <TModel>)View;

                    holder.Model = model;
                }
                catch (InvalidCastException)
                {
                    Debug.LogWarning("Controller: invalid View to ModelHolder cast");
                }
            }
        }
        private TModel getModelFromProvider()
        {
            TModel model = null;
            IModelProvider <TModel> modelProvider = null;
            IModelHolder <TModel>   modelHolder   = null;

            try
            {
                modelProvider = (IModelProvider <TModel>)publicModelProvider;
            }
            catch (System.InvalidCastException)
            {
                Debug.LogWarning("Controller: Object to IModelProvider cast error");
            }
            if (modelProvider == null)
            {
                try
                {
                    modelHolder = (IModelHolder <TModel>)publicModelProvider;
                }
                catch (System.InvalidCastException)
                {
                    Debug.LogWarning("Controller: Object to IModelHolder cast error");
                }
            }

            if (modelProvider != null)
            {
                model = modelProvider.Model();
            }
            else if (modelHolder != null)
            {
                model = modelHolder.Model;
            }

            return(model);
        }
Beispiel #13
0
        protected virtual void ExtractModel()
        {
            TModel model = null;
            IModelHolder <TModel> holder = null;

            try
            {
                holder = (IModelHolder <TModel>)Controller;
            } catch (System.InvalidCastException) {
                Debug.Log("GenericView: invalid Controller to IModelHolder cast");
            }

            if (holder != null)
            {
                model = holder.Model;
            }

            if (model == null)
            {
                Model = GetModelFromProvider(publicModelProvider);
            }

            Model = model;
        }
Beispiel #14
0
 public Predictor(IModelHolder modelHolder)
 {
     _modelHolder = modelHolder;
 }
Beispiel #15
0
 public static async Task Setup(IModelHolder modelHolder = null)
 {
     ModelHolder = modelHolder;
     await InstallVoiceCommands();
     await InstallPhrases();
 }
Beispiel #16
0
 public static async Task Setup(IModelHolder modelHolder=null)
 {
     ModelHolder = modelHolder;
     await InstallVoiceCommands();
     await InstallPhrases();
 }
 public static LabelSuggestion Predict(IssueModel issue, ILogger logger, IModelHolder modelHolder)
 {
     return(Predict(issue, modelHolder.IssuePredEngine, logger));
 }