本文整理汇总了C#中Parent类的典型用法代码示例。如果您正苦于以下问题:C# Parent类的具体用法?C# Parent怎么用?C# Parent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parent类属于命名空间,在下文中一共展示了Parent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndDisposeParentChildLoop
public void CreateAndDisposeParentChildLoop()
{
var parent = new Parent { Child = new Child("c") };
parent.Child.Parent = parent;
Assert.AreSame(parent, parent.Child.Parent);
Assert.AreSame(parent.Child, parent.Child.Parent.Child);
var propertyChanges = new List<string>();
var changes = new List<EventArgs>();
var tracker = Track.Changes(parent, ReferenceHandling.Structural);
tracker.PropertyChanged += (_, e) => propertyChanges.Add(e.PropertyName);
tracker.Changed += (_, e) => changes.Add(e);
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
tracker.Dispose();
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
parent.Name += "abc";
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
parent.Child.Name += "abc";
Assert.AreEqual(0, tracker.Changes);
CollectionAssert.IsEmpty(propertyChanges);
CollectionAssert.IsEmpty(changes);
}
示例2: Test
public void Test()
{
var p = new Parent { Child = new Child() };
p.Child.A = 1;
var json = p.ToJson();
BsonSerializer.Deserialize<Parent>(json); // throws Unexpected element exception
}
示例3: InvokeAdjacent
//InvokeAdjacent is a recursive function for the reconnection of adjacent blocks to current ship parent
//(and the setup that comes with that)
public void InvokeAdjacent(int NewShipID)
{
ShipID = NewShipID;
GameObject tParent = GameObject.Find ("Parent " + NewShipID.ToString ());
//if there is no parent with this ShipID, make one
if (tParent == null) {
ParentTrans = Instantiate (bc.Parent, transform.position, Quaternion.identity) as Transform;
Parent = ParentTrans.GetComponent<Parent>();
Parent.ShipID = NewShipID;
Parent.bc = bc;
ParentTrans.name = "Parent " + NewShipID.ToString ();
}
//join the ship with the ID
else
{
ParentTrans = tParent.transform;
Parent = ParentTrans.GetComponent<Parent>();
}
transform.parent = ParentTrans;
//Make the other blocks adjacent to this one do this process (recursive)
for(int i = 0;i < 4;i++)
{
Block thisCheck = CheckAdjacent(i);
if(thisCheck != null && thisCheck.ShipID != NewShipID)
{
thisCheck.InvokeAdjacent(NewShipID);
}
}
}
示例4: ParentChildCreateWhenParentDirtyLoop
public void ParentChildCreateWhenParentDirtyLoop()
{
var changes = new List<string>();
var expectedChanges = new List<string>();
var x = new Parent { Name = "p1", Child = new Child("c") };
x.Child.Parent = x;
var y = new Parent { Name = "p2", Child = new Child("c") };
y.Child.Parent = y;
using (var tracker = Track.IsDirty(x, y, ReferenceHandling.Structural))
{
tracker.PropertyChanged += (_, e) => changes.Add(e.PropertyName);
Assert.AreEqual(true, tracker.IsDirty);
CollectionAssert.IsEmpty(changes);
var expected = "Parent Child Parent ... Name x: p1 y: p2";
var actual = tracker.Diff.ToString("", " ");
Assert.AreEqual(expected, actual);
x.Name = y.Name;
y.Name = x.Name;
expectedChanges.Add("Diff", "IsDirty");
CollectionAssert.AreEqual(expectedChanges, changes);
Assert.AreEqual(false, tracker.IsDirty);
}
}
示例5: SetUp
public void SetUp()
{
this._parent = new Parent();
this._child = new Child();
this._parent.Child = this._child;
this._child.Parent = this._parent;
}
示例6: LoadTestData
protected override void LoadTestData()
{
var parent = new Parent("Mike Hadlow", string.Format("{0}@yahoo.com", "mike"), "yyy");
Session.Save(parent);
this.FlushSessionAndEvict(parent);
parentId = parent.Id;
}
示例7: LoadTestData
protected override void LoadTestData()
{
User user = new Parent("Dad", "[email protected]", "xxx");
Session.Save(user);
this.FlushSessionAndEvict(user);
userId = user.Id;
}
示例8: Test
public void Test()
{
Family family = new Family();
Child child1 = new Child(1);
Child child2 = new Child(2);
Parent parent = new Parent(new List<Child>() {child1, child2});
family.Add(parent);
string file = "sandbox.txt";
try
{
File.Delete(file);
}
catch
{
}
using (var fs = File.OpenWrite(file))
{
Serializer.Serialize(fs, family);
}
using (var fs = File.OpenRead(file))
{
family = Serializer.Deserialize<Family>(fs);
}
System.Diagnostics.Debug.Assert(family != null, "1. Expect family not null, but not the case.");
}
示例9: IfNullCreateSetsPropertyAndReturnsCorrectValueIfChildIsNull
public void IfNullCreateSetsPropertyAndReturnsCorrectValueIfChildIsNull()
{
var parent = new Parent();
var candidate = parent.IfNullCreate(t => t.Child, () => new Child());
Assert.IsNotNull(candidate);
Assert.AreSame(candidate, parent.Child);
}
示例10: Poke
public override void Poke(Parent parent)
{
base.Poke (parent);
tree.actions.SetSpeed(speed);
parent.ReceiveStatus(Status.Success);
}
示例11: TypeEqualityIsRespected
public void TypeEqualityIsRespected()
{
var parent = new Parent().GetChangeType();
var child = new Child().GetChangeType();
Assert.IsTrue(parent.IsA(typeof(Parent)));
Assert.IsTrue(child.IsA(typeof(Child)));
}
示例12: Add
public string Add(ParentModelView parent)
{
if(ModelState.IsValid)
{
int user_id = SessionHandler.GetUserID();
if (user_id == -1)
{
return (false).ToJSON();
}
int school_id = SessionHandler.GetSchoolID();
Parent s = new Parent()
{
gfirst_name = parent.GardianFirstName,
glast_name = parent.GardianLastName,
address = parent.Address,
phone = parent.Phone,
password = parent.Password,
school_id = school_id,
created_by = user_id,
updated_by = user_id,
profession = parent.Profession,
income = parent.Income,
pfirst_name = parent.ParentFirstName,
plast_name = parent.ParentLastName,
mother_name = parent.MotherName,
landline = parent.Landline,
cnic = parent.CNICNumber,
email = parent.EmailAddress
};
bool result = _pd.Insert(s);
return result.ToJSON();
}
return "";
}
示例13: InheritanceIsRespected
public void InheritanceIsRespected()
{
var parent = new Parent().GetChangeType();
var child = new Child().GetChangeType();
Assert.IsFalse(parent.IsA(typeof(Child)));
Assert.IsTrue(child.IsA(typeof(Parent)));
}
示例14: SetUp
public void SetUp()
{
parent = new Parent
{
Id = 10,
Name = "Parent from repository",
Child = new Child
{
Id = 3,
Name = "Child of Parent from repository"
}
};
parentRepository = new FakeRepository(id => parent);
childRepository = new FakeRepository(id => parent.Child);
repositoryResolver = MockRepository.GenerateStub<IRepositoryResolver>();
repositoryResolver.Stub(r => r.GetRepository(typeof (Parent))).Return(parentRepository);
repositoryResolver.Stub(r => r.GetRepository(typeof (Child))).Return(childRepository);
entityModelBinder = new EntityModelBinder(repositoryResolver);
controllerContext = new ControllerContext
{
HttpContext = MockRepository.GenerateStub<HttpContextBase>()
};
request = MockRepository.GenerateStub<HttpRequestBase>();
controllerContext.HttpContext.Stub(x => x.Request).Return(request);
entityModelBinder.SetModelBinderDictionary(new ModelBinderDictionary { DefaultBinder = entityModelBinder });
}
示例15: LoadTestData
protected override void LoadTestData()
{
var parent = new Parent(name: "Mike Hadlow", userName: string.Format("{0}@yahoo.com", "mike"), password: "yyy");
session.Store(parent);
parentId = parent.Id;
this.FlushSessionAndEvict(parent);
}