Exemple #1
0
 // Q. Why do return types not count as part of a method signatiure?
 public static IEnumerable <DataAttribute> create_attribute_memento
     (time.Date date)
 {
     return(new[] {
         DataAttribute.create_value("year", date.year.ToString())
         , DataAttribute.create_value("month", date.month.ToString())
         , DataAttribute.create_value("day", date.day.ToString())
     });
 }
Exemple #2
0
 public Day
     (string summary
     , time.Date date
     , IEnumerable <DiaryEntry> diary)
 {
     this.summary = summary;
     this.date    = date;
     this.diary   = diary;
 }
Exemple #3
0
 public static Memento create_memento
     (time.Date date)
 {
     return(new Memento
     {
         day = date.day
         ,
         month = date.month
         ,
         year = date.year
     });
 }
Exemple #4
0
        public static Result <domain.Day> create_day
            (IEnumerable <DataAttribute> attributes)
        {
            var errors  = new List <ResultError>();
            var summary = string.Empty;

            time.Date date  = null;
            var       diary = Enumerable.Empty <domain.DiaryEntry>();

            var create_day = (Func <domain.Day>)(() => new domain.Day(
                                                     summary
                                                     , date
                                                     , diary
                                                     ));

            attributes
            .value_for(
                "summary"
                , error: () => new SummarySerialisationError()
                )
            .match(
                success: value => summary = value
                , error: errs => errors.AddRange(errs)
                )
            ;

            attributes
            .collection_for(
                "date"
                , error: () => new DateSerialisationError()
                )
            .bind(collection => time.serialisation.Date.create_date(collection))
            .match(
                success: d => date = d
                , error: errs => errors.AddRange(errs)
                );

            attributes
            .collection_for(
                "diary"
                , error: () => new DiarySerialisationError()
                )
            // I. This does not handled failures in create_diary entry this has multiple otions and will need to be dealt with.
            .bind(EEa =>



                  EEa
                  .Select((Ea, i) => {
                return
                (DiaryEntry.create_diary_entry(



                     Ea
                     .match(s => default(IEnumerable <DataAttribute>),
                            ca => ca)



                     ));
            })
                  .Aggregate(
                      new AggregatedDiaryEntryResults()
                      , (acc, Re) => acc.add_result(Re)
                      )
                  .fmap(acc => acc.result())


                  )
            .match(
                success: diary_entries => diary = diary_entries
                , error: errs => errors.AddRange(errs)
                );

            /*
             *
             *      public static TSource Aggregate<TSource>(
             *            this IEnumerable<TSource> source
             *           ,Func<TSource, TSource, TSource> func
             *      );
             *      public static TAccumulate Aggregate<TSource, TAccumulate>(
             *           this IEnumerable<TSource> source
             *          ,TAccumulate seed
             *          ,Func<TAccumulate, TSource, TAccumulate> func
             *      );
             *      public static TResult Aggregate<TSource, TAccumulate, TResult>(
             *           this IEnumerable<TSource> source
             *          ,TAccumulate seed
             *          ,Func<TAccumulate, TSource, TAccumulate> func
             *          ,Func<TAccumulate, TResult> resultSelector
             *      );
             *
             */

            return(!errors.Any()
                 ? Result <domain.Day> .success(create_day())
                 : Result <domain.Day> .error(errors)
                   );
        }
Exemple #5
0
 var series = new TimeSeries <T>(new TimeSeriesSpan(time.Date, time.Date.AddDays(1), TimeSeriesSpan.Spacing.Spacing5Min));