Example #1
0
        public override void Present <T>()
        {
            var       ps = this.presenters;
            Presenter presenter;

            lock (this.locker)
            {
                presenter = EH.FirstOrDefault(
                    ps,
                    p => p is T);
            }

            if (presenter == null)
            {
                return;
            }

            lock (this.locker)
            {
                foreach (var p in ps)
                {
                    p.Stop();
                }
            }

            this.startPresenter?.Invoke(presenter);
        }
            public void Items_in_original_collection_same_with_array()
            {
                var mf         = this.manifestObject;
                var sourceList = new List <object>
                {
                    mf(),
                    mf(),
                    mf(),
                    mf(),
                    mf()
                };

                var endArray = EH.ToArray(
                    sourceList);
                var endArrayLength  = endArray.Length;
                var sourceListCount = sourceList.Count;

                Assert.Equal(
                    sourceListCount,
                    endArrayLength);
                for (
                    var indexer = zero;
                    indexer < endArrayLength && indexer < sourceListCount;
                    ++indexer)
                {
                    Assert.Same(
                        sourceList[indexer],
                        endArray[indexer]);
                }
            }
Example #3
0
        public override void PresentFluidly <T>(
            string name)
        {
            NamedPresenter np;

            lock (this.locker)
            {
                var matchingPresenters = EH.OfType <T>(
                    this.presenters);
                foreach (var presenter in matchingPresenters)
                {
                    if (presenter.Name != name)
                    {
                        continue;
                    }

                    np = presenter;
                    goto start;
                }
            }

            return;

start:
            this.startPresenter?.Invoke(np);
        }
            public void Type_test()
            {
                var empty = EH.Empty <object>();

                this.outputter.WriteLine(
                    empty.GetType().ToString());
            }
Example #5
0
 public override bool Equals(
     object obj)
 {
     return(EH.All(
                this.dependencies,
                t => t.Equals(obj)));
 }
Example #6
0
 public virtual bool IsRegistered <T>()
     where T : Presenter
 {
     return(EH.Any(
                EH.OfType <T>(
                    this.presenters)));
 }
Example #7
0
 public override int GetHashCode()
 {
     return(EH.Aggregate(
                this.dependencies,
                0,
                (current, o) => current ^ o.GetHashCode()));
 }
Example #8
0
 public virtual bool Contains(
     T item)
 {
     return(EH.Contains(
                this.items,
                item));
 }
Example #9
0
 public virtual IEnumerator <V> GetEnumerator()
 {
     return(EH.Select(
                this.items,
                i => i.Value)
            .GetEnumerator());
 }
Example #10
0
 public IEnumerable <T> Generate()
 {
     return(EH.Select(
                this.gates,
                gate => this.generator(gate))
            ?? EH.Empty <T>());
 }
Example #11
0
        // pass the Nameable.Name last, after all constructor arguments
        public override T Create <T>(
            params object[] dependencies)
        {
            var ds = dependencies;

            if (ds == null)
            {
                return(base.Create <T>());
            }

            var l = ds.Length;

            if (l < one || !typeof(Nameable).IsAssignableFrom(typeof(T)))
            {
                return(base.Create <T>(ds));
            }

            var possibleNameable = base.Create <T>(
                EH.ToArray(
                    EH.Take(
                        ds,
                        l - one)));

            if (possibleNameable is Nameable n &&
                EH.Last(ds) is string name)
            {
                n.Name = name;
            }

            return(possibleNameable);
        }
Example #12
0
 public virtual ICollection <string> ReadSectionNames()
 {
     return(new LinkedList <string>(
                EH.Select(
                    this.readSectionHeaders(
                        this.readLines()),
                    header => header.Name)));
 }
Example #13
0
 public virtual bool Contains(
     T item)
 {
     this.checkItems();
     return(EH.Contains(
                this.items,
                item));
 }
Example #14
0
 public virtual bool IsRegistered <T>(
     string name)
     where T : NamedPresenter
 {
     return(EH.Any(
                EH.OfType <T>(
                    this.presenters),
                p => p.Name == name));
 }
 public void Not_null()
 {
     Assert.NotNull(
         EH.ToArray(
             (IEnumerable <object>)null));
     Assert.NotNull(
         EH.ToArray(
             (Lot <object>)null));
 }
