public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputGenesisExecutionResult();

            if (!Directory.Exists(Config.OutputPath)) //TODO: Worry about the output path in the OutputGenerator base
            {
                Directory.CreateDirectory(Config.OutputPath);
            }

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            var outPath = Path.Combine(Config.OutputPath, "Mapper.cs");

            var output = Template.Raw
                         .Replace("~MAPPING_CODE~", string.Join(Environment.NewLine, _lines))
                         .Replace(Tokens.DepsModelNamespace, Config.ModelNamespace)
                         .Replace(Tokens.DepsDtoNamespace, Config.DtoNamespace)
                         .Replace(Tokens.DepsNamespace, Config.DepsNamespace)
                         .Replace(Tokens.Namespace, Config.Namespace);

            File.WriteAllText(outPath, output);

            result.Success = true;

            return(result);
        }
Exemplo n.º 2
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new BlankGenesisExecutionResult();

            var alc = new AssemblyLoadContext("DotNetAssembly", true);

            using var stream = File.OpenRead(Config.AssemblyPath);

            var asm = alc.LoadFromStream(stream);

            if (Config.OnlyGenesisDecorations)
            {
                foreach (var t in asm.DefinedTypes.Where(w => // pull objects with GenesisObject attribute
                                                         w.CustomAttributes.SingleOrDefault(ca => ca.AttributeType == typeof(GenesisObjectAttribute)) != null))
                {
                    InsertGraphFromType(genesis, t);
                }
            }
            else // use all public objects
            {
                foreach (var t in asm.DefinedTypes)
                {
                    InsertGraphFromType(genesis, t);
                }
            }

            return(await Task.FromResult(result));
        }
Exemplo n.º 3
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            Text.DarkYellowLine("Paused... press the any key");
            Console.ReadKey();

            return(await Task.FromResult(new BlankTaskResult()));
        }
Exemplo n.º 4
0
        public static void InitCompanyData(GenesisContext context)
        {
            try
            {
                //hejehj
                var adr   = new Address("Nejlikegatan 3", "70353", "Örebro");
                var comp1 = context.Companies.Find("o1");
                if (comp1 != null)
                {
                    context.Companies.Remove(comp1);

                    context.SaveChanges();
                }
                var comp = new Company("o1", "n1", "*****@*****.**", "p1", adr);
                var dep1 = new Department("Olaigatan", adr, "phone1");
                dep1.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(15));
                dep1.AddExceptionDay(new DateTime(2018, 2, 24));
                dep1.AddExceptionDay(new DateTime(2018, 2, 28));
                comp.Departments.Add(dep1);
                context.Companies.Add(comp);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
 public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
 {
     return(await Task.FromResult(new OutputGenesisExecutionResult()
     {
         Success = true, Message = "Bad command or file name"
     }));                                                                                                                       //heh
 }
Exemplo n.º 6
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            await CommandLoader.InitAsync(args);

            Text.Line();
            Text.Cyan("Genesis"); Text.GrayLine($" {Program.GetVersionDisplayString()}");
            Text.Line();

            foreach (var cmd in CommandLoader.Commands)
            {
                if (cmd.Name == string.Empty) //default command leaves an empty line otherwise
                {
                    continue;
                }

                Text.Green($"\t{cmd.Name}"); Text.WhiteLine($"\t{cmd.Description}");
            }

            Text.Line();

            return(await Task.FromResult(new BlankGenesisExecutionResult()
            {
                Success = true, Message = ""
            }));
        }
