当前位置: 首页>>代码示例>>C#>>正文


C# NbtCompound.Remove方法代码示例

本文整理汇总了C#中NbtCompound.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# NbtCompound.Remove方法的具体用法?C# NbtCompound.Remove怎么用?C# NbtCompound.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NbtCompound的用法示例。


在下文中一共展示了NbtCompound.Remove方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddingAndRemoving

        public void AddingAndRemoving()
        {
            NbtCompound test = new NbtCompound();

            NbtInt foo =  new NbtInt( "Foo" );

            test.Add( foo );

            // adding duplicate object
            Assert.Throws<ArgumentException>( () => test.Add( foo ) );

            // adding duplicate name
            Assert.Throws<ArgumentException>( () => test.Add( new NbtByte( "Foo" ) ) );

            // adding unnamed tag
            Assert.Throws<ArgumentException>( () => test.Add( new NbtInt() ) );

            // adding null
            Assert.Throws<ArgumentNullException>( () => test.Add( null ) );

            // contains existing name
            Assert.IsTrue( test.Contains( "Foo" ) );

            // contains existing object
            Assert.IsTrue( test.Contains( foo ) );

            // contains non-existent name
            Assert.IsFalse( test.Contains( "Bar" ) );

            // contains existing name / different object
            Assert.IsFalse( test.Contains( new NbtInt( "Foo" ) ) );

            // removing non-existent name
            Assert.IsFalse( test.Remove( "Bar" ) );

            // removing existing name
            Assert.IsTrue( test.Remove( "Foo" ) );

            // removing non-existent name
            Assert.IsFalse( test.Remove( "Foo" ) );

            // re-adding object
            test.Add( foo );

            // removing existing object
            Assert.IsTrue( test.Remove( foo ) );

            // clearing an empty NbtCompound
            Assert.AreEqual( test.Count, 0 );
            test.Clear();

            // re-adding after clearing
            test.Add( foo );
            Assert.AreEqual( test.Count, 1 );

            // clearing a non-empty NbtCompound
            test.Clear();
            Assert.AreEqual( test.Count, 0 );
        }
开发者ID:pdelvo,项目名称:LibNbt2012,代码行数:59,代码来源:CompoundTests.cs

示例2: Read

        public NbtCompound Read(NbtCompound metadata) {
            Tags = new NbtTag[metadata.Tags.Count()];
            metadata.CopyTo(Tags, 0);

            foreach (NbtTag b in Tags) 
                metadata.Remove(b);

            return metadata;
        }
开发者ID:umby24,项目名称:ClassicWorld.Net,代码行数:9,代码来源:ClassicWorld.cs

