Пример #1
0
 public void SetOwner(Somebody owner)
 {
     // NOT LEGAL. WHY ONLY EVENT ON THIS ATTRIBUTE? WHAT MAKES IT DIFFERENT FROM A RING2 PERSPECTIVE?
     OwnerChanged = DateTime.Now;
     OnOwnerChanged(owner);
     Owner = owner;
 }
Пример #2
0
        public void TestConstructorSomebody()
        {
            var s = new Somebody(2, 5.1);
            var v = new Vector(2, 5.1, 0);

            Assert.IsTrue(v == s);
        }
Пример #3
0
            public TradeAction ActionPerformed(Somebody processor, Something processedObject)
            {
                TradeAction action = (TradeAction) New();
                action.Processor = processor;
                action.ProcessedObject = processedObject;
                action.When = DateTime.Now;

                return action;
            }
Пример #4
0
            /// <summary>
            /// Returns the first action of the given kind, between the processor and the processedObject.
            /// </summary>
            /// <param name="kind"></param>
            /// <param name="processor"></param>
            /// <param name="processedObject"></param>
            /// <returns></returns>
            public TradeAction GetFirst(TradeAction.Kind kind, Somebody processor, Something processedObject)
            {
                ICollection<Persistent> result = kind.FindMany("Processor = {0} AND ProcessedObject = {1}", new Object[] { processor, processedObject });
                TradeAction first = null;

                foreach (TradeAction action in result)
                {
                    if (first == null || action.When < first.When)
                    {
                        first = action;
                    }
                }

                return first;
            }
Пример #5
0
        static void Initiallizesomebody()
        {
            Somebody somebody = new Somebody()
            {
                Name     = "Emmanuel",
                Age      = 20,
                LastName = "Ojo"
            };

            Console.WriteLine(somebody.ToString());
            Somebody somebody1 = new Somebody("james", "Ojo", 20);

            Console.WriteLine();
            Console.WriteLine(somebody1.ToString());

            WriteLine("Somebody = Somebody1?: {0}", object.Equals(somebody, somebody1));
            WriteLine("Somebody = Somebody1?: {0}", object.ReferenceEquals(somebody, somebody1));
        }
        private static void Dictionary()
        {
            Dictionary <string, Somebody> pairs = new Dictionary <string, Somebody>()
            {
                { "FirstPerson", new Somebody("peter", "hanna", 1) },
                { "Second Somebody", new Somebody("tolu", "badmus", 23) }
            };

            // Intialization of the Object can Point to a refrence of the Dictionary with the Key
            try
            {
                Somebody somebody = pairs["tolu"];
                Console.WriteLine(somebody);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #7
0
 public void SetMember(Somebody member)
 {
     SetWhatIs(member);
 }
Пример #8
0
            /// <summary>
            /// Returns the first action of the given kind, between the processor and the processedObjects.
            /// </summary>
            /// <param name="kind"></param>
            /// <param name="processor"></param>
            /// <param name="processedObjects"></param>
            /// <returns></returns>
            public TradeAction GetFirst(TradeAction.Kind kind, Somebody processor, ICollection processedObjects)
            {
                TradeAction first = null;

                foreach (Something processedObject in processedObjects)
                {
                    TradeAction action = GetFirst(kind, processor, processedObject);

                    if (first == null || action.When < first.When)
                    {
                        first = action;
                    }
                }

                return first;
            }
Пример #9
0
 public void SetApprover(Somebody approver)
 {
     _approver = approver;
 }
Пример #10
0
 public void SetWhoIs(Somebody whoIs)
 {
     SetWhatIs(whoIs);
 }
Пример #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="somebody"></param>
 /// <param name="literaryWorkKind"></param>
 /// <returns></returns>
 public Author Assure(Somebody somebody, LiteraryWork.Kind literaryWorkKind)
 {
     return Relate<Author>(somebody, literaryWorkKind);
 }
Пример #12
0
        /// <summary>
        /// Validates if a specific <c>Somebody</c> is a valid consumer of the trade agreement.
        /// Excluding agreements that os valid for <c>Everybody._.GetInstance()</c>
        /// </summary>
        /// <param name="offereeCandidate"></param>
        /// <returns></returns>
        public Boolean IsValidExclEverybodyConsumers(Somebody offereeCandidate)
        {
            Boolean isMatching = false;

            //Everybody is consumer, not what we are looking for here.
            if (Offeree.ToWhom.Equals(Kind.GetInstance<Everybody.Kind>().Singleton))
            {
                isMatching = false;
            }
            //Validate offeree candidate.
            else if (IsSomebodyValidAsOfferee(offereeCandidate))
            {
                isMatching = true;
            }
            return isMatching;
        }
Пример #13
0
        /// <summary>
        /// Validation of a offeree candidate.
        /// </summary>
        /// <param name="offereeCandidate"></param>
        /// <returns></returns>
        public Boolean IsSomebodyValidAsOfferee(Somebody offereeCandidate)
        {
            Boolean isMatching = false;

            //This trade agreement is valid for only one consumer
            if (Offeree.WhoIs.Equals(offereeCandidate))
            {
                isMatching = true;
            }
            else if (Offeree.WhoIs.Equals(Kind.GetInstance<Everybody.Kind>().Singleton))
            {
                isMatching = true;
            }
            //Check if this agreement is valid for the offereeCandidate,
            //since this agreement is valid for a group of somebodies.
            else if (Offeree.WhoIs is Group)
            {
                isMatching = ((Group)Offeree.WhoIs).IsMember(offereeCandidate);
            }
            return isMatching;
        }
Пример #14
0
        /// <summary>
        /// Validates if a <c>Somebody</c> is a valid offeror.
        /// </summary>
        /// <param name="offerorCandidate"></param>
        /// <returns></returns>
        public Boolean IsSomebodyAValidOfferor(Somebody offerorCandidate)
        {
            Boolean isMatching = false;

            //Direct match.
            if (Offeror.Equals(offerorCandidate))
            {
                isMatching = true;
            }
            //Is a part of a group that offers this agreement.
            else if (Offeror is Group)
            {
                isMatching = ((Group)Offeror).IsMember(offerorCandidate);
            }
            return isMatching;
        }
Пример #15
0
 /// <summary>
 /// NOT LEGAL. WHY ONLY EVENT ON THIS ATTRIBUTE? WHAT MAKES IT DIFFERENT FROM A RING2 PERSPECTIVE?
 /// Called when the owner has changed.
 /// </summary>
 /// <param name="Owner">The new owner</param>
 protected virtual void OnOwnerChanged(Somebody Owner)
 {
 }
Пример #16
0
 public void SetToWhom(Somebody toWhom)
 {
     SetToWhat(toWhom);
 }
Пример #17
0
            /// <summary>
            /// Returns the latest action of the given kind, for the given processor.
            /// </summary>
            /// <param name="kind"></param>
            /// <param name="processor"></param>
            /// <returns></returns>
            public TradeAction GetLatestForProcessor(TradeAction.Kind kind, Somebody processor)
            {
                ICollection<Persistent> result = kind.FindMany("Processor = {0}", new Object[] { processor });
                TradeAction latest = null;

                foreach (TradeAction action in result)
                {
                    if (latest == null || action.When > latest.When)
                    {
                        latest = action;
                    }
                }

                return latest;
            }
Пример #18
0
            public IEnumerable<CompensationProvision> MatchingOffers(Somebody offeror,
                Something persistentObject,
                DateValidationType dateValidationType)
            {
                if (offeror == null || persistentObject == null)
                {
                    throw new ArgumentException("Missing offeror or object in price evaluation.");
                }

                List<CompensationProvision> validElements = new List<CompensationProvision>();
                IEnumerable<CompensationProvision> offerCandidates = GetOffers(persistentObject);

                foreach (CompensationProvision cod in offerCandidates)
                {
                    //Validate participating parts
                    if (!cod.AgreedCompensation.IsSomebodyAValidOfferor(offeror))
                    {
                        continue; //No match, check next offer.
                    }
                    if (CanAddElement(cod, dateValidationType))
                    {
                        validElements.Add(cod);
                    }
                }
                return validElements;
            }
Пример #19
0
 /// <summary>
 /// Returns the processedObject that was the latest one on a TradeAction for the given processor.
 /// </summary>
 /// <param name="kind"></param>
 /// <param name="processor"></param>
 /// <returns></returns>
 public Something GetLatestProcessedObject(TradeAction.Kind kind, Somebody processor)
 {
     TradeAction latest = GetLatestForProcessor(kind, processor);
     return (latest != null) ? latest.ProcessedObject : null;
 }
Пример #20
0
 public virtual void OnDelivererSet(Somebody deliveree)
 {
 }
Пример #21
0
        //queue is a data-type that works with first in first out;
        //We all have seen how a queue can be in realife

        //Lets Create a Reallife instance
        //Somebody is to buy a Coffee
        //And There is a Really Long Queue

        //A Funtion that Model the Fact That Somebody as been attended to by the attendant

        private static void NextCustomer(Somebody somebody)
        {
            Console.WriteLine($"Next Customer Please; {somebody.Name} as been Attended to");
        }