Exemple #1
0
        protected override void Load(IParameters parameters)
        {
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var unit        = Unit = parameters.GetValue <string>(NavParams.UNIT);
            var plotNumber  = PlotNumber = parameters.GetValue <int>(NavParams.PLOT_NUMBER);
            var stratumCode = parameters.GetValue <string>(NavParams.STRATUM);

            //read fixcount tally populations
            var tallyPopulations = FixCNTDataservice.GetFixCNTTallyPopulations(stratumCode).ToArray();

            //foreach tally population calculate and itterate through interval values
            foreach (var tp in tallyPopulations)
            {
                var buckets  = new List <FixCNTTallyBucket>();
                var interval = tp.Min + tp.IntervalSize / 2;

                //foreach interval value try to read a tree
                do
                {
                    var treeCount = FixCNTDataservice.GetTreeCount(unit, plotNumber, stratumCode, tp.SampleGroupCode, tp.SpeciesCode, tp.LiveDead, tp.FieldName, interval);

                    buckets.Add(new FixCNTTallyBucket(tp, interval, treeCount));

                    interval += tp.IntervalSize;
                } while (interval <= tp.Max);

                tp.Buckets = buckets;
            }

            TallyPopulations = tallyPopulations;
            RaisePropertyChanged(nameof(TallyPopulations));
        }
Exemple #2
0
        internal static void Abracadabra(object item, IParameters parameters)
        {
            var props = item.GetType()
                        .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                        .Where(x => x.CanWrite);

            foreach (var prop in props)
            {
                (var name, var isRequired) = prop.GetAutoInitializeProperty();

                if (!parameters.HasKey(name, out var key))
                {
                    if (isRequired)
                    {
                        throw new ArgumentNullException(name);
                    }
                    continue;
                }

                prop.SetValue(item, parameters.GetValue(key, prop.PropertyType));
            }
        }