本文整理汇总了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 );
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}