本文整理汇总了C#中Entity.AddPrototype方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.AddPrototype方法的具体用法?C# Entity.AddPrototype怎么用?C# Entity.AddPrototype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity.AddPrototype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPrototype
public void AddPrototype()
{
Entity entity = new Entity();
Entity prototype = new Entity() { Name = "prototype" };
entity.AddPrototype(prototype);
Assert.AreEqual(1, entity.Prototypes.Where(x => x.Name == "prototype").Count());
}
示例2: AttributeBecomesInheritableAfterAddToParent
public void AttributeBecomesInheritableAfterAddToParent()
{
Entity parent = new Entity() { Name = "parent" };
Entity child = new Entity();
child.AddPrototype(parent);
Attribute attribute = new Attribute("test") { Value = new Value("value") };
child.AddAttribute(attribute);
//Assert.IsFalse(attribute.CanInherit);
Attribute parentAttribute = new Attribute("test") { Value = new Value("new value") };
parent.AddAttribute(parentAttribute);
//Assert.IsTrue(attribute.CanInherit);
Assert.AreEqual(1, parent.Attributes.Count);
Assert.AreEqual(1, child.Attributes.Count);
}
示例3: CannotRemoveReadOnlyEventFromInheritingEntity
public void CannotRemoveReadOnlyEventFromInheritingEntity()
{
bool collectionChanged = false;
Entity parent = new Entity() { Name = "parent" };
Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
parentEvent.SetProperty("Trigger", new Value("test"));
parent.AddEvent(parentEvent);
Entity child = new Entity();
child.AddPrototype(parent);
child.Events.CollectionChanged += (o, e) => collectionChanged = true;
AbstractEvent childEvent = child.Events.Single();
child.RemoveEvent(childEvent);
Assert.IsFalse(collectionChanged);
Assert.AreEqual(1, child.Events.Count);
}
示例4: KeyFollowsInheritedAttribute
public void KeyFollowsInheritedAttribute()
{
Entity parent = new Entity() { Name = "parent" };
Attribute parentAttribute = new Attribute("test");
parent.AddAttribute(parentAttribute);
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
parentAttribute.Name = "test2";
Assert.IsFalse(childAttribute.HasOwnValue);
Assert.AreEqual(0, child.Attributes.Count(x => x.Name == "test"));
Assert.AreEqual(1, child.Attributes.Count(x => x.Name == "test2"));
}
示例5: GiveInheritedAttributeLocalValue
public void GiveInheritedAttributeLocalValue()
{
bool propertyChanged = false;
Entity parent = new Entity() { Name = "parent" };
Attribute parentAttribute = new Attribute("test");
parent.AddAttribute(parentAttribute);
Entity child = new Entity();
child.AddPrototype(parent);
Assert.AreEqual(1, child.Attributes.Count(x => x.IsInherited && !x.HasOwnValue));
Attribute childAttribute = child.GetAttribute("test");
childAttribute.PropertyChanged += (o, e) => propertyChanged |= (e.PropertyName == "HasOwnValue");
childAttribute.Value = new Value("value");
Assert.IsTrue(propertyChanged);
Assert.AreEqual(1, child.Attributes.Count(x => x.HasOwnValue));
}
示例6: ClearAttributeValue
public void ClearAttributeValue()
{
Entity parent = new Entity() { Name = "parent" };
Attribute parentAttribute = new Attribute("test") { Value = new Value("originalValue") };
parent.AddAttribute(parentAttribute);
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
childAttribute.Value = new Value("value");
Assert.AreEqual(childAttribute.Value.Initializer, "value");
Assert.AreEqual(1, child.Attributes.Count(x => x.HasOwnValue));
childAttribute.Value = null;
Assert.AreEqual(childAttribute.Value.Initializer, "originalValue");
Assert.AreEqual(0, child.Attributes.Count(x => x.HasOwnValue));
}
示例7: CannotSetReadOnlyEventProperty
public void CannotSetReadOnlyEventProperty()
{
Entity parent = new Entity() { Name = "parent" };
Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
parentEvent.SetProperty("Trigger", new Value("test", true));
parent.AddEvent(parentEvent);
Entity child = new Entity();
child.AddPrototype(parent);
AbstractProperty childProperty = child.Events.Single().GetProperty("Trigger");
childProperty.Value = new Value("test2", true);
Assert.AreEqual("test", childProperty.Value.Reader.GetStrValue());
}
示例8: RemoveReadOnlyEvent
public void RemoveReadOnlyEvent()
{
int eventsFired = 0;
Entity parent = new Entity() { Name = "parent" };
Entity child = new Entity();
child.Events.CollectionChanged += (o, e) => eventsFired++;
child.AddPrototype(parent);
Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType));
parent.AddEvent(parentEvent);
parent.RemoveEvent(parentEvent);
Assert.AreEqual(2, eventsFired);
Assert.AreEqual(0, parent.Events.Count);
Assert.AreEqual(0, child.Events.Count);
}
示例9: AttributesBecomesNonInheritableAfterParentKeyChange
public void AttributesBecomesNonInheritableAfterParentKeyChange()
{
Entity parent = new Entity() { Name = "parent" };
Attribute attribute = new Attribute("test") { Value = new Value("value") };
parent.AddAttribute(attribute);
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
//childAttribute.IsInherited = false;
childAttribute.Value = new Value("new value");
attribute.Name = "test2";
Assert.AreEqual(childAttribute.Name, "test");
//Assert.IsFalse(childAttribute.CanInherit);
Assert.AreEqual(1, parent.Attributes.Count);
Assert.AreEqual(2, child.Attributes.Count);
}
示例10: EventsInheritedFromAllPrototypes
public void EventsInheritedFromAllPrototypes()
{
int eventsFired = 0;
Entity parent = new Entity() { Name = "parent" };
Entity otherParent = new Entity() { Name = "otherParent" };
Entity child = new Entity();
child.Events.CollectionChanged += (o, e) => eventsFired++;
child.AddPrototype(parent);
child.AddPrototype(otherParent);
parent.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));
otherParent.AddEvent(new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)));
Assert.AreEqual(2, eventsFired);
Assert.AreEqual(1, parent.Events.Count(x => x.IsEditable));
Assert.AreEqual(1, otherParent.Events.Count(x => x.IsEditable));
Assert.AreEqual(2, child.Events.Count(x => x.IsReadOnly));
}
示例11: PrototypeMustHaveName
public void PrototypeMustHaveName()
{
Entity entity = new Entity();
Entity prototype = new Entity();
entity.AddPrototype(prototype);
Assert.AreEqual(0, entity.Prototypes.Count());
}
示例12: EntityInheritsAttributeFromPrototype
public void EntityInheritsAttributeFromPrototype()
{
Entity parent = new Entity() { Name = "parent" };
parent.AddAttribute(new Attribute("test"));
Entity child = new Entity();
child.AddPrototype(parent);
Assert.AreEqual(1, parent.Attributes.Where(x => x.Name == "test").Count());
Assert.AreEqual(1, child.Attributes.Where(x => x.Name == "test").Count());
}
示例13: CannotRemoveInheritedAttribute
public void CannotRemoveInheritedAttribute()
{
Entity parent = new Entity() { Name = "parent" };
parent.AddAttribute(new Attribute("test"));
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
child.RemoveAttribute(childAttribute);
Assert.AreEqual(1, child.Attributes.Where(x => x.Name == "test").Count());
}
示例14: CannotChangeKeyForInheritedAttribute
public void CannotChangeKeyForInheritedAttribute()
{
Entity parent = new Entity() { Name = "parent" };
Attribute attribute = new Attribute("test") { Value = new Value("value") };
parent.AddAttribute(attribute);
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
childAttribute.Value = new Value("new value");
Assert.IsTrue(childAttribute.IsInherited);
Assert.IsTrue(childAttribute.Name == "test");
childAttribute.Name = "test2";
Assert.IsTrue(childAttribute.IsInherited);
Assert.IsTrue(childAttribute.Name == "test");
Assert.AreEqual(1, parent.Attributes.Count);
Assert.AreEqual(1, child.Attributes.Count);
}
示例15: ValueFollowsInheritedAttribute
public void ValueFollowsInheritedAttribute()
{
//bool propertyChanged = false;
Entity parent = new Entity() { Name = "parent" };
Attribute parentAttribute = new Attribute("test");
parent.AddAttribute(parentAttribute);
Entity child = new Entity();
child.AddPrototype(parent);
Attribute childAttribute = child.GetAttribute("test");
//childAttribute.PropertyChanged += (o, e) => propertyChanged = (e.PropertyName == "Value");
parentAttribute.Value = new Value("value");
//Assert.IsTrue(propertyChanged);
Assert.AreEqual("value", childAttribute.Value.Initializer);
}