當前位置: 首頁>>代碼示例>>C#>>正文


C# Bag類代碼示例

本文整理匯總了C#中Bag的典型用法代碼示例。如果您正苦於以下問題:C# Bag類的具體用法?C# Bag怎麽用?C# Bag使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Bag類屬於命名空間,在下文中一共展示了Bag類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: should_not_return_ticket_given_full_cabinet_when_pick

        public void should_not_return_ticket_given_full_cabinet_when_pick()
        {
            Bag bag = new Bag();
            var cabinet = new Cabinet(0);

            Assert.IsNull(new Direct(cabinet).Store(bag));
        }
開發者ID:renxiaobai,項目名稱:CabinetSystem_weiming,代碼行數:7,代碼來源:DirectTest.cs

示例2: Store

        public Ticket Store(Bag aBag, Ticket ticket)
        {
            if (!HasEmptyBox()) return null;

            _dicTicketBag.Add(ticket, aBag);
            return ticket;
        }
開發者ID:renxiaobai,項目名稱:CabinetSystem_weiming,代碼行數:7,代碼來源:Cabinet.cs

示例3: Simple

        public void Simple()
        {
            var bag1 = new Bag<string>();
            var bag2 = GetTestBag();

            var resultBag = bag1 * bag2;

            Assert.IsTrue(resultBag.Equals(bag1));

            bag1.Add("50", 2);

            var shouldBe = new Bag<string>();

            resultBag = bag1 * bag2;

            Assert.IsTrue(shouldBe.Equals(resultBag));

            bag1.Add("2", 2);

            shouldBe.Add("2", 2);

            resultBag = bag1 * bag2;

            Assert.IsTrue(shouldBe.Equals(resultBag));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:25,代碼來源:Intersection.cs

示例4: Store_One_Bag_When_Not_All_Cabinets_Full_Return_Ticket

 public void Store_One_Bag_When_Not_All_Cabinets_Full_Return_Ticket()
 {
     var smartRobot = new SmartRobot(new List<Cabinet> { new Cabinet(0), new Cabinet(1), new Cabinet(0) });
     var bag = new Bag();
     var ticket = smartRobot.Store(bag);
     Assert.IsNotNull(ticket);
 }
開發者ID:hzhang27,項目名稱:OOBootCamp,代碼行數:7,代碼來源:SmartRobotTest.cs

示例5: Interface

        public void Interface()
        {
            var bag1 = new Bag<int> { 3, 4, 5, 6 };

            var bag2 = new Bag<int> { 3, 4, 5 };

            var shouldBe = new Bag<int> { 6 };

            var resultBag = (Bag<int>)((IBag<int>)bag1).Subtract(bag2);

            Assert.IsTrue(resultBag.Equals(shouldBe));

            bag1.Clear();
            bag2.Clear();

            bag1.Add(3, 3);
            bag2.Add(3, 2);

            bag1.Add(5, 5);
            bag2.Add(5, 7);

            shouldBe.Clear();
            shouldBe.Add(3, 1);

            resultBag = bag1.Subtract(bag2);

            Assert.IsTrue(resultBag.Equals(shouldBe));
        }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:28,代碼來源:Subtract.cs

示例6: TestAddRange

 public void TestAddRange()
 {
     Bag<string> target = new Bag<string>(Capacity);
     Bag<string> rangeOfElements = new Bag<string>(Capacity) { TestElement1, TestElement2, TestElement3 };
     target.AddRange(rangeOfElements);
     Assert.IsTrue(target.Contains(TestElement1) && target.Contains(TestElement2) && target.Contains(TestElement3));
 }
開發者ID:Kserol,項目名稱:artemis_csharp-odb,代碼行數:7,代碼來源:TestBag.cs

示例7: ReadElement

        private void ReadElement(XmlReader reader, Bag parent) {
            var name = XmlConvert.DecodeName(reader.LocalName);
            var type = reader["type"];

            // is it a value node ? i.e. type=""
            if (type != null) {
                if (type == "Array") {
                    // go to first item
                    parent.SetMember(name, ReadArray(reader));
                    reader.Read();
                }
                else {
                    var typeCode = (TypeCode)Enum.Parse(typeof(TypeCode), type);
                    var value = SConvert.XmlDecode(typeCode, reader.ReadElementString());
                    parent.SetMember(name, value);
                }
            }
            else {
                var grappe = new Bag();
                reader.Read();
                parent.SetMember(name, grappe);
                while (reader.MoveToContent() == XmlNodeType.Element) {
                    ReadElement(reader, grappe);
                }

                reader.Read();
            }
        }
開發者ID:RasterImage,項目名稱:Orchard,代碼行數:28,代碼來源:XmlSettingsSerializer.cs

示例8: Dikabryozik

        public Dikabryozik(Point position)
        {
            IsPassable = false;

            Size = new Size(1, 1);

            Id = 0x00018000;

            Speed = 10;

            ViewRadius = 3;
            ViewSight = new Size((uint)ViewRadius, (uint)ViewRadius);
            Position = position;

            _bundle = new Bag(2, 2);

            ObjectWithState = new ObjectWithState(
                new List<IObjectState>
                    {
                        new Staying() {TickCount = STAYING_BASE_TICKCOUNT, Distribution = STAYING_BASE_TICKCOUNT/10, Eternal = false},
                        new Hungry() {TickCount = 300, Distribution = 30, Eternal = true}
                    },
                    false, null, OnChangeState);

            this.StateEvent.FireEvent();
        }
開發者ID:norniel,項目名稱:Game,代碼行數:26,代碼來源:Dikabryozik.cs

示例9: Main

    public static void Main(string[] args)
    {
        System.Console.WriteLine("Starting Tester.");

        System.Console.WriteLine("Writing Hello on wall.");
        Wall wall = new Wall();
        wall.writeBSTROnWall("Hello");
        System.Console.WriteLine("Writing Brrrrr! on wall.");
        wall.writeBSTROnWall("Brrrrr!");
        System.Console.WriteLine("Reading wall:");
        string wallContents = "overwrite me";
        wallContents = wall.readWallBSTR();
        System.Console.WriteLine("Wall says: " + wallContents);
        System.Console.WriteLine("Again, Wall says: '" + wall.readWallBSTR() + "'.");

        System.Console.WriteLine("\n\nDoing Bag-Ball test");
        //TODO What if I create it something like: IBag bag = (IBall) Factory.BagClass();  Eberhard might have said I was supposed to be doing this sort of thing that way.
        Bag bag = new Bag();
        Ball ball = (Ball) bag.ProvideBall(); // TODO what if I cast it as an IBall rather than Ball

        long distance_rolled;
        distance_rolled = ball.roll(2);
        System.Console.WriteLine("Rolling ball by 2. Accumulated distance: {0} (should say 2)", distance_rolled);
        if (distance_rolled != 2) {
            System.Console.WriteLine("Tester.exe: Error, distance wasn't correct. Exiting.");
            Environment.Exit(-1);
        }
        bag.InspectBall(ball);
        distance_rolled = ball.roll(9);
        System.Console.WriteLine("Rolling ball by 9. Accumulated distance: {0} (should say 14)", distance_rolled);
        if (distance_rolled != 14) {
            System.Console.WriteLine("Tester.exe: Error, distance wasn't correct. Exiting.");
            Environment.Exit(-1);
        }
    }
開發者ID:sillsdev,項目名稱:libcom,代碼行數:35,代碼來源:Tester.cs

示例10: ShouldAddAnonymousObject

        public void ShouldAddAnonymousObject() {
            dynamic e = new Bag();

            e.Foos = new { Foo1 = "Bar1", Foo2 = "Bar2" };
            Assert.That(e.Foos.Foo1, Is.EqualTo("Bar1"));
            Assert.That(e.Foos.Foo2, Is.EqualTo("Bar2"));
        }
開發者ID:SunRobin2015,項目名稱:RobinWithOrchard,代碼行數:7,代碼來源:SettingsTests.cs

示例11: MainWindow

        public MainWindow()
        {
            try
            {
                System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener("Debug.log"));
                System.Diagnostics.Debug.AutoFlush = true;
                System.Diagnostics.Debug.WriteLine(String.Format("Started at {0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
                RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Westwood\\Nox");
                if (key == null)
                {
                    MessageBox.Show("Can not find the Nox directory in the registry. You can try reinstalling Nox to fix this.", "Error");
                    Environment.Exit(1);
                }
                string installPath = (string) key.GetValue("InstallPath");
                string bagPath = installPath.Substring(0, installPath.LastIndexOf("\\") + 1) + "Audio.bag";
                bag = new AudioBag(bagPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went very wrong. See the message in the following message box for details.", "Fatal Error");
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
                throw ex;
            }
            //Bag bag = new VideoBag("c:\\Westwood\\Nox\\Video.bag");
            //bag = new AudioBag("c:\\Westwood\\Nox\\Audio.bag");

            InitializeComponent();
        }
開發者ID:elitak,項目名稱:NoxTools,代碼行數:28,代碼來源:MainWindow.cs

示例12: OnDoubleClick

		public override void OnDoubleClick( Mobile from )
		{
            if (Mobiles.BaseVendor.ConsumeBackpackAndBankGold(from, m_Price))
            {
                Bag regBag = new Bag();
                regBag.Hue = 1159;

                regBag.DropItem(new Bottle(12));
                regBag.DropItem(new EyesOfNewt(30));
                regBag.DropItem(new BlackPearl(50));
                regBag.DropItem(new Bloodmoss(50));
                regBag.DropItem(new Nightshade(50));
                regBag.DropItem(new Bandage(50));
                regBag.DropItem(new SulfurousAsh(60));
                regBag.DropItem(new Garlic(70));
                regBag.DropItem(new Ginseng(70));
                regBag.DropItem(new SpidersSilk(75));
                regBag.DropItem(new MandrakeRoot(85));

                from.Backpack.DropItem(regBag);
                from.SendAsciiMessage("You've bought a bag of reagents.");
                from.PlaySound(247);
            }
            else
                from.SendAsciiMessage("You do not have enough money!");
		}
開發者ID:FreeReign,項目名稱:imaginenation,代碼行數:26,代碼來源:ReagentStone.cs

示例13: Simple

        public void Simple()
        {
            var bag = new Bag<string>
                          {
                              "aa"
                          };

            Assert.AreEqual(bag.Count, 1);
            Assert.IsTrue(bag.Contains("aa"));
            Assert.AreEqual(bag["aa"], 1);

            bag.Add("bb");
            Assert.AreEqual(bag.Count, 2);
            Assert.IsTrue(bag.Contains("bb"));
            Assert.AreEqual(bag["bb"], 1);

            bag.Add("aa");
            Assert.AreEqual(bag.Count, 3);
            Assert.IsTrue(bag.Contains("aa"));
            Assert.AreEqual(bag["aa"], 2);

            bag.Add("cc", 3);
            Assert.AreEqual(bag.Count, 6);
            Assert.IsTrue(bag.Contains("cc"));
            Assert.AreEqual(bag["cc"], 3);

            bag.Add("cc", 2);

            Assert.AreEqual(bag.Count, 8);
            Assert.IsTrue(bag.Contains("cc"));
            Assert.AreEqual(bag["cc"], 5);
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:32,代碼來源:Add.cs

示例14: CreateAchievements

        private static IEnumerable<Achievement> CreateAchievements()
        {
            CreateAchievementTrackerDelegate persistentKillZombieTrackerCreator = (am, ew, achievement) => new PersistentKillZombiesTracker(am, ew, achievement.Name);
            PassiveSkill zombieKillReward = new PassiveSkill("Player shoots faster", passiveStats => passiveStats.FireRateMultiplier += 0.1f);

            Bag<Achievement> achievements = new Bag<Achievement>();

            // "important"
            AchievementHelper.CreatePersistentKillingAchievements(achievements);
            AchievementHelper.CreatePersistentRunningAchievements(achievements);
            AchievementHelper.CreateScoreAchievements(achievements);

            // "kill XXX"
            AchievementHelper.CreateKillInTimeAchievements(achievements);
            AchievementHelper.CreateKillRushersWhileRushingAchievements(achievements);
            AchievementHelper.CreateKillWithInvulnerabilityAchievements(achievements);
            AchievementHelper.CreateKillWithSingleRocketAchievments(achievements);
            AchievementHelper.CreateKillGoldenGoblinsAchievements(achievements);

            // "survive"
            AchievementHelper.CreateSurviveWithoutKillingAchievements(achievements);
            AchievementHelper.CreateSurviveWithoutMovingAchievements(achievements);

            // misc
            AchievementHelper.CreateLivesAtAnyPointOfGameAchievements(achievements);
            AchievementHelper.CreateSpendLaserWithoutKillingAchievements(achievements);

            // golden goblin

            // not in atm
            AchievementHelper.CreateIAPAchievements(achievements);

            return achievements;
        }
開發者ID:JaakkoLipsanen,項目名稱:Skypiea,代碼行數:34,代碼來源:AchievementHelper.cs

示例15: Associate

 public void Associate(ComponentTypeFactory tf, Bag<Type> types, BitSet componentBits)
 {
     foreach (var t in types)
     {
         componentBits.Set(tf.GetIndexFor(t));
     }
 }
開發者ID:Kserol,項目名稱:artemis_csharp-odb,代碼行數:7,代碼來源:AspectPromise.cs


注:本文中的Bag類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。