示例3: Read

        public NbtCompound Read(NbtCompound metadata)
        {
            var Data = metadata.Get<NbtCompound>("MCForge");
            Logger.Log(Data["perbuild"].ToString());
            if (Data != null)
            {
                perbuild = Data["perbuild"].ByteValue;
                pervisit = Data["pervisit"].ByteValue;
                metadata.Remove(Data);
            }

            return metadata;
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:13,代码来源:Level.cs

示例4: Read

        public NbtCompound Read(NbtCompound metadata)
        {
            var hcData = metadata.Get<NbtCompound>("Hypercube");

            if (hcData == null)
                return metadata;

            BuildPerms = hcData["BuildPerms"].StringValue;
            ShowPerms = hcData["ShowPerms"].StringValue;
            JoinPerms = hcData["JoinPerms"].StringValue;
            Physics = Convert.ToBoolean(hcData["Physics"].ByteValue);
            Building = Convert.ToBoolean(hcData["Building"].ByteValue);
            History = Convert.ToBoolean(hcData["History"].ByteValue);
            SaveInterval = hcData["SaveInterval"].IntValue;

            if (hcData["MOTD"] != null)
                Motd = hcData["MOTD"].StringValue;

            metadata.Remove(hcData);

            return metadata;
        }
开发者ID:umby24,项目名称:Hypercube,代码行数:22,代码来源:HypercubeMap.cs

示例5: Renaming

        public void Renaming()
        {
            var tagToRename = new NbtInt("DifferentName", 1);
            var compound = new NbtCompound {
                new NbtInt("SameName", 1),
                tagToRename
            };

            // proper renaming, should not throw
            tagToRename.Name = "SomeOtherName";

            // attempting to use a duplicate name
            Assert.Throws<ArgumentException>(() => tagToRename.Name = "SameName");

            // assigning a null name to a tag inside a compound; should throw
            Assert.Throws<ArgumentNullException>(() => tagToRename.Name = null);

            // assigning a null name to a tag inside a compound; should not throw
            compound.Remove(tagToRename);
            tagToRename.Name = null;
        }
开发者ID:johndpalm,项目名称:fNbt,代码行数:21,代码来源:CompoundTests.cs

示例6: Read

        public NbtCompound Read(NbtCompound Metadata)
        {
            NbtCompound CPEData = Metadata.Get<NbtCompound>("CPE");

            if (CPEData != null)
            {
                if (CPEData["ClickDistance"] != null)
                {
                    ClickDistanceVersion = CPEData["ClickDistance"]["ExtensionVersion"].IntValue;
                    ClickDistance = CPEData["ClickDistance"]["Distance"].ShortValue;
                }

                if (CPEData["CustomBlocks"] != null)
                {
                    CustomBlocksVersion = CPEData["CustomBlocks"]["ExtensionVersion"].IntValue;
                    CustomBlocksLevel = CPEData["CustomBlocks"]["SupportLevel"].ShortValue;
                    CustomBlocksFallback = CPEData["CustomBlocks"]["Fallback"].ByteArrayValue;
                }

                if (CPEData["EnvColors"] != null)
                {
                    EnvColorsVersion = CPEData["EnvColors"]["ExtensionVersion"].IntValue;
                    SkyColor = new short[] { CPEData["EnvColors"]["Sky"]["R"].ShortValue, CPEData["EnvColors"]["Sky"]["G"].ShortValue, CPEData["EnvColors"]["Sky"]["B"].ShortValue };
                    CloudColor = new short[] { CPEData["EnvColors"]["Cloud"]["R"].ShortValue, CPEData["EnvColors"]["Cloud"]["G"].ShortValue, CPEData["EnvColors"]["Cloud"]["B"].ShortValue };
                    FogColor = new short[] { CPEData["EnvColors"]["Fog"]["R"].ShortValue, CPEData["EnvColors"]["Fog"]["G"].ShortValue, CPEData["EnvColors"]["Fog"]["B"].ShortValue };
                    AmbientColor = new short[] { CPEData["EnvColors"]["Ambient"]["R"].ShortValue, CPEData["EnvColors"]["Ambient"]["G"].ShortValue, CPEData["EnvColors"]["Ambient"]["B"].ShortValue };
                    SunlightColor = new short[] { CPEData["EnvColors"]["Sunlight"]["R"].ShortValue, CPEData["EnvColors"]["Sunlight"]["R"].ShortValue, CPEData["EnvColors"]["Sunlight"]["R"].ShortValue };
                }

                if (CPEData["EnvMapAppearance"] != null)
                {
                    EnvMapAppearanceVersion = CPEData["EnvMapAppearance"]["ExtensionVersion"].IntValue;
                    TextureURL = CPEData["EnvMapAppearance"]["TextureURL"].StringValue;
                    SideBlock = CPEData["EnvMapAppearance"]["SideBlock"].ByteValue;
                    EdgeBlock = CPEData["EnvMapAppearance"]["EdgeBlock"].ByteValue;
                    SideLevel = CPEData["EnvMapAppearance"]["SideLevel"].ShortValue;
                }

                Metadata.Remove(CPEData);
            }

            return Metadata;
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:43,代码来源:ClassicWorld.cs

示例7: AddingAndRemoving

        public void AddingAndRemoving()
        {
            var foo = new NbtInt("Foo");
            var test = new NbtCompound
            {
                foo
            };

            // adding duplicate object
            Assert.Throws<ArgumentException>(() => test.Add(foo));

            // adding duplicate name
            Assert.Throws<ArgumentException>(() => test.Add(new NbtByte("Foo")));

            // adding unnamed tag
            Assert.Throws<ArgumentException>(() => test.Add(new NbtInt()));

            // adding null
            Assert.Throws<ArgumentNullException>(() => test.Add(null));

            // adding tag to self
            Assert.Throws<ArgumentException>(() => test.Add(test));

            // contains existing name/object
            Assert.True(test.Contains("Foo"));
            Assert.True(test.Contains(foo));
            Assert.Throws<ArgumentNullException>(() => test.Contains((string) null));
            Assert.Throws<ArgumentNullException>(() => test.Contains((NbtTag) null));

            // contains non-existent name
            Assert.False(test.Contains("Bar"));

            // contains existing name / different object
            Assert.False(test.Contains(new NbtInt("Foo")));

            // removing non-existent name
            Assert.Throws<ArgumentNullException>(() => test.Remove((string) null));
            Assert.False(test.Remove("Bar"));

            // removing existing name
            Assert.True(test.Remove("Foo"));

            // removing non-existent name
            Assert.False(test.Remove("Foo"));

            // re-adding object
            test.Add(foo);

            // removing existing object
            Assert.Throws<ArgumentNullException>(() => test.Remove((NbtTag) null));
            Assert.True(test.Remove(foo));
            Assert.False(test.Remove(foo));

            // clearing an empty NbtCompound
            Assert.Equal(0, test.Count);
            test.Clear();

            // re-adding after clearing
            test.Add(foo);
            Assert.Equal(1, test.Count);

            // clearing a non-empty NbtCompound
            test.Clear();
            Assert.Equal(0, test.Count);
        }
开发者ID:KenVanGilbergen,项目名称:ken.Minecraft,代码行数:65,代码来源:NbtCompoundTests.cs


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