public static void Main(string[] args) { var client1 = new Client("catdog", "123", "Алексей", 3000, "client", "*****@*****.**", 39); Console.WriteLine($"Role: {client1.Roll}"); Console.WriteLine($"Name: {client1.Name}"); Console.WriteLine($"CurrentSum: {client1.CurrentSum}"); Console.WriteLine(); client1.Put(500); Console.WriteLine($"{client1.Name} Put CurrentSum: {client1.CurrentSum}"); client1.Withdraw(600); Console.WriteLine($"{client1.Name} WithDraw CurrentSum: {client1.CurrentSum}"); Console.WriteLine(); ISchool pupil = new Person(); IUniversity student = new Person(); pupil.Study(); student.Study(); Person person = new Person(); ISchool p1 = person as ISchool; p1.Study(); IUniversity p2 = person as IUniversity; p2.Study(); }
public Student(string name, int uniqueNumber, ISchool school) { if (name == null) { throw new ArgumentNullException("The name of the student can't be null."); } if (name == string.Empty) { throw new ArgumentException("The name of the student can't be empty."); } this.name = name; if (uniqueNumber < 10000 && uniqueNumber > 99999) { throw new ArgumentOutOfRangeException("The name of the student must be between 10000 and 99999."); } this.uniqueNumber = uniqueNumber; if (school == null) { throw new ArgumentNullException("The name of the student can't be null."); } this.school = school; this.school.Add(this); }
private static void Append(XmlNode educationNode, ISchool school) { var schoolNode = Append(educationNode, "school"); if (school.Id != Guid.Empty) { AppendAttribute(schoolNode, "guid", school.Id.ToString("n")); } if (school.CompletionDate != null) { var daterangeNode = Append(schoolNode, "daterange"); Append(daterangeNode, "end", ToString(school.CompletionDate.End)); } Append(schoolNode, "institution", school.Institution); Append(schoolNode, "degree", school.Degree); Append(schoolNode, "major", school.Major); Append(schoolNode, "description", school.Description); var addressNode = Append(schoolNode, "address"); Append(addressNode, "city", school.City); Append(addressNode, "country", school.Country); }
public Student(string name, ISchool school) { this.Name = name; this.UniqueNumber = school.GenerateStudentId(); this.coursesList = new List <ICourse>(); school.AddStudent(this); }
private static NameValueCollection GetParameters(ISchool school) { return(new NameValueCollection { { "Id", school.Id.ToString() }, }); }
private static NameValueCollection GetParameters(ICandidate candidate, ISchool school) { var parameters = new NameValueCollection { { "HighestEducationLevel", candidate.HighestEducationLevel == null ? null : candidate.HighestEducationLevel.Value.ToString() }, }; if (school != null) { if (school.Id != Guid.Empty) { parameters.Add("Id", school.Id.ToString()); } parameters.Add("City", school.City); parameters.Add("Degree", school.Degree); parameters.Add("Description", school.Description); parameters.Add("Institution", school.Institution); parameters.Add("Major", school.Major); parameters.Add("EndDateMonth", school.CompletionDate == null || school.CompletionDate.End == null || school.CompletionDate.End.Value.Month == null ? null : school.CompletionDate.End.Value.Month.Value.ToString()); parameters.Add("EndDateYear", school.CompletionDate == null || school.CompletionDate.End == null ? null : school.CompletionDate.End.Value.Year.ToString()); parameters.Add("IsCurrent", (school.CompletionDate != null && school.CompletionDate.End == null).ToString()); } return(parameters); }
public void Main() { Adapter builder = new Adapter(); builder.Event += new AdapterEvents(EventProcessing); School school = new School(); school.Event += new AdapterEvents(EventProcessing); builder.BuildPartA(school, 3); builder.BuildPartB(school, 100); University university = new University(); university.Event += new AdapterEvents(EventProcessing); SchoolToUniversityAdapter schoolToUniversityAdapter = new SchoolToUniversityAdapter(university); schoolToUniversityAdapter.Event += new AdapterEvents(EventProcessing); ISchool universityBuilding = schoolToUniversityAdapter; builder.BuildPartA(universityBuilding, 10); builder.BuildPartB(universityBuilding, 5); }
internal SchoolViewHtml(ISchool school) { _degree = school.Degree; _major = school.Major; _completionDate = school.GetCompletionDateDisplayText(); _institution = school.Institution; _description = HtmlUtil.LineBreaksToHtml(school.Description); }
public static string GetCompletionDateDisplayText(this ISchool school) { if (school == null || school.CompletionDate == null || school.CompletionDate.End == null) { return(null); } return(school.CompletionDate.End.Value.ToString("MMMM yyyy")); }
public Student(string name, ISchool school) { Validator.NullCheck(school, "School"); this.Id = school.GenerateStudentId(); this.courses = new List <ICourse>(); this.Name = name; school.AddStudent(this); }
private static void AssertSchool(ISchool expectedSchool, ISchool school) { Assert.AreEqual(expectedSchool.CompletionDate, school.CompletionDate); Assert.AreEqual(expectedSchool.Institution, school.Institution); Assert.AreEqual(expectedSchool.Degree, school.Degree); Assert.AreEqual(expectedSchool.Major, school.Major); Assert.AreEqual(expectedSchool.Description, school.Description); Assert.AreEqual(expectedSchool.City, school.City); Assert.AreEqual(expectedSchool.Country, school.Country); }
//IOC容器,atofac演示 static void Main1(string[] args) { //最土的调用 //UserBll userbll = new UserBll(); //基于接口编程 //IUserBll userbll = new UserBll(); //userbll.AddNew("aaa", "123"); //Autofac //先创建一个ContainerBuilder容器构建者 ContainerBuilder builder = new ContainerBuilder(); //演化1:注册IUserBll是IUserBll接口的实现类 //builder.RegisterType<UserBll>().As<IUserBll>(); //演化2:把UserBll注册为所有实现类,比如UserBll类实现了好几个接口,那么Resolve任何一个接口,都会返回我的对象 //builder.RegisterType<UserBll>().AsImplementedInterfaces(); //builder.RegisterType<DogBll>().AsImplementedInterfaces(); //演化3:首先拿到所有实现类所在程序集的名字 Assembly asm = Assembly.Load("MyBll"); //把MyBll程序集里的类都注册一遍 //builder.RegisterAssemblyTypes(asm).AsImplementedInterfaces(); //把MyBll程序集里的类都注册一遍,给属性自动输入实现类 ,SingleInstance()(单例)创建同一个对象 builder.RegisterAssemblyTypes(asm).AsImplementedInterfaces().PropertiesAutowired().SingleInstance(); IContainer container = builder.Build(); //Resolve获得实现类UserBll,创建IUserBll实现类的对象 //IUserBll bll = container.Resolve<IUserBll>(); //Console.WriteLine(bll.GetType()); //bll.AddNew("aa", "123"); //如果IUserBll有多个实现类,把实现类放到一个集合中 //IEnumerable<IUserBll> blls= container.Resolve<IEnumerable<IUserBll>>(); //foreach (IUserBll bll in blls) //{ // Console.WriteLine(bll.GetType()); // bll.AddNew("aaa","333"); //} //IDogBll dogbll=container.Resolve<IDogBll>(); //dogbll.bark(); ISchool school = container.Resolve <ISchool>(); school.FangXue(); ISchool school1 = container.Resolve <ISchool>(); //加了SingleInstance() 判断school和school1是不是同一个引用(对象) Console.WriteLine(object.ReferenceEquals(school, school1)); Console.WriteLine("OK"); Console.ReadKey(); }
public static bool SynchronizeTo(this ISchool source, ISchool target) { bool isModified = false; var sourceSupport = source as ISchoolSynchronizationSourceSupport; // Back synch non-reference portion of PK (PK properties cannot be changed, therefore they can be omitted in the resource payload, but we need them for proper comparisons for persistence) if (source.SchoolName != target.SchoolName) { source.SchoolName = target.SchoolName; } // Copy non-PK properties if ((sourceSupport == null || sourceSupport.IsSchoolYearSupported) && target.SchoolYear != source.SchoolYear) { target.SchoolYear = source.SchoolYear; isModified = true; } // ---------------------------------- // Synch One-to-one relationships // ---------------------------------- // SchoolAddress if (sourceSupport == null || sourceSupport.IsSchoolAddressSupported) { if (source.SchoolAddress == null) { if (target.SchoolAddress != null) { target.SchoolAddress = null; isModified = true; } } else { if (target.SchoolAddress == null) { var itemType = target.GetType().GetProperty("SchoolAddress").PropertyType; var newItem = Activator.CreateInstance(itemType); target.SchoolAddress = (ISchoolAddress)newItem; } isModified |= source.SchoolAddress.Synchronize(target.SchoolAddress); } } // ------------------------------------------------------------- // Sync lists return(isModified); }
public void AdmitStudent_shouldThrow_ifPassedStudentIsNull() { this.testInputStudent = null; var testInputSchoolName = "test school"; var testInputSchoolMinimumIdValue = 1; var testInputSchoolMaximumIdValue = 10; this.testInputSchool = new Schools(testInputSchoolName, testInputSchoolMinimumIdValue, testInputSchoolMaximumIdValue); this.testInputSchool.AdmitStudent(this.testInputStudent); }
public void GenerateUniqueStudentID_shouldGenerateIdValueGreaterThanSchoolMinimumIdValue() { var testInputStudentName = "test student"; var testInputStudentId = 10000; this.testInputStudent = new Student(testInputStudentName, testInputStudentId); var testInputSchoolMinimumIdValue = 1; var testInputSchoolMaximumValue = 100; this.testInputSchool = new Schools("school", testInputSchoolMinimumIdValue, testInputSchoolMaximumValue); this.testInputSchool.AdmitStudent(this.testInputStudent); Assert.IsTrue(testInputSchoolMinimumIdValue <= this.testInputStudent.ID); }
public void AdmitStudent_shouldThrow_ifThePassedStudentAlreadyExistsInStudentsICollection() { var testInputStudentName = "test student"; var testInputStudentId = 10000; this.testInputStudent = new Student(testInputStudentName, testInputStudentId); var testInputSchoolName = "test school"; var testInputSchoolMinimumIdValue = 1; var testInputSchoolMaximumIdValue = 10; this.testInputSchool = new Schools(testInputSchoolName, testInputSchoolMinimumIdValue, testInputSchoolMaximumIdValue); this.testInputSchool.AdmitStudent(this.testInputStudent); this.testInputSchool.AdmitStudent(this.testInputStudent); }
private static ResumeSchoolEntity Map(this ISchool school, Guid resumeId) { var entity = new ResumeSchoolEntity { id = school.Id, resumeId = resumeId, city = school.City, country = school.Country, degree = school.Degree, description = school.Description, institution = school.Institution, major = school.Major, }; school.CompletionDate.MapTo(entity); return(entity); }
public void AdmitStudent_shouldReturnTrue_ifStudentWasSuccessfullyAddedToICollection() { var testInputStudentName = "test student"; var testInputStudentId = 10000; this.testInputStudent = new Student(testInputStudentName, testInputStudentId); var testInputSchoolName = "test school"; var testInputSchoolMinimumIdValue = 1; var testInputSchoolMaximumIdValue = 10; this.testInputSchool = new Schools(testInputSchoolName, testInputSchoolMinimumIdValue, testInputSchoolMaximumIdValue); var actual = this.testInputSchool.AdmitStudent(this.testInputStudent); Assert.IsTrue(actual); }
static void Main(string[] args) { ISchool pupil = new Person(); IUniversity student = new Person(); pupil.Study(); student.Study(); Person person = new Person(); ISchool p1 = person as ISchool; p1.Study(); //person в данном случае является и школьником и студентом IUniversity p2 = person as IUniversity; p2.Study(); Console.ReadKey(); }
public void AdmitStudent_shouldThrow_ifTheIdGeneratorWasNotAbleToGenerateAUniqueIdForTheNewlyAdmittedStudent() { var testInputSchoolName = "test school"; var testInputSchoolMinimumIdValue = 1; var testInputSchoolMaximumIdValue = 2; this.testInputSchool = new Schools(testInputSchoolName, testInputSchoolMinimumIdValue, testInputSchoolMaximumIdValue); var students = new List <IStudent>() { new Student("1", 1), new Student("2", 1), new Student("3", 1) }; for (int i = 0; i < students.Count; i++) { this.testInputSchool.AdmitStudent(students[i]); } }
public async static Task <IJw> LoginAsync(ISchool school, string studentId, string password) { School school_ = school as School; if (school_ == null) { throw new Exception("教务实例无法处理传入的学校"); } RestClient restClient = new RestClient(school_.ServiceUrl); var request = new RestRequest("/wap/wapController.jsp", Method.POST); var rawParam = "action=getLoginInfoNew&sjbz=&isky=1&sswl=&sjxh=&os=android&xtbb=&appver=2.6.109&loginmode=0" + $"&loginId={studentId}&pwd={password}&xxdm={school_.IdCode}"; request.AddParameter("param", Param.Encrypt(rawParam)); request.AddParameter("param2", "4cdb913629de86f59af8ad9f46d48f7a"); request.AddParameter("appinfo", "android2.6.109"); request.AddParameter("token", "00000"); var response = await restClient.ExecutePostAsync(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { throw new Exception("非200状态响应"); } var loginInfo = JsonConvert.DeserializeObject <LoginInfo>(response.Content); if (loginInfo.Flag != "0") { throw new Exception(loginInfo.Message); } Jw result = new Jw(studentId) { School = school_, LoginInfo = loginInfo }; return(result); }
public EtudiantController(ISchool <Etudiant> EtudiantsRepo) { etudiantsRepo = EtudiantsRepo; }
public static void MapTo(this ISchool source, ISchool target, Action <ISchool, ISchool> onMapped) { var sourceSynchSupport = source as ISchoolSynchronizationSourceSupport; var targetSynchSupport = target as ISchoolSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.SchoolName = source.SchoolName; // Copy non-PK properties if (sourceSynchSupport.IsSchoolYearSupported) { target.SchoolYear = source.SchoolYear; } else { targetSynchSupport.IsSchoolYearSupported = false; } // Copy Aggregate Reference Data if (GeneratedArtifactStaticDependencies.AuthorizationContextProvider == null || GeneratedArtifactStaticDependencies.AuthorizationContextProvider.GetAction() == RequestActions.ReadActionUri) { target.SchoolYearTypeResourceId = source.SchoolYearTypeResourceId; target.SchoolYearTypeDiscriminator = source.SchoolYearTypeDiscriminator; } // ---------------------------------- // Map One-to-one relationships // ---------------------------------- // SchoolAddress (Source) if (sourceSynchSupport.IsSchoolAddressSupported) { var itemProperty = target.GetType().GetProperty("SchoolAddress"); if (itemProperty != null) { if (source.SchoolAddress == null) { target.SchoolAddress = null; } else { var itemType = itemProperty.PropertyType; object targetSchoolAddress = Activator.CreateInstance(itemType); (targetSchoolAddress as IChildEntity)?.SetParent(target); source.SchoolAddress.Map(targetSchoolAddress); // Update the target reference appropriately target.SchoolAddress = (ISchoolAddress)targetSchoolAddress; } } } else { targetSynchSupport.IsSchoolAddressSupported = false; } // ------------------------------------------------------------- // Map lists var eTagProvider = new ETagProvider(); // Convert value to ETag, if appropriate var entityWithETag = target as IHasETag; if (entityWithETag != null) { entityWithETag.ETag = eTagProvider.GetETag(source); } // Convert value to LastModifiedDate, if appropriate var dateVersionedEntity = target as IDateVersionedEntity; var etagSource = source as IHasETag; if (dateVersionedEntity != null && etagSource != null) { dateVersionedEntity.LastModifiedDate = eTagProvider.GetDateTime(etagSource.ETag); } }
public void Study(ISchool school) { school.MakeHomework(); school.LearnSubject(); }
public Student(string name, ISchool schoolEnrolledIn) { this.Name = name; Validator.CheckIfNull <ISchool>(schoolEnrolledIn); this.ID = schoolEnrolledIn.GetUniqueStudentID(); }
public async static Task <IJw> LoginAsync(ISchool school, string schoolId, string password) { FakeJw result = new FakeJw(); return(await Task.FromResult(result)); }
public Student(string name, ISchool schoolEnrolledIn) { this.Name = name; Validator.CheckIfNull<ISchool>(schoolEnrolledIn); this.ID = schoolEnrolledIn.GetUniqueStudentID(); }
public void BuildPartA(ISchool school, int numberOfSmth) { school.SetNumberOfFloors(numberOfSmth); }
protected override void MapAll(Api.Models.Requests.Schools.EdFi.Test_Profile_Resource_IncludeOnly.SchoolGetByExample request, ISchool specification) { // Copy all existing values specification.SuspendReferenceAssignmentCheck(); specification.AdministrativeFundingControlDescriptor = request.AdministrativeFundingControlDescriptor; specification.CharterApprovalAgencyTypeDescriptor = request.CharterApprovalAgencyTypeDescriptor; specification.CharterApprovalSchoolYear = request.CharterApprovalSchoolYear; specification.CharterStatusDescriptor = request.CharterStatusDescriptor; specification.InternetAccessDescriptor = request.InternetAccessDescriptor; specification.LocalEducationAgencyId = request.LocalEducationAgencyId; specification.MagnetSpecialProgramEmphasisSchoolDescriptor = request.MagnetSpecialProgramEmphasisSchoolDescriptor; specification.SchoolId = request.SchoolId; specification.SchoolTypeDescriptor = request.SchoolTypeDescriptor; specification.TitleIPartASchoolDesignationDescriptor = request.TitleIPartASchoolDesignationDescriptor; }
protected override void MapAll(SchoolsNullReadRequest request, ISchool specification) { throw new NotSupportedException("Profile only has a Write Content Type defined for this resource, and so the controller does not support read operations."); }
public void BuildPartB(ISchool school, int numberOfSmth) { school.SetNumberOfRooms(numberOfSmth); }