Exemplo n.º 7
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new BlankTaskResult()
            {
                Success = true, Message = ""
            };

            Text.Line();
            Text.YellowLine("Scanning for Inputs:");
            await InputManager.InitializePopulatorsAsync(true);

            Text.Line();

            Text.YellowLine("Scanning for Outputs:");
            await OutputManager.InitializeGeneratorsAsync(true);

            Text.Line();

            Console.ForegroundColor = (InputManager.Inputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
            Console.Write($@"{InputManager.Inputs.Count}");
            Console.ResetColor();
            Console.WriteLine($" Populator(s)");

            Console.ForegroundColor = (OutputManager.Outputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
            Console.Write($"{OutputManager.Outputs.Count}");
            Console.ResetColor();
            Console.WriteLine(" Generator(s)");

            genesis.ScanCount++;

            return(await Task.FromResult(result));
        }
Exemplo n.º 8
0
        private static void CreateObjectMethodGraphs(GenesisContext genesis, TypeInfo cls, ObjectGraph obj)
        {
            var events = new List <string>();

            foreach (var m in cls.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
            {
                if (m.Name.StartsWith("get_") || m.Name.StartsWith("set_"))
                {
                    continue; //already did property accessors
                }
                if (m.Name.StartsWith("add_") || m.Name.StartsWith("remove_"))
                {
                    var name = m.Name.Split('_')[1]; //just get the event Name
                    if (!events.Contains(name))
                    {
                        events.Add(name);
                    }
                }

                Debug.WriteLine($@"Method:{(_nullableRegex.IsMatch(m.Name) ? _nullableRegex.Match(m.Name).Value : m.Name)}");
                var methodGraph = new MethodGraph
                {
                    Name                      = _nullableRegex.IsMatch(m.Name) ? _nullableRegex.Match(m.Name).Value : m.Name,
                    MethodVisibility          = MethodVisibilities.Public,
                    ReturnDataType            = m.ReturnType,
                    ReturnTypeFormattedName   = m.ReturnType.GetFormattedName(),
                    HasGenericParams          = m.ContainsGenericParameters,
                    IsGeneric                 = m.IsGenericMethod,
                    FormattedGenericArguments = m.GetGenericArguments().ToFormattedNames(),
                };

                foreach (var par in m.GetParameters().OrderBy(o => o.Position))
                {
                    var mp = new ParameterGraph
                    {
                        DataType = par.ParameterType,
                        DataTypeFormattedName = par.ParameterType.GetFormattedName(),
                        DisplayName           = par.ParameterType.GetDisplayName(),
                        Name       = par.Name,
                        IsOut      = par.IsOut,
                        IsIn       = par.IsIn,
                        IsOptional = par.IsOptional,
                        Position   = par.Position,
                        IsGeneric  = par.ParameterType.IsGenericType,
                        IsGenericMethodParameter          = par.ParameterType.IsGenericMethodParameter,
                        GenericArgumentFormattedTypeNames = par.ParameterType.GetGenericArguments().ToFormattedNames(),
                    };

                    methodGraph.Parameters.Add(mp);
                }

                obj.Methods.Add(methodGraph);

                Text.GrayLine(
                    $"\tMethod: {m.Name}, Return: {methodGraph.ReturnTypeFormattedName}, Visibility: {(m.IsPublic ? "public" : m.IsPrivate ? "private" : "protected")}");
            }

            genesis.Objects.Add(obj);
        }
Exemplo n.º 9
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new InputTaskResult();

            if (args.Length == 1 || HelpWasRequested(args)) //just 'gen' or 'gen --help,-?'
            {
                Console.WriteLine("Usage:");
                Console.WriteLine($"\t{Name} <Populator>\t\t\tSet the current populator to the type provided.");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine($"\t'{Name} PopulatorName'");
                Console.ResetColor();
                Console.WriteLine();

                if (InputManager.Inputs.Count == 0) //NO Inputs Found
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write("There are no populators discovered yet. Run a '");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("scan");
                    Console.ResetColor();
                    Console.WriteLine("'.");
                }
                else //Inputs were found
                {
                    Console.WriteLine("Known Inputs:");
                    foreach (var item in InputManager.Inputs)
                    {
                        Text.White("Command: "); Text.Green($@"{item.CommandText}"); Text.White(" From: "); Text.Cyan($"'{item.GetType().Name}'"); Text.WhiteLine($"\t\t{ item.Description} ");
                    }
                }
                result.Success = true;
                result.Message = string.Empty;
            }
            else
            {
                var populator = InputManager.Inputs.Find(g => g.CommandText.Trim().ToLower() == args[1].Trim().ToLower());
                if (populator != null)
                {
                    await genesis.ConfigurePopulator(populator);

                    Text.White($@"The current Populator is now: "); Text.CyanLine($"'{populator.GetType().Name}'");
                    result.Success = true;
                    result.Message = string.Empty;
                }
                else
                {
                    Console.Write("'");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(args[1]);
                    Console.ResetColor();
                    Console.Write("'");
                    Console.WriteLine(" is not a known Populator name.");

                    result.Message = "Invalid Populator.Name";
                }
            }

            return(await Task.FromResult(result));
        }
