本文整理汇总了C#中Parent类的典型用法代码示例。如果您正苦于以下问题:C# Parent类的具体用法?C# Parent怎么用?C# Parent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parent类属于命名空间,在下文中一共展示了Parent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:30,代码来源:ChangeTrackerTests.ReferenceLoops.cs
示例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
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:7,代码来源:CSharp147Tests.cs
示例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);
}
}
}
开发者ID:scrblnrd3,项目名称:ShipRekt,代码行数:31,代码来源:Block.cs
示例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);
}
}
开发者ID:JohanLarsson,项目名称:Gu.State,代码行数:25,代码来源:DirtyTrackerTests.ReferenceLoops.cs
示例5: SetUp
public void SetUp()
{
this._parent = new Parent();
this._child = new Child();
this._parent.Child = this._child;
this._child.Parent = this._parent;
}
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:7,代码来源:CloneExtensionCircularReferenceTests.cs
示例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;
}
开发者ID:sharparchitecture,项目名称:Sharp-Architecture,代码行数:7,代码来源:ParentTests.cs
示例7: LoadTestData
protected override void LoadTestData()
{
User user = new Parent("Dad", "[email protected]", "xxx");
Session.Save(user);
this.FlushSessionAndEvict(user);
userId = user.Id;
}
开发者ID:sharparchitecture,项目名称:Sharp-Architecture,代码行数:7,代码来源:MessageTests.cs
示例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.");
}
开发者ID:Erguotou,项目名称:protobuf-net,代码行数:29,代码来源:SO7219959.cs
示例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);
}
开发者ID:kevinwiegand,项目名称:EnergyTrading-Core,代码行数:7,代码来源:ReflectionExtensionsFixture.cs
示例10: Poke
public override void Poke(Parent parent)
{
base.Poke (parent);
tree.actions.SetSpeed(speed);
parent.ReceiveStatus(Status.Success);
}
开发者ID:rdstn,项目名称:Project,代码行数:7,代码来源:SetSpeed.cs
示例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)));
}
开发者ID:NiSHoW,项目名称:FrameLogCustom,代码行数:7,代码来源:ChangeTypeTests.cs
示例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 "";
}
开发者ID:MuhammadUsmaann,项目名称:Education-System-Web-App,代码行数:35,代码来源:ParentController.cs
示例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)));
}
开发者ID:NiSHoW,项目名称:FrameLogCustom,代码行数:7,代码来源:ChangeTypeTests.cs
示例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 });
}
开发者ID:somlea-george,项目名称:sutekishop,代码行数:30,代码来源:EntityModelBinderTests.cs
示例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);
}
开发者ID:seif,项目名称:SharpArch.TardisBank,代码行数:7,代码来源:ParentTests.cs
示例16: SetUp
public void SetUp()
{
parent = new Parent("Mike Hadlow", "[email protected]", "pwd");
child = parent.CreateChild("Leo", "leohadlow", "xxx");
somebodyElse = new Parent("John Robinson", "[email protected]", "pwd");
somebodyElsesChild = somebodyElse.CreateChild("Jim", "jimrobinson", "yyy");
}
开发者ID:sharparchitecture,项目名称:Sharp-Architecture,代码行数:8,代码来源:MakePaymentTests.cs
示例17: NewParentCreatedEvent
public NewParentCreatedEvent(Parent parent)
{
if (parent == null)
{
throw new ArgumentNullException("parent");
}
this.Parent = parent;
}
开发者ID:seif,项目名称:SharpArch.TardisBank,代码行数:8,代码来源:NewParentCreatedEvent.cs
示例18: ShouldGetProperty
public void ShouldGetProperty()
{
var instance = new Parent { Child = { Text = "foo" } };
ReflectionUtil.GetProperty(instance, "Child").ShouldBe(Child.Instance);
ReflectionUtil.GetProperty<Child>(instance, "Child").ShouldBe(Child.Instance);
ReflectionUtil.GetProperty(instance, new[] { "Child", "Text", "Length" }).ShouldBe(3);
ReflectionUtil.GetProperty<int>(instance, new[] { "Child", "Text", "Length" }).ShouldBe(3);
}
开发者ID:JonasSamuelsson,项目名称:Handyman,代码行数:8,代码来源:ReflectionUtilTests.cs
示例19: Main
public static int Main (string[] args) {
Parent p;
Parent f = new Parent();
Bar b = new Bar();
p = args == null? (Parent) f : (Parent) b;
return 1;
}
开发者ID:Zman0169,项目名称:mono,代码行数:8,代码来源:valid_merge_first_value_is_base_type.cs
示例20: Parents
public void Parents()
{
var p1 = new Parent { new Child(1), new Child(2) };
var p2 = new Parent { new Child(1), new Child(2) };
var comparison = DeepEqualsNode.CreateFor(p1, p2);
var dump = Dump(comparison);
Console.Write(dump);
}
开发者ID:JohanLarsson,项目名称:Gu.SerializationAsserts,代码行数:8,代码来源:ComparisonTest.cs
注:本文中的Parent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论