当前位置: 首页>>代码示例>>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;未经允许,请勿转载。