Exemplo n.º 10
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            //NOTE: This apparently can't affect anything on the Program class itself. (without some voodoo)
            //So, just dump some text and check for this command in Program.
            Text.DarkYellowLine("Breaking...");

            return(await Task.FromResult(new BlankTaskResult()));
        }
Exemplo n.º 11
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var net        = new HttpClient();
            var yamlString = await net.GetStringAsync(Config.Address);

            Text.DarkYellowLine(yamlString);

            return(await base.Execute(genesis, args));
        }
Exemplo n.º 12
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            Debug.WriteLine($@"{GetType().Name}.{nameof(Execute)}");
            Console.WriteLine("Exiting");

            Environment.Exit(0); //untz

            return(await Task.FromResult(new BlankTaskResult()));
        }
Exemplo n.º 13
0
        public CompanyRepositoryTests()
        {
            var options = new DbContextOptionsBuilder <GenesisContext>()
                          .UseInMemoryDatabase("TestInMemoryDb")
                          .Options;

            _context = new GenesisContext(options);
            BuildContext();
            _repository = new CompanyRepository(_context);
        }
Exemplo n.º 14
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            genesis.Objects.Clear();
            Text.GrayLine("Objects have been reset");

            Text.WhiteLine("Clearing the Chain");
            genesis.Chain.Clear();

            return(await Task.FromResult(new BlankGenesisExecutionResult())); //because nothing broke and we have nothing to report. :| (uh)
        }
Exemplo n.º 15
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputGenesisExecutionResult();

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(result);
        }
Exemplo n.º 16
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            Text.DarkGrayLine($@"Generating MVC Controllers in: {Config.OutputPath}");

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(new OutputGenesisExecutionResult());
        }
Exemplo n.º 17
0
        public ImportSectionViewModel(IExcelService excelService)
        {
            DisplayName = "Import";
            Order = 50;

            context = new GenesisContext();
            this.excelService = excelService;

            Sheets = new ObservableCollection<string>();
            Columns = new ObservableCollection<ColumnViewModel>();
        }
Exemplo n.º 18
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputTaskResult(); //overridden just to loop over all the graphs

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(result);
        }
Exemplo n.º 19
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            //NOTE: This apparently can't affect anything on the Program class itself. (without some voodoo)
            //So, just dump some text and check for this command in Program.
            Text.DarkYellowLine("Breaking...");
            Text.Yellow($"Dumping to a prompt, [");
            Text.CliCommand(GetType().Name.Replace("Command", ""));
            Text.YellowLine($"] was called.");
            Text.Line();

            return(await Task.FromResult(new BlankGenesisExecutionResult()));
        }
Exemplo n.º 20
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            Text.DarkGrayLine($@"Generating MVC Controllers in: {Config.OutputPath}");
            var result = new OutputGenesisExecutionResult(); //overridden just to loop over all the graphs

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(result);
        }
        protected override void OnActivate()
        {
            base.OnActivate();

            if (context != null)
                context.Dispose();

            context = new GenesisContext();

            Localities.Clear();
            Localities.AddRange(context.Localities);
        }
