当前位置: 首页>>代码示例>>C#>>正文


C# Person.IsValid方法代码示例

本文整理汇总了C#中Person.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# Person.IsValid方法的具体用法?C# Person.IsValid怎么用?C# Person.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Person的用法示例。


在下文中一共展示了Person.IsValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Hierarchy

		public void Hierarchy()
		{
			ActiveRecordStarter.Initialize( GetConfigSource(), typeof(Person), typeof(Customer) );
			// Recreate();

			Person p1 = new Person();
			
			Assert.IsFalse( p1.IsValid() );

			p1.Name = "hammett";
			p1.Age = 25;

			Assert.IsTrue( p1.IsValid() );

			Customer c1 = new Customer();

			Assert.IsFalse( c1.IsValid() );

			c1.ContactName = "someone";
			c1.Phone = "11";

			Assert.IsFalse( c1.IsValid() );

			c1.Name = "hammett";

			Assert.IsTrue( c1.IsValid() );
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:27,代码来源:ValidationTestCase.Generic.cs

示例2: SaveOrUpdate

        public ActionConfirmation SaveOrUpdate(Person person)
        {
            if (person.IsValid())
            {
                ValidatePerson(person);
                _personRepository.SaveOrUpdate(person);

                ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The person was successfully saved.");
                saveOrUpdateConfirmation.Value = person;

                return saveOrUpdateConfirmation;
            }
            else
            {
                _personRepository.DbContext.RollbackTransaction();

                return ActionConfirmation.CreateFailureConfirmation(
                    "The person could not be saved due to missing or invalid information.");
            }
        }
开发者ID:ryantornberg,项目名称:wrms,代码行数:21,代码来源:PersonManagementService.cs


注:本文中的Person.IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。