Example #16
0
 public virtual bool Contains(
     V value)
 {
     return(EH.Contains(
                EH.Select(
                    this.items,
                    kvp => kvp.Value),
                value));
 }
Example #17
0
 public override bool IsRegistered <T>()
 {
     lock (this.locker)
     {
         return(EH.Any(
                    EH.OfType <T>(
                        this.presenters)));
     }
 }
Example #18
0
 public virtual void StopPresenter <T>()
     where T : Presenter
 {
     foreach (var presenter in EH.OfType <T>(
                  this.presenters))
     {
         presenter?.Stop();
         break;
     }
 }
Example #19
0
        public virtual BigInteger ReadBigInteger(
            IEnumerable <bool> bits)
        {
            var        bytes = this.GetBytes(bits);
            const byte zero  = 0;

            return(new BigInteger(
                       EH.ToArray(bytes) ??
                       new byte[zero]));
        }
Example #20
0
 public IniReaderWriter(
     string filePath)
     : this(
         () => File.Exists(filePath)
             ? File.ReadAllLines(filePath)
             : new string[0],
         lines => File.WriteAllLines(
             filePath,
             EH.ToArray(lines)))
 {
 }
Example #21
0
 public override bool IsRegistered <T>(
     string name)
 {
     lock (this.locker)
     {
         return(EH.Any(
                    EH.OfType <T>(
                        this.presenters),
                    p => p.Name == name));
     }
 }
Example #22
0
 public override void StopPresenter <T>()
 {
     lock (this.locker)
     {
         foreach (var presenter in EH.OfType <T>(
                      this.presenters))
         {
             presenter.Stop();
             break;
         }
     }
 }
Example #23
0
        public virtual void CopyTo(
            V[] valueArray)
        {
            var lot = this.items;

            Array.Copy(
                EH.ToArray(
                    EH.Select(
                        lot,
                        kvp => kvp.Value)),
                valueArray,
                lot.Count);
        }
Example #24
0
 public virtual void StopPresenter <T>(
     string name)
     where T : NamedPresenter
 {
     foreach (var presenter in
              EH.Where(
                  EH.OfType <T>(
                      this.presenters),
                  p => p.Name == name))
     {
         presenter?.Stop();
         break;
     }
 }
Example #25
0
        public virtual void PresentFluidly <T>()
            where T : Presenter
        {
            var presenter = EH.FirstOrDefault(
                this.presenters,
                p => p is T);

            if (presenter == null)
            {
                return;
            }

            this.startPresenter?.Invoke(presenter);
        }
Example #26
0
        public virtual TUi GetUi <TPresenter, TUi>(
            string presenterName = null,
            string fieldName     = Presenter.DefaultUiFieldName)
            where TPresenter : Presenter
        {
            Lot <Presenter> matchingPresenters
                = new LinkedListLot <Presenter>(
                      EH.Where(
                          this.presenters,
                          p => p is TPresenter));
            const byte one = 1;

            if (matchingPresenters.Count < one)
            {
                return(default);
Example #27
0
 public override void StopPresenter <T>(
     string name)
 {
     lock (this.locker)
     {
         foreach (var presenter in
                  EH.Where(
                      EH.OfType <T>(
                          this.presenters),
                      p => p.Name == name))
         {
             presenter.Stop();
             break;
         }
     }
 }
Example #28
0
        public virtual bool Unregister <T>()
            where T : Presenter
        {
            var  ps           = this.presenters;
            bool unregistered = falsity;

            lock (this.locker)
            {
                foreach (var p in EH.OfType <T>(ps))
                {
                    unregistered = ps.Remove(p);
                    break;
                }
            }

            return(unregistered);
        }
Example #29
0
        public override void PresentFluidly <T>()
        {
            Presenter presenter;

            lock (this.locker)
            {
                presenter = EH.FirstOrDefault(
                    this.presenters,
                    p => p is T);
            }

            if (presenter == null)
            {
                return;
            }

            this.startPresenter?.Invoke(presenter);
        }
Example #30
0
        public virtual void PresentFluidly <T>(
            string name)
            where T : NamedPresenter
        {
            var matchingPresenters = EH.OfType <T>(
                this.presenters);

            foreach (var presenter in matchingPresenters)
            {
                if (presenter.Name != name)
                {
                    continue;
                }

                this.startPresenter?.Invoke(presenter);
                break;
            }
        }