Exemplo n.º 22
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputTaskResult();

            if (args.Length == 1) //config
            {
                await OnHelpRequested(args);
            }
            else if (args.Length == 2) //config executorname
            {
                WriteExecutorDetails(args[1]);
            }
            else
            {
                var generator = OutputManager.Outputs.Find(g => g.CommandText.Trim().ToLower().Equals(args[1].Trim().ToLower(), StringComparison.Ordinal));
                var populator = InputManager.Inputs.Find(p => p.CommandText.Trim().ToLower() == args[1].Trim().ToLower());

                var chunks       = args[2].Split('=');
                var propertyName = chunks[0];

                if (generator != null)
                {
                    if (!await generator.EditConfig(chunks[0], chunks[1]))
                    {
                        Text.RedLine("Couldn't update value");
                    }
                    else
                    {
                        result.Success = true;
                    }
                }
                else if (populator != null)
                {
                    if (!await populator.EditConfig(chunks[0], chunks[1]))
                    {
                        Text.RedLine("Couldn't update value");
                    }
                    else
                    {
                        result.Success = true;
                    }
                }
                else
                {
                    Text.Command(args[1]);
                    Text.RedLine(" is not a known Executor. ("); Text.FriendlyText("Input", false); Text.Red(" or "); Text.FriendlyText("Output"); Text.RedLine(".");

                    result.Message = "Invalid Executor";
                }
            }
            return(await Task.FromResult(result));
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            //    var optionsBuilder = new DbContextOptionsBuilder<GenesisContext>();
            //optionsBuilder.UseSqlServer("Data Source =.\\sqlexpress; Initial Catalog = Genesis; Integrated Security = True; MultipleActiveResultSets = True");
            var optionsBuilder = new DbContextOptionsBuilder <GenesisContext>();

            optionsBuilder.UseSqlServer("Server=tcp:genesissqlserver.database.windows.net,1433;Initial Catalog=genesis;Persist Security Info=False;User ID={genesisadmin};Password={Shafiro1};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");


            var dbc = new GenesisContext(optionsBuilder.Options);

            //AppData.InitCompanyData(dbc);
            HallsInfo.Init(dbc);
            Console.WriteLine("Hello World!");
        }
Exemplo n.º 24
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var btr = new BlankGenesisExecutionResult();

            var exeName = args[1];

            //NOTE: Added that default help stuff for commands. Copy / Pasted 'gen' command here ;)

            var exe = GetExecutor(exeName);
            await exe.DisplayConfiguration();

            Text.Line();

            return(await Task.FromResult(btr));
        }
Exemplo n.º 25
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            if (args.Length == 2)
            {
                WriteUsage();
                return(await Task.FromResult(new BlankGenesisExecutionResult()));
            }

            _ = args[2].ToLower() switch
            {
                "--dump" => WriteObjectGraphToStorage(genesis),
                _ => WriteUsage()
            };
            return(await Task.FromResult(new BlankGenesisExecutionResult()));
        }
Exemplo n.º 26
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            await CommandLoader.InitAsync(args);

            Text.Line();
            Text.Cyan("Genesis"); Text.GrayLine($" {Program.GetVersionDisplayString()}");
            Text.Line();

            foreach (var cmd in CommandLoader.Commands)
            {
                Text.Green($"\t{cmd.Name}"); Text.WhiteLine($"\t{cmd.Description}");
            }
            return(await Task.FromResult(new BlankTaskResult()
            {
                Success = true, Message = ""
            }));
        }
        public SettingsSectionViewModel()
        {
            DisplayName = "Settings";
            Order = 100;

            var method = ActionMessage.GetTargetMethod;
            ActionMessage.GetTargetMethod = (message, o) =>
            {
                return method(message, o);
            };

            if (Execute.InDesignMode)
            {
                context = new GenesisContext();
                context.Species.Load();
            }
        }
Exemplo n.º 28
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            Text.Line();
            Text.DarkCyanLine("How this works:");
            Text.White("*");
            Text.YellowLine("\tDiscover Executor interfaces in the libraries that are right next to the cli. (for now)");
            Text.CliCommand("\tscan", false); Text.Line();
            Text.Yellow("\tAdd an Executor to the chain. "); Text.GrayLine("(probably an Input/Source/Origin)");
            Text.CliCommand("\tadd ", false); Text.CliCommand("mssql", false); Text.GrayLine();
            Text.Yellow("\tAdd another Executor. "); Text.GrayLine("(Output/Destination/Target)");
            Text.CliCommand("\tadd ", false); Text.CliCommand("poco", false); Text.GrayLine();
            Text.Yellow("\tExecute the chain sequentially. mssql populates ObjectGraphs, then poco reads them and writes out class files."); Text.GrayLine();
            Text.CliCommand("\texec chain ", false); Text.DarkGrayLine("\t\t\t\t(double check config for mssql.ConnectionString");
            Text.Line();
            Text.Line();
            Text.GrayLine("This effectively reads sql schema so that a poco generator can access that schema and do what it needs to. In this case, it's to write c# class files for each of the Sql Table objects.");

            return(await Task.FromResult(new BlankGenesisExecutionResult { Success = true, Message = "" }));;
        }
