• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Pet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Pet的典型用法代码示例。如果您正苦于以下问题:C# Pet类的具体用法?C# Pet怎么用?C# Pet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pet类属于命名空间,在下文中一共展示了Pet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Get

        public IEnumerable<Pet> Get()
        {
            List<Pet> pets = new List<Pet>();

            //get pets from db
            using (SqlConnection connection = new SqlConnection(this.connectionString))
            {
                string sql = @"SELECT * FROM PETS";

                connection.Open();
                SqlCommand cmd = new SqlCommand(sql, connection);
                SqlDataReader data = cmd.ExecuteReader();

                if (data.HasRows)
                {
                    while (data.Read())
                    {
                        Pet pet = new Pet();

                        pet.Id = Int32.Parse(data["Id"].ToString());
                        pet.Name = data["Name"].ToString();
                        pet.Notes = data["Notes"].ToString();
                        pet.IsOnCare = Boolean.Parse(data["IsOnCare"].ToString());

                        pets.Add(pet);
                    }
                }

                data.Dispose();
                cmd.Dispose();
            }

            return pets;
        }
开发者ID:jicking,项目名称:Bejie-s-Pet-Care,代码行数:34,代码来源:PetController.cs


示例2: AddPetAsync

 /// <summary>
 /// Add a new pet to the store
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// Pet object that needs to be added to the store
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<Pet> AddPetAsync(this ISwaggerPetstoreV2 operations, Pet body, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.AddPetWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }
开发者ID:devigned,项目名称:autorest,代码行数:19,代码来源:SwaggerPetstoreV2Extensions.cs


示例3: AddPetAsync

     /// <summary>Add a new pet to the store</summary>
     /// <param name="body">Pet object that needs to be added to the store</param>
     /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
     /// <exception cref="SwaggerException">A server side error occurred.</exception>
     public async System.Threading.Tasks.Task AddPetAsync(Pet body, System.Threading.CancellationToken cancellationToken)
     {
         var url_ = string.Format("{0}/{1}", BaseUrl, "pet");
 
         using (var client_ = new System.Net.Http.HttpClient())
 		{
 			var request_ = new System.Net.Http.HttpRequestMessage();
 			PrepareRequest(client_, ref url_);
 			var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body));
 			content_.Headers.ContentType.MediaType = "application/json";
 			request_.Content = content_;
 			request_.Method = new System.Net.Http.HttpMethod("POST");
 			request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
 			var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false);
 			ProcessResponse(client_, response_);
 
 			var responseData_ = await response_.Content.ReadAsByteArrayAsync().ConfigureAwait(false); 
 			var status_ = ((int)response_.StatusCode).ToString();
 
 			if (status_ == "405") 
 			{
 				throw new SwaggerException("Invalid input", status_, responseData_, null);
 			}
 			else
 			if (status_ != "200" && status_ != "204")
 				throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", status_, responseData_, null);
 		}
 	}
开发者ID:NSwag,项目名称:NSwag,代码行数:32,代码来源:PetStoreClient.cs


示例4: StartUp

    public void StartUp()
    {
        // add prices to the dictionary, prices
          prices.Add("Dog", 120);
          prices.Add("Cat", 60);
          prices.Add("Snake", 40);
          prices.Add("Guinea pig", 20);
          prices.Add("Canary", 15);

        // create customers
        Customer c1 = new Customer(1001, "Susan", "Peterson", "Borgergade 45", "8000", "Aarhus", "[email protected]", "211a212121");
          Customer c2 = new Customer(1002, "Brian", "Smith", "Allegade 108", "8000", "Aarhus", "[email protected]", "45454545");

        //opret Employees
          Employee e1 = new Employee("Gitte", "Svendsen", "GIT", "234234234");
          Employee e2 = new Employee("Mads", "Juul", "MUL", "911112112");

          Pet p1 = new Pet("Dog", "Hamlet", new DateTime(2011, 9, 2),
                       new DateTime(2011,9,20), c1, e1);
          Pet p2 = new Pet("Dog", "Samson", new DateTime(2011, 9, 14),
                       new DateTime(2011, 9, 21), c1, e1);
          Pet p3 = new Pet("Cat", "Darla", new DateTime(2011, 9, 7),
                       new DateTime(2011, 9, 10), c2, e2);
          // add Pets to list of Pet, pets
          pets.Add(p1);
          pets.Add(p2);
          pets.Add(p3);

        // add customers to list
          customer.Add(c1);
          customer.Add(c2);
    }
