本文整理汇总了C#中Child类的典型用法代码示例。如果您正苦于以下问题:C# Child类的具体用法?C# Child怎么用?C# Child使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Child类属于命名空间,在下文中一共展示了Child类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
this._parent = new Parent();
this._child = new Child();
this._parent.Child = this._child;
this._child.Parent = this._parent;
}
示例2: 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)));
}
示例3: UpdateCoverArt
private void UpdateCoverArt(Task<IImageFormat<Image>> task, Child child)
{
switch (task.Status)
{
case TaskStatus.RanToCompletion:
if (task.Result == null)
return;
using (_currentAlbumArt = task.Result.Image)
{
if (_currentAlbumArt != null)
{
string localFileName = GetCoverArtFilename(child);
try
{
_currentAlbumArt.Save(localFileName);
Dispatcher.Invoke(() => MusicCoverArt.Source = _currentAlbumArt.ToBitmapSource().Resize(BitmapScalingMode.HighQuality, true, (int)(MusicCoverArt.Width * ScalingFactor), (int)(MusicCoverArt.Height * ScalingFactor)));
}
catch(Exception)
{
}
}
}
task.Result.Dispose();
break;
}
}
示例4: 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.");
}
示例5: Parent
public Parent(Child[] children)
{
foreach (var child in children)
{
child.Events.AddListenerStream(_childEvents);
}
}
示例6: TestAccessToProtected
public int TestAccessToProtected (Child c)
{
if (c.a == 0)
return 1;
else
return 2;
}
示例7: 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)));
}
示例8: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
Service1Client service = new WCFWebReference.Service1Client();
string userName = UserNameTB.Text;
string password = service.GetHashedPassword(UserPasswordTB.Text);
Person obj = service.Login(userName, password);
if (obj != null)
{
if (obj.GetType() == typeof(Child))
{
child = (Child)obj;
Response.Redirect("Default.aspx");
}
else
{
Response.Write("<script>alert('Teachers cannot log in using this platform. /nPlease use the windows software')</script>");
}
}
else
{
Response.Write("<script>alert('No user found')</script>");
}
}
示例9: convertMainObjectToCommunityMember
public CommunityMember convertMainObjectToCommunityMember(MainObjectFromCsvFileInfo mainObject)
{
CommunityMember communityMemberVm = new CommunityMember();
if(string.IsNullOrWhiteSpace(mainObject.FatherFirstName) && string.IsNullOrWhiteSpace(mainObject.FatherLastName)) {
communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName) ? "N/A" : mainObject.MotherFirstName;
communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName) ? "N/A" : mainObject.MotherLastName;
} else {
communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.FatherFirstName)? "N/A" : mainObject.FatherFirstName;
communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.FatherLastName)? "N/A" : mainObject.FatherLastName;
communityMemberVm.SpouseFirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName)? "N/A" : mainObject.MotherFirstName;
communityMemberVm.SpouseLastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName)? "N/A" : mainObject.MotherLastName;
}
communityMemberVm.PhoneNumber = mainObject.FatherPhone;
communityMemberVm.SpousePhoneNumber = mainObject.MotherPhone;
communityMemberVm.Email = "[email protected]";
if (mainObject.Children != null && mainObject.Children.Count() > 0)
{
communityMemberVm.Children = new List<Child>();
for (int i = 0; i < mainObject.Children.Count(); i++)
{
var mainObjectChild = mainObject.Children[i];
Child child = new Child();
child.FirstName = mainObjectChild.ChildFirstName;
child.LastName = string.IsNullOrWhiteSpace(communityMemberVm.LastName) ? "" : communityMemberVm.LastName;
child.Gender = mainObjectChild.Gender;
child.DateOfBirth = new Extentions().getDobFromAge(mainObjectChild.Age);
communityMemberVm.Children.Add(child);
}
}
return communityMemberVm;
}
示例10: Main
static void Main(string[] args)
{
Child child = new Child();
// Previously null checks were needed before accessing a parent property.
string grandParentNameOld = "No name found";
if (child.Parent != null)
if (child.Parent.GrandParent != null)
grandParentNameOld = child.Parent.GrandParent.Name;
// C# 6: If any property is null, a null result is returned immediately.
// Can be conveniently used with the null-coalescing operator.
string grandParentNameNew = child.Parent?.GrandParent?.Name ?? "No name found";
Console.WriteLine(grandParentNameOld);
Console.WriteLine(grandParentNameNew);
// C# 6: Also works with indexers.
int[] arr = null;
int foundOld = arr != null ? arr[1337] : 0;
int foundNew = arr?[1337] ?? 0;
// Can't use Null-conditional operator to call a delegate directly.
// But can be used by calling the Invoke method.
Func<string, string> func = null;
string result = func?.Invoke("Not invoked");
//string result = func?(); // Syntax not supported
// The Null-conditional operator is nice to use when raising events.
// The call is thread-safe, since the reference is held in a temporary variable.
PropertyChanged?.Invoke(null, null);
Console.Read();
}
示例11: ChildViewModel
public ChildViewModel(Child child)
{
Birthday = child.Birthday;
FullName = child.FullName;
Id = child.Id;
Addres = child.Addres;
}
示例12: PropertyAccessorAccessibilityTest
public void PropertyAccessorAccessibilityTest()
{
Parent parent = new Parent();
Assert.AreEqual("parent", parent.Name);
Child child = new Child();
Assert.AreEqual("child", child.Name);
}
示例13: 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");
}
示例14: AddChild
public ActionResult AddChild(Child child)
{
if (ModelState.IsValid)
{
return Json(membersRepo.AddChild(child), JsonRequestBehavior.AllowGet);
}
return Json(ErrorMessages.getErrorFieldsEmptyServerResponse(), JsonRequestBehavior.AllowGet);
}
示例15: Main
public static void Main()
{
Child child = new Child();
child.print();
((Parent)child).print();
}