Exemplo n.º 29
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new BlankGenesisExecutionResult()
            {
                Success = true, Message = ""
            };

            Text.Line();
            Text.YellowLine("Scanning for Inputs:");
            await InputManager.InitializeInputsAsync(true);

            Text.Line();

            Text.YellowLine("Scanning for Outputs:");
            await OutputManager.InitializeGeneratorsAsync(true);

            Text.Line();

            Text.YellowLine("Scanning for General Executors: ");
            await GeneralManager.InitializeGeneratorsAsync(true);

            Text.Line();

            Console.ForegroundColor = (InputManager.Inputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
            Text.White($@"{InputManager.Inputs.Count}");
            Text.WhiteLine($" Potential Input(s)");

            Console.ForegroundColor = (OutputManager.Outputs.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
            Text.White($"{OutputManager.Outputs.Count}");
            Text.WhiteLine(" Possible Output(s)");

            Console.ForegroundColor = (GeneralManager.Current.Count > 0) ? ConsoleColor.Green : ConsoleColor.Yellow;
            Text.White($"{GeneralManager.Current.Count}");
            Text.WhiteLine(" General Executor(s)");

            Text.Line();
            Text.White("The "); Text.Green("green"); Text.WhiteLine(" text is how you reference an Executor. ");
            Text.Line();

            genesis.ScanCount++;

            return(await Task.FromResult(result));
        }
Exemplo n.º 30
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            if (!Directory.Exists(Config.OutputPath))
            {
                Directory.CreateDirectory(Config.OutputPath);
            }

            var path = !string.IsNullOrEmpty(Config.DepsPath) && Directory.Exists(Config.DepsPath)
                            ? Config.DepsPath
                            : Config.OutputPath;

            await DepositDependencies(path);

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            return(new OutputGenesisExecutionResult());
        }
Exemplo n.º 31
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputGenesisExecutionResult();

            if (!Directory.Exists(Config.OutputPath)) //TODO: Worry about the output path in the OutputGenerator base
            {
                Directory.CreateDirectory(Config.OutputPath);
            }

            await DepositDependencies();

            foreach (var obj in genesis.Objects)
            {
                await ExecuteGraph(obj);
            }

            result.Success = true;

            return(result);
        }
Exemplo n.º 32
0
        public override async Task <IGenesisExecutionResult> Execute(GenesisContext genesis, string[] args)
        {
            var result = new OutputGenesisExecutionResult();

            try
            {
                foreach (var obj in genesis.Objects)
                {
                    await ExecuteGraph(obj);
                }
                result.Success = true;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                result.Message = e.Message;
            }

            return(result);
        }
Exemplo n.º 33
0
        public override async Task <ITaskResult> Execute(GenesisContext genesis, string[] args)
        {
            var tmp = GetSchema();

            Text.BlueLine($"{GetType().Name} created {tmp.Count} ObjectGraph(s)");

            foreach (var i in tmp)
            {
                Text.DarkYellowLine($"{i.Name}:{i.SourceType}");
                if (genesis.Objects.SingleOrDefault(x => x.KeyId == i.KeyId) == null)
                {
                    await genesis.AddObject(i); //yeah, this can blow up - leaving it for errors
                }
            }

            Text.CyanLine("Populated " + genesis.Objects.Count().ToString() + " object(s).");
            return(await Task.FromResult(new InputTaskResult {
                Success = true,
            }));
        }
        private static PropertyChangedBase WrapTraitIntoModel(Trait trait, GenesisContext context)
        {
            var ordinal = trait as OrdinalTrait;
            if (ordinal != null)
                return new OrdinalTraitViewModel(ordinal);

            var nominal = trait as NominalTrait;
            if (nominal != null)
            {
                return new NominalTraitViewModel(nominal, context);
            }

            throw new NotSupportedException("Unknown trait type.");
        }