开发者ID:morten-s,项目名称:WebSites,代码行数:32,代码来源:Service.cs


示例5: GenerateMessage

 internal static void GenerateMessage(Pet pet)
 {
     ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("RespectPetComposer"));
     serverMessage.AppendInteger(pet.VirtualId);
     serverMessage.AppendBool(true);
     pet.Room.SendMessage(serverMessage);
 }
开发者ID:bblackv,项目名称:Yupi,代码行数:7,代码来源:RespectPetComposer.cs


示例6: CreatePet

        public ActionResult CreatePet([DataSourceRequest]DataSourceRequest request, IEnumerable<AdministrationPetsViewModel> models)
        {
            var result = new List<AdministrationPetsViewModel>();
            if (this.ModelState.IsValid && models != null)
            {
                foreach (var model in models)
                {
                    var owner = this.users.GetByUsername(model.Owner).FirstOrDefault();
                    var breed = this.breeds.GetById(model.BreedId).FirstOrDefault();
                    var location = this.locations.GetById(model.LocationId).FirstOrDefault();
                    var status = this.petStatuses.GetById(model.PetStatusId).FirstOrDefault();
                    if (owner != null && breed != null && location != null && status != null)
                    {
                        var newPet = new Pet { Name = model.Name, Description = model.Description, Breed = breed, Owner = owner, Location = location, PetStatus = status, ImageUrl = model.ImageUrl, PetGender = model.PetGenderType };
                        this.pets.Add(newPet);
                        model.CreatedOn = newPet.CreatedOn;
                        model.Id = newPet.Id;
                        result.Add(model);
                    }
                }

                return this.Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
            }

            return null;
        }
开发者ID:KonstantinAdamu,项目名称:PetRescue,代码行数:26,代码来源:PetsAdministrationController.cs


示例7: GetPet

 public Pet GetPet()
 {
     Pet pet = new Pet();
     pet.PetId = 1;
     pet.Name = "Tamo";
     return pet;
 }
开发者ID:janisskuja,项目名称:tamagotchi,代码行数:7,代码来源:PetRepository.cs


示例8: GenerateMessage

        internal static void GenerateMessage(Pet pet, ServerMessage message, bool levelAfterName = false)
        {
            message.AppendInteger(pet.PetId);
            message.AppendString(pet.Name);

            if (levelAfterName)
                message.AppendInteger(pet.Level);

            message.AppendInteger(pet.RaceId);
            message.AppendInteger(pet.Race);
            message.AppendString(pet.Type == "pet_monster" ? "ffffff" : pet.Color);
            message.AppendInteger(pet.Type == "pet_monster" ? 0u : pet.RaceId);

            if (pet.Type == "pet_monster" && pet.MoplaBreed != null)
            {
                string[] array = pet.MoplaBreed.PlantData.Substring(12).Split(' ');
                string[] array2 = array;

                foreach (string s in array2)
                    message.AppendInteger(int.Parse(s));

                message.AppendInteger(pet.MoplaBreed.GrowingStatus);

                return;
            }

            message.AppendInteger(0);
            message.AppendInteger(0);
        }
开发者ID:weslley17w,项目名称:Yupi,代码行数:29,代码来源:SerializePetInventoryComposer.cs


示例9: Pet_insert

 public Pet Pet_insert()
 {
     Pet.Pet_Location_Found_ID = Convert.ToInt32(Pet_Location_Found_ID_txt.Text);
     Pet.Pet_Type_ID = Convert.ToInt32(Pet_Type_ID_txt.Text);
     Pet.Pet_Vet_ID = Pet_Vet_ID_txt.Text;
     Pet.Pet_License_Tag = Pet_License_Tag_txt.Text;
     Pet.Pet_RFID = Pet_RFID_txt.Text;
     Pet.Pet_Tatoo_No = Pet_Tatoo_No_txt.Text;
     Pet.Pet_Name = Pet_Name_txt.Text;
     Pet.Pet_Gender = Pet_Gender_txt.Text;
     Pet.Pet_Color = Pet_Color_txt.Text;
     Pet.Pet_Weight = Convert.ToInt32(Pet_Weight_txt.Text);
     Pet.Pet_Description = Pet_Description_txt.Text;
     Pet.Pet_Condition = Pet_Condition_txt.Text;
     Pet.Pet_Status = Pet_Status_txt.Text;
     Pet.Pet_Date_Of_Birth = Convert.ToDateTime(Pet_Date_Of_Birth_txt.Text);
     byte[] uploaded_picture = FileUpload1.FileBytes;
     Pet.Pet_Picture = uploaded_picture;
     Pet.Pet_Sterilized = Pet_Sterilized_txt.Text;
     Pet.Date_Modified = Convert.ToDateTime(Date_Modified_txt.Text);
     Pet.Date_Created = Convert.ToDateTime(Date_Created_txt.Text);
     Pet = Pet.Insert(Pet);
     GridView1.DataBind();
     return Pet;
 }
