本文整理汇总了C#中PropertyCollection.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyCollection.Contains方法的具体用法?C# PropertyCollection.Contains怎么用?C# PropertyCollection.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyCollection
的用法示例。
在下文中一共展示了PropertyCollection.Contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPropertyTest
public void AddPropertyTest()
{
PropertyCollection collection = new PropertyCollection(new string[0]);
AttachEvents(collection);
Property prop = new StringProperty("test", "orange");
collection.PropertyAdded += (s, e) =>
{
Assert.AreSame(prop, e.Property);
Assert.AreEqual(1, collection.Count);
Assert.IsTrue(collection.Contains("test"));
Assert.IsTrue(collection.Contains(prop));
};
collection.Add(prop);
Assert.AreEqual(EventFlags.PropertyAdded | EventFlags.Modified, _eventsFired);
}
示例2: Spawn
public Enemy Spawn(EnemyType type, Vector3 pos, PropertyCollection props)
{
Enemy e = null;
switch (type)
{
case EnemyType.Asteroid:
e = new Asteroid(pos, spriteSheets["Asteroid"]);
break;
case EnemyType.Omega:
e = new Omega(pos, spriteSheets["Omega"]);
break;
case EnemyType.Turret:
e = new Turret(pos, spriteSheets["Turret"], props.Contains("Inverted"));
break;
case EnemyType.Squid:
e = new Squid(pos, spriteSheets["Squid"]);
break;
}
Enemies.Add(e);
return e;
}
示例3: RenamePropertyTest
public void RenamePropertyTest()
{
PropertyCollection collection = new PropertyCollection(new string[0]);
AttachEvents(collection);
StringProperty prop = new StringProperty("test", "orange");
collection.PropertyRenamed += (s, e) =>
{
Assert.AreEqual("test", e.OldName);
Assert.AreEqual("two", e.NewName);
Assert.AreEqual(1, collection.Count);
Assert.IsFalse(collection.Contains("test"));
Assert.IsTrue(collection.Contains("two"));
Assert.IsTrue(collection.Contains(prop));
};
collection.Add(prop);
_eventsFired = EventFlags.None;
prop.Name = "two";
Assert.AreEqual(EventFlags.PropertyRenamed | EventFlags.Modified, _eventsFired);
}
示例4: RemovePropertyTest
public void RemovePropertyTest()
{
PropertyCollection collection = new PropertyCollection(new string[0]);
AttachEvents(collection);
Property prop1 = new StringProperty("test", "orange");
Property prop2 = new StringProperty("two", "number");
collection.Add(prop1);
collection.Add(prop2);
collection.PropertyRemoved += (s, e) =>
{
Assert.AreSame(prop1, e.Property);
Assert.AreEqual(1, collection.Count);
Assert.IsFalse(collection.Contains("test"));
Assert.IsTrue(collection.Contains("two"));
Assert.IsFalse(collection.Contains(prop1));
Assert.IsTrue(collection.Contains(prop2));
};
_eventsFired = EventFlags.None;
collection.Remove(prop1);
Assert.AreEqual(EventFlags.PropertyRemoved | EventFlags.Modified, _eventsFired);
}
示例5: ModifyPropertyTest
public void ModifyPropertyTest()
{
PropertyCollection collection = new PropertyCollection(new string[0]);
AttachEvents(collection);
StringProperty prop = new StringProperty("test", "orange");
collection.PropertyModified += (s, e) =>
{
Assert.AreSame(prop, e.Property);
Assert.AreEqual(1, collection.Count);
Assert.IsTrue(collection.Contains("test"));
Assert.IsTrue(collection.Contains(prop));
Assert.AreEqual("blue", e.Property.ToString());
};
collection.Add(prop);
_eventsFired = EventFlags.None;
prop.Value = "blue";
Assert.AreEqual(EventFlags.PropertyModified | EventFlags.Modified, _eventsFired);
}
示例6: BuildContext
public BuildContext(String properties, ParsedPath contentFilePath)
{
ContentFilePath = contentFilePath;
ContentFile = new ContentFileV4();
ContentFile.Load(ContentFilePath);
WriteMessage("Read content file '{0}'", ContentFilePath);
Properties = new PropertyCollection();
// Start with the environment
Properties.AddFromEnvironment();
// Set defaults for important locations
Properties.Set("BuildContentDir", new ParsedPath(Assembly.GetExecutingAssembly().Location, PathType.File).VolumeAndDirectory.ToString());
Properties.Set("ContentFileDir", contentFilePath.VolumeAndDirectory);
Properties.Set("InputDir", contentFilePath.VolumeAndDirectory);
Properties.Set("OutputDir", contentFilePath.VolumeAndDirectory);
// Now override with from content file
Properties.AddFromList(ContentFile.Properties.Select(nv => new KeyValuePair<string, string>(nv.Name.Value, nv.Value.Value)));
// Now override with command line
Properties.AddFromString(properties);
// Add content file hash location if not set already
if (!Properties.Contains("ContentFileHashes"))
{
ParsedPath path = new ParsedPath(Properties.GetRequiredValue("OutputDir"), PathType.Directory);
Properties.Set("ContentHashesFile", path.Append(ContentFilePath.FileAndExtension + ".hashes", PathType.File));
}
ContentFileHashesPath = new ParsedPath(Properties.GetRequiredValue("ContentHashesFile"), PathType.File).MakeFullPath();
ContentFileWriteTime = File.GetLastWriteTime(this.ContentFilePath);
// Create a hash of all the things than can affect the build
SHA1 sha1 = SHA1.Create();
StringBuilder sb = new StringBuilder();
foreach (var rawAssembly in ContentFile.CompilerAssemblies)
{
sb.Append(rawAssembly.Value);
}
foreach (var rawProperty in ContentFile.Properties)
{
sb.Append(rawProperty.Name.Value);
sb.Append(rawProperty.Value.Value);
}
foreach (var rawCompilerSettings in this.ContentFile.CompilerSettings)
{
sb.Append(rawCompilerSettings.Name);
foreach (var extension in rawCompilerSettings.CompilerExtensions)
{
foreach (var input in extension.Inputs)
sb.Append(input.Value);
foreach (var output in extension.Outputs)
sb.Append(output.Value);
}
foreach (var parameter in rawCompilerSettings.Parameters.KeyValues)
{
sb.Append(parameter.Key.Value);
sb.Append(parameter.Value.ToString());
}
}
GlobalHash = BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()))).Replace("-", "");
LoadCompilerClasses();
}
示例7: GetObjectFromProperty
/// <summary>
/// Gets an Object from a Dynamic Entity's Property collection
/// </summary>
/// <param name="col"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
private object GetObjectFromProperty(PropertyCollection col, string propertyName)
{
return col.Contains(propertyName) ? col[propertyName] : null;
}