Exemplo n.º 35
0
 public GeneViewModel(Gene gene, GenesisContext context)
     : base(gene, context)
 {
     this.gene = gene;
 }
 public MiceSheetColumnViewModel(int columnIndex, string name, GenesisContext context)
     : base(columnIndex, name)
 {
     this.context = context;
     ApplyConvention(name);
 }
Exemplo n.º 37
0
 public ChromosomeViewModel(Chromosome chromosome, GenesisContext context)
 {
     this.chromosome = chromosome;
     this.context = context;
     Genes = new ObservableCollection<GeneViewModel>(chromosome.Genes.Select(g => new GeneViewModel(g, context)));
 }
Exemplo n.º 38
0
        public async void Analyze()
        {
            currentAnalysis = new FstAnalyzer(AnalysisName, new FstAnalyzer.Settings()
            {
                Genes = Genes.Where(g => g.Selected).Select(g => g.Gene).ToList(),
                Species = SelectedSpecies
            });

            var context = new GenesisContext();
            var result = await Task.Run(() => currentAnalysis.Analyse(context));
            context.FstAnalysis.Add(result);
            context.SaveChanges();
        }
 public TraitCellEditorViewModel(Trait preselctedValue, GenesisContext context)
 {
     this.context = context;
     Trait = preselctedValue;
 }
        protected override void OnActivate()
        {
            base.OnActivate();

            context?.Dispose();
            context = new GenesisContext();

            context.Species.Load();

            traits = null;
            NotifyOfPropertyChange(() => Traits);
            NotifyOfPropertyChange(() => Species);
        }
Exemplo n.º 41
0
        public new void Refresh()
        {    
            if (context != null)
                context.Dispose();

            context = new GenesisContext();

            Genes.Clear();
            foreach (var gene in context.Genes)
            {
                Genes.Add(new GeneViewModel(gene));
            }

            NotifyOfPropertyChange(() => FstAnalysis);
            NotifyOfPropertyChange(() => Species);
            SelectedSpecies = Species.FirstOrDefault();
        }
Exemplo n.º 42
0
        protected override void OnActivate()
        {
            base.OnActivate();

            if (context != null)
                context.Dispose();
            context = new GenesisContext();

            NotifyOfPropertyChange(() => FrequencyAnalysis);
            NotifyOfPropertyChange(() => Localities);

            UpdateData();
        }
        private void ReloadData()
        {
            if (context != null)
                context.Dispose();

            context = new GenesisContext();

            Traits.Clear();
            foreach (var gene in context.Genes.OrderBy(g => g.StartBasePair))
            {
                Traits.Add(new NominalTraitViewModel(gene));
            }

            NotifyOfPropertyChange(() => FrequencyAnalysis);
        }
Exemplo n.º 44
0
        protected override void OnActivate()
        {
            base.OnActivate();

            if (context != null)
                context.Dispose();
            context = new GenesisContext();

            NotifyOfPropertyChange(() => Mice);
            NotifyOfPropertyChange(() => Genes);
        }
        public async void Analyze()
        {
            currentAnalysis = new FrequencyAnalyzer(AnalysisName, new FrequencyAnalyzer.Settings()
            {
                Traits = Traits.Where(g => g.Selected).Select(g => g.Trait).ToList()
            });

            var context = new GenesisContext();
            var result = await Task.Run(() => currentAnalysis.Analyse(context));
            context.FrequencyAnalysis.Add(result);
            context.SaveChanges();
            ReloadData();
        }
Exemplo n.º 46
0
        protected override void OnActivate()
        {
            if (context != null)
            {
                context.Dispose();
                context = new GenesisContext();
                context.Traits.Load();
            }

            LoadColumns();
        }