开发者ID:ManigandanS,项目名称:Disaster-Management-Communication-System,代码行数:25,代码来源:Testing.aspx.cs


示例10: JoinEx1

        public static void JoinEx1()
        {
            Person magnus = new Person { Name = "Hedlund, Magnus" };
            Person terry = new Person { Name = "Adams, Terry" };
            Person charlotte = new Person { Name = "Weiss, Charlotte" };

            Pet barley = new Pet { Name = "Barley", Owner = terry };
            Pet boots = new Pet { Name = "Boots", Owner = terry };
            Pet whiskers = new Pet { Name = "Whiskers", Owner = charlotte };
            Pet daisy = new Pet { Name = "Daisy", Owner = magnus };

            List<Person> people = new List<Person> { magnus, terry, charlotte };
            List<Pet> pets = new List<Pet> { barley, boots, whiskers, daisy };

            // Create a list of Person-Pet pairs where
            // each element is an anonymous type that contains a
            // Pet's name and the name of the Person that owns the Pet.
            var query =
                people.Join(pets,
                            person => person,
                            pet => pet.Owner,
                            (person1, pet1) =>
                                new { OwnerName = person1.Name, Pet = pet1.Name });

            foreach (var obj in query)
            {
                Console.WriteLine(
                    "{0} - {1}",
                    obj.OwnerName,
                    obj.Pet);
            }
        }
开发者ID:radamus,项目名称:OptimizableLINQ,代码行数:32,代码来源:OperatorsTests.cs


示例11: MainVM

        public MainVM()
        {
            var bobbyJoe = new Person("Bobby Joe", new[] { new Pet("Fluffy") });
            var bob = new Person("Bob", new[] { bobbyJoe });
            var littleJoe = new Person("Little Joe");
            var joe = new Person("Joe", new[] { littleJoe });
            Family = new ReactiveList<TreeItem> { bob, joe };

            _addPerson = ReactiveCommand.Create();
            _addPerson.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Person(NewName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _addPet = ReactiveCommand.Create();
            _addPet.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Pet(PetName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _collapse = ReactiveCommand.Create();
            _collapse.Subscribe(_ =>
            {
                SelectedItem?.CollapsePath();
            });
        }
开发者ID:reactiveui-forks,项目名称:ReactiveUI-TreeView,代码行数:32,代码来源:MainVM.cs


示例12: Main

    static void Main()
    {
        Person Ivan = new Person{ Name = "Ivan Petrov" };
        Person Gosho = new Person{ Name = "Gosho Georgiev" };
        Person Mara = new Person{ Name = "Kaka Mara" };

        Pet barley = new Pet{ Name = "Barley", Owner = Ivan };
        Pet boots = new Pet{ Name = "Boots", Owner = Ivan };
        Pet whiskers = new Pet{ Name = "Whiskers", Owner = Mara };
        Pet daisy = new Pet{ Name = "Daisy", Owner = Gosho };

        List<Person> people = new List<Person>{ Ivan, Gosho, Mara };
        List<Pet> pets = new List<Pet>{ barley, boots, whiskers, daisy };
        var query =
        //from person in people
        //   join p in pets on person equals p.Owner
        //   select new { OwnerName = person.Name, Pet = p.Name };
        people.Join(pets, person => person,
                    pet => pet.Owner,
                    (person, pet) =>
                    new { OwnerName = person.Name, Pet = pet.Name });

        foreach (var obj in query)
        {
            Console.WriteLine("{0} - {1}",
                              obj.OwnerName,
                              obj.Pet);
        }
    }
开发者ID:mitev-web,项目名称:acad-asp-mvc,代码行数:29,代码来源:JoinDemo.cs


示例13: GenerateMessage

 internal static void GenerateMessage(Pet pet)
 {
     ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("PetRespectNotificationMessageComposer"));
     serverMessage.AppendInteger(1);
     serverMessage.AppendInteger(pet.VirtualId);
     pet.SerializeInventory(serverMessage);
     pet.Room.SendMessage(serverMessage);
 }
开发者ID:bblackv,项目名称:Yupi,代码行数:8,代码来源:RespectPetNotificationComposer.cs


示例14: dogIndexChanged

 public void dogIndexChanged(object sender, EventArgs e)
 {
     gvCat.SelectedIndex = -1;
     gvBird.SelectedIndex = -1;
     btnPurchase.Enabled = true;
     petToBuy = (Pet)dogList[gvDog.SelectedIndex];
     ViewState["pet"] = pet_dao.ObjectToString(petToBuy);
 }
开发者ID:rhelmstetter,项目名称:445Proj5,代码行数:8,代码来源:Default.aspx.cs


示例15: GenerateMessage

        internal static void GenerateMessage(Pet pet, uint amount)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer"));

            serverMessage.AppendInteger(pet.PetId);
            serverMessage.AppendInteger(pet.VirtualId);
            serverMessage.AppendInteger(amount);
            pet.Room.SendMessage(serverMessage);
        }
