Exemplo n.º 1
0
        static void BirthdayParty()
        {
            //Birthday birthday = new Birthday();
            //birthday.Venue = "Disneyland";

            //string venue =  birthday.Venue;

            Console.WriteLine(venue);

            TwentyOnePlus top = new TwentyOnePlus();

            //Party party = new Party();

            Party party = new TwentyOnePlus();

            Quack quack = new Quack();

            top.Goober(quack);

            // an array of parties
            // top is a 21+ Birthdya party
            // quack is a football party
            Party[] parties = { top, quack };

            for (int i = 0; i < parties.Length; i++)
            {
                if (parties[i] is Football)
                {
                    // Do something
                }
                else if (parties[i] is Birthday)
                {
                }
            }
        }
Exemplo n.º 2
0
        public void SaveQuack(Quack quack)
        {
            quack.CreatedDate      = DateTime.Now;
            quack.LastModifiedDate = DateTime.Now;
            quack.Active           = true;
            var quackType = _quackTypeRepository.GetQuackByQuackType(quack.QuackTypeID);

            quack.QuackType = quackType;
            var user = _userRepository.GetUserById(quack.UserID);

            quack.User = user;

            if (!String.IsNullOrEmpty(quack.QuackContent.ImageUrl))
            {
                var img = quack.QuackContent.ImageUrl;
                quack.QuackContent.ImageUrl = "Y";
                var currentImage = img.Substring(img.IndexOf(',') + 1);
                var data         = Convert.FromBase64String(currentImage);
                quack.QuackContent.Image = data;
            }

            quack.QuackContent.CreatedDate = DateTime.Now;
            _quackRepository.SaveQuack(quack);

            if (quack.ConversationID != 0)
            {
                _quackRepository.UpdateQuack(quack.ConversationID);
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            //A DEPENDENCY INJECTOR OR FACTORY SHOULD REPLACE ALL THIS DECLARATIONS
            IFlyBehavior canFly  = new FlyWithWings();
            IFlyBehavior cantFly = new FlyNoWay();

            IQuackBehavior quack   = new Quack();
            IQuackBehavior squeack = new Squeack();
            IQuackBehavior mute    = new MuteQuack();

            List <Duck> ducks = new List <Duck>();

            Duck mallardDuck = new MallardDuck(canFly, quack);
            Duck redHeadDuck = new RedHeadDuck(canFly, quack);
            Duck decoyDuck   = new DecoyDuck(cantFly, mute);
            Duck rubberDuck  = new RubberDuck(cantFly, squeack);

            ducks.Add(mallardDuck);
            ducks.Add(redHeadDuck);
            ducks.Add(decoyDuck);
            ducks.Add(rubberDuck);

            //NOW WE WILL MAKE OUR DUCKS DISPLAY FLY AND QUACK
            foreach (Duck duck in ducks)
            {
                duck.Display();
                duck.PerformFly();
                duck.PerformQuack();

                Console.WriteLine("---------------");
            }

            Console.ReadLine();
        }
Exemplo n.º 4
0
        public void PushWork(WorkItem workItem)
        {
            if (_firstWorkItem == null)
            {
                _firstWorkItem = workItem;
            }
            else
            {
                if (_workItemQueue == null)
                {
                    _workItemQueue = new Quack <WorkItem>();
                }

                _workItemQueue.PushFront(_firstWorkItem);
                _firstWorkItem = workItem;
            }

            // To avoid the virt call on EVERY work item we check
            // the Verbose flag.  All of our Schedule traces are
            // verbose.
            if (Microsoft.CoreWf.Internals.FxTrace.ShouldTraceVerboseToTraceSource)
            {
                workItem.TraceScheduled();
            }
        }
Exemplo n.º 5
0
        public void PushWork(WorkItem workItem)
        {
            if (this.firstWorkItem == null)
            {
                this.firstWorkItem = workItem;
            }
            else
            {
                if (this.workItemQueue == null)
                {
                    this.workItemQueue = new Quack <WorkItem>();
                }

                this.workItemQueue.PushFront(this.firstWorkItem);
                this.firstWorkItem = workItem;
            }

            // To avoid the virt call on EVERY work item we check
            // the Verbose flag.  All of our Schedule traces are
            // verbose.
            if (FxTrace.ShouldTraceVerboseToTraceSource)
            {
                workItem.TraceScheduled();
            }
        }
Exemplo n.º 6
0
        public MallardDuck()
        {
            // 呱呱叫
            QuackBehavior = new Quack();

            // 有翅膀飞行
            FlyBehavior = new FlyWithWings();
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Quack quack = db.Quacks.Find(id);

            db.Quacks.Remove(quack);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Quack_Id,Quack_Title,Date_Created,Quack_Text")] Quack quack)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quack).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(quack));
 }
Exemplo n.º 9
0
    public static ulong[] Quack2MachineCode(Quack <AIMouvementCommand> quack)
    {
        ulong[] res = new ulong[quack.Count];

        for (uint i = 0u; i < quack.Count; i++)
        {
            res [i] = quack [i].ToCode();
        }

        return(res);
    }
Exemplo n.º 10
0
        // GET: Quacks/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Quack quack = db.Quacks.Find(id);

            if (quack == null)
            {
                return(HttpNotFound());
            }
            return(View(quack));
        }
Exemplo n.º 11
0
        public void TypeDuck(Label a, Label b, Label c, PictureBox pic)
        {
            IQuack quack;
            Ivolar ivolar;

            quack  = new Quack();
            ivolar = new Flyaway();
            Swim s = new Swim();

            a.Text = quack.TypeQuack();
            b.Text = ivolar.Comportamiento();
            c.Text = s.S();
            quack.Typesound();
            pic.Image = Properties.Resources.redhead;
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Quack_Id,Quack_Title,Date_Created,Quack_Text")] Quack quack)
        {
            var userId = User.Identity.GetUserId();

            quack.UserId = userId;

            if (ModelState.IsValid)
            {
                db.Quacks.Add(quack);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quack));
        }
Exemplo n.º 13
0
        public void TypeDuck(Label a, Label b, Label c, PictureBox pic)
        {
            Ivolar ivolar;
            IQuack quack;
            Swim   s = new Swim();

            ivolar = new Flyaway();
            quack  = new Quack();
            a.Text = ivolar.Comportamiento();
            b.Text = quack.TypeQuack();
            c.Text = s.S();
            quack.Typesound();
            PMallard d = new PMallard();

            d.p(pic);
        }
 public void ClearAllWorkItems(ActivityExecutor executor)
 {
     if (this.firstWorkItem != null)
     {
         this.firstWorkItem.Release(executor);
         this.firstWorkItem = null;
         if (this.workItemQueue != null)
         {
             while (this.workItemQueue.Count > 0)
             {
                 this.workItemQueue.Dequeue().Release(executor);
             }
         }
     }
     this.workItemQueue = null;
 }
Exemplo n.º 15
0
 public void ClearAllWorkItems(ActivityExecutor executor)
 {
     if (this.firstWorkItem != null)
     {
         this.firstWorkItem.Release(executor);
         this.firstWorkItem = null;
         if (this.workItemQueue != null)
         {
             while (this.workItemQueue.Count > 0)
             {
                 this.workItemQueue.Dequeue().Release(executor);
             }
         }
     }
     this.workItemQueue = null;
 }
Exemplo n.º 16
0
 public void EnqueueWork(System.Activities.Runtime.WorkItem workItem)
 {
     if (this.firstWorkItem == null)
     {
         this.firstWorkItem = workItem;
     }
     else
     {
         if (this.workItemQueue == null)
         {
             this.workItemQueue = new Quack <System.Activities.Runtime.WorkItem>();
         }
         this.workItemQueue.Enqueue(workItem);
     }
     if (FxTrace.ShouldTraceVerboseToTraceSource)
     {
         workItem.TraceScheduled();
     }
 }
 public void EnqueueWork(System.Activities.Runtime.WorkItem workItem)
 {
     if (this.firstWorkItem == null)
     {
         this.firstWorkItem = workItem;
     }
     else
     {
         if (this.workItemQueue == null)
         {
             this.workItemQueue = new Quack<System.Activities.Runtime.WorkItem>();
         }
         this.workItemQueue.Enqueue(workItem);
     }
     if (FxTrace.ShouldTraceVerboseToTraceSource)
     {
         workItem.TraceScheduled();
     }
 }
Exemplo n.º 18
0
 private QuackDto QuackMapper(Quack quack, int userId = 0)
 {
     return(new QuackDto
     {
         Id = quack.ID,
         Likes = quack.QuackLikes.Count(q => q.Active),
         Message = quack.QuackContent.MessageText,
         TimeSpan = GetTimeSpanInformation(quack.LastModifiedDate),
         UserName = quack.User.UserName,
         UserImage = quack.User.ProfileImage,
         UserId = quack.User.ID,
         LikeOrUnlike = VerifyLikeOrUnLike(quack, userId),
         IsNew = quack.QuackTypeID == 1 ? true : false,
         UserNickName = quack.User.UserName.Replace("DS\\", ""),
         ConversationId = quack.ConversationID,
         UserDisplayName = quack.User.FirstName + " " + quack.User.LastName,
         LatestReply = GetRepliesInformation(quack.ID),
         QuackImage = quack.QuackContent.Image
     });
 }
Exemplo n.º 19
0
        public void EnqueueWork(WorkItem workItem)
        {
            if (_firstWorkItem == null)
            {
                _firstWorkItem = workItem;
            }
            else
            {
                if (_workItemQueue == null)
                {
                    _workItemQueue = new Quack <WorkItem>();
                }

                _workItemQueue.Enqueue(workItem);
            }

            if (Microsoft.CoreWf.Internals.FxTrace.ShouldTraceVerboseToTraceSource)
            {
                workItem.TraceScheduled();
            }
        }
Exemplo n.º 20
0
        public void ClearAllWorkItems(ActivityExecutor executor)
        {
            if (this.firstWorkItem != null)
            {
                this.firstWorkItem.Release(executor);
                this.firstWorkItem = null;

                if (this.workItemQueue != null)
                {
                    while (this.workItemQueue.Count > 0)
                    {
                        WorkItem item = this.workItemQueue.Dequeue();
                        item.Release(executor);
                    }
                }
            }

            Fx.Assert(this.workItemQueue == null || this.workItemQueue.Count == 0, "We either didn't have a first work item and therefore don't have anything in the queue, or we drained the queue.");

            // For consistency we set this to null even if it is empty
            this.workItemQueue = null;
        }
Exemplo n.º 21
0
        protected void valueRemember(string what)
        {
            RegistryKey rk = Application.UserAppDataRegistry.CreateSubKey(myID());

                        #if USER_READABLE
            ///send the recent list back
            for (i = maxRecent - 1; i > 1; i--)
            {
                found = rk.GetValue(recentPrefix + i);
                if (found != null)
                {
                    rk.SetValue(recentPrefix + (i + 1), found);
                }
            }
            rk.SetValue(recentPrefix + 0, what);
                        #else
            object s = ApplicationHelper.getSetting(@"recent", myID());
            if (!(s is Quack))
            {
                s = new Quack();
            }

            if (((Quack)s).Contains(what))
            {
                ((Quack)s).Remove(what);
            }

            while (((Quack)s).Count >= maxRecent)
            {
                ((Quack)s).Dequeue();
            }

            ((Quack)s).Enqueue(what);

            ApplicationHelper.storeSetting(@"recent", myID(), s);
            //rk.SetValue(recentPrefix + "list", s);
                        #endif
        }
Exemplo n.º 22
0
 public RubberDuck()
 {
     flyBehaviour   = new CantFly();
     quackBehaviour = new Quack();
 }
Exemplo n.º 23
0
 public HttpResponseMessage Post(Quack quack)
 {
     _quackFacade.SaveQuack(quack);
     return(Request.CreateResponse(HttpStatusCode.Created, "true"));
 }
Exemplo n.º 24
0
 public RedheadDuck()
 {
     QuackBehavior = new Quack();
     FlyBehavior   = new FlyWithWings();
 }
Exemplo n.º 25
0
        public void ClearAllWorkItems(ActivityExecutor executor)
        {
            if (this.firstWorkItem != null)
            {
                this.firstWorkItem.Release(executor);
                this.firstWorkItem = null;

                if (this.workItemQueue != null)
                {
                    while (this.workItemQueue.Count > 0)
                    {
                        WorkItem item = this.workItemQueue.Dequeue();
                        item.Release(executor);
                    }
                }
            }

            Fx.Assert(this.workItemQueue == null || this.workItemQueue.Count == 0, "We either didn't have a first work item and therefore don't have anything in the queue, or we drained the queue.");

            // For consistency we set this to null even if it is empty
            this.workItemQueue = null;
        }
Exemplo n.º 26
0
 public ModelDuck()
 {
     _iFlyBehavior   = new FlyNoWay();
     _iQuackBehavior = new Quack();
 }
Exemplo n.º 27
0
 public ReadheadDuck()
 {
     quackBehavior = new Quack();
     flyBehavior   = new FlyWithWings();
     swimBehavior  = new SwimWithPaws();
 }
Exemplo n.º 28
0
 public ModelDuck()
 {
     quackBehavior = new Quack();
     flyBehavior = new FlyNoWay();
 }
Exemplo n.º 29
0
 public MallardDuck()
 {
     flyBehavior = new FlyWithWings();
     quackBehavior = new Quack();
 }
Exemplo n.º 30
0
 public ModelDuck()
 {
     flyBehavior   = new FlyNoWay();
     quackBehavior = new Quack();
 }
 public MallarDuck()
 {
     QuackBehavior = new Quack();
     FlyBehavior   = new FlyWithWings();
 }
Exemplo n.º 32
0
 public ModelDuck()
 {
     FlyBehaviour   = new FlyNoWay();
     QuackBehaviour = new Quack();
 }
Exemplo n.º 33
0
 //Mallard Duck is a real duck. Therefore it quacks and flies(For short durations)
 public MallardDuck()
 {
     quackBehaviour = new Quack();
     flyBehaviour   = new FlyWithWings();
 }
Exemplo n.º 34
0
 public RedheadDuck()
 {
     flyBehavior   = new FlyNoWay();
     quackBehavior = new Quack();
 }
Exemplo n.º 35
0
 public MallardDuck()
 {
     FlyBehavior   = new FlyWithWings();
     QuackBehavior = new Quack();
 }
Exemplo n.º 36
0
        public void PushWork(WorkItem workItem)
        {
            if (this.firstWorkItem == null)
            {
                this.firstWorkItem = workItem;
            }
            else
            {
                if (this.workItemQueue == null)
                {
                    this.workItemQueue = new Quack<WorkItem>();
                }

                this.workItemQueue.PushFront(this.firstWorkItem);
                this.firstWorkItem = workItem;
            }

            // To avoid the virt call on EVERY work item we check
            // the Verbose flag.  All of our Schedule traces are
            // verbose.
            if (FxTrace.ShouldTraceVerboseToTraceSource)
            {
                workItem.TraceScheduled();
            }
        }