开发者ID:weslley17w,项目名称:Yupi,代码行数:9,代码来源:PetExperienceComposer.cs


示例16: MoplaBreed

 internal MoplaBreed(Pet Pet, uint PetId, int Rarity, string MoplaName, string BreedData, int LiveState, int GrowingStatus)
 {
     this.Pet = Pet;
     this.PetId = PetId;
     this.Rarity = Rarity;
     this.MoplaName = MoplaName;
     this.BreedData = BreedData;
     this.LiveState = (MoplaState)LiveState;
     this.GrowingStatus = GrowingStatus;
 }
开发者ID:BjkGkh,项目名称:Mercury,代码行数:10,代码来源:MoplaBreed.cs


示例17:

 Regulus.Remoting.Value<IBattlerBehavior> IBattleAdmissionTickets.Visit(Pet pet)
 {
     Regulus.Remoting.Value<IBattlerBehavior> rce = new Remoting.Value<IBattlerBehavior>();
     ReadyInfomation ri = (from readyInfomation in _ReadyInfomations where readyInfomation.Battler.Id == pet.Owner && readyInfomation.Pet == null select readyInfomation).FirstOrDefault();
     if (ri != null)
     {
         ri.Pet = pet;
         ri.BattleBehavior = rce;
         _Count++;
     }
     return rce;
 }
开发者ID:jiowchern,项目名称:KeysCore,代码行数:12,代码来源:BattleFieldWaittingConnectStage.cs


示例18: Pet

 Regulus.Remoting.Value<Pet> IStorage.FindPet(Guid id)
 {
     var pet = new Pet() { Id = Guid.NewGuid(), Owner = id };
     pet.Energy = new Energy(7);
     Func<bool>[] energyIncs = new Func<bool>[]{pet.Energy.IncGreen , pet.Energy.IncRed , pet.Energy.IncYellow };
     /*for(int i = 0 ; i < 3 ; ++i)
     {
         energyIncs[Regulus.Utility.Random.Next(0, 3)]();
     }*/
     pet.Name = _Count++ % 2 == 0 ? "蝙蝠" : "甲蟲";
     return pet;
 }
开发者ID:jiowchern,项目名称:KeysCore,代码行数:12,代码来源:Storage.cs


示例19: Main

    public static void Main()
    {
        Console.WriteLine("Pet Properties");

        // Create a new Person object:
        Pet pet = new Pet();

        // Print out the name and the age associated with the person:
        Console.WriteLine("Pet details - {0}", pet);
        pet.Name = "Doge";
        pet.Age = 99;
        pet.Sex = "male";
        pet.Type = "Shiba Inu";
        Console.WriteLine("Pet details - {0}", pet);
    }
开发者ID:mr-fool,项目名称:CSharp,代码行数:15,代码来源:Pet.cs


示例20: Awake

 public override void Awake()
 {
     base.Awake();
     atkAnimKeyFrame = 14;
     if (GotoProxy.getSceneName() != GotoProxy.SKILLTREE
         && GotoProxy.getSceneName() != GotoProxy.YOUR_TEAM
         && GotoProxy.getSceneName() != GotoProxy.COMBINED_ARMORY
         && GotoProxy.getSceneName() != GotoProxy.ARMORY )
     {
         GameObject petObj = Instantiate(petPrb, gameObject.transform.position, gameObject.transform.rotation) as GameObject;
         pet = petObj.GetComponent<Pet>();
         pet.selectMaster(this);
     }
     isTigersClaw = false;
 }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:15,代码来源:Trainer.cs



注:本文中的Pet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PetaPoco.Database类代码示例发布时间:2022-05-24
下一篇:
C# Pessoa类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap