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


C# Customer.GetType方法代码示例

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


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

示例1: Main

        public void Main(string[] args)
        {
            var config = new ConfigurationBuilder(@"C:\VSProjects\Precisionsoft\Decidify\trunk\Decidify.UI")
                .AddJsonFile("config.json");
            var mongoProvider = new MongoDbAuditStoreProvider()
                .WithConfiguration(config.Build())
                .Start();

            using (var myDbContext = new MyDBContext(mongoProvider))
            {
                myDbContext.Database.EnsureDeleted();
                myDbContext.Database.EnsureCreated();

                var customer = new Customer()
                {
                    FirstName = "TestFirstName",
                    LastName = "TEstLAstNAme"
                };
                myDbContext.Customers.Add(customer);

                var auditablePropCount =
                    customer.GetType()
                        .GetProperties()
                        .Count(p => !p.GetCustomAttributes(typeof (DoNotAudit), true).Any());

                var nonAuditablePropCount =
                    customer.GetType()
                        .GetProperties()
                        .Count(p => p.GetCustomAttributes(typeof(DoNotAudit), true).Any());
                myDbContext.SaveChanges("Test User");

                Console.WriteLine($"Added object with {auditablePropCount} auditable properties and {nonAuditablePropCount} non-auditable properties." );

                var auditLogs = myDbContext.GetAuditLogs()?.ToList();
                Console.WriteLine($"Audit log contains {auditLogs?.Count()} entries.");
                //foreach (var auditLog in myDbContext.GetAuditLogs())
                //{
                //    Console.WriteLine($"AuditLogId:{auditLog.AuditLogId} TableName:{auditLog.TableName} ColumnName:{auditLog.ColumnName} OriginalValue:{auditLog.OriginalValue} NewValue:{auditLog.NewValue} EventDateTime:{auditLog.EventDateTime}");
                //}

                //if (auditLogs.Count() == auditablePropCount)
                //    Console.WriteLine("Test succeeded.");
                //else
                //    throw new Exception("Something is wrong.");

                Console.Read();
                myDbContext.Database.EnsureDeleted();
            }
        }
开发者ID:johannbrink,项目名称:EFAuditing,代码行数:49,代码来源:Program.cs

示例2: CustomerView

        public CustomerView(Customer model)
        {
            Mapper.CreateMap<Customer, CustomerView>();
            Mapper.Map<Customer, CustomerView>(model, this);

            this.created = model.created.ToString().Replace('T', ' ');
            this.updated = model.updated.ToString().Replace('T', ' ');
            this.type = model.GetType().BaseType.Name;
        }
开发者ID:JobSystemsAB,项目名称:JobSystems-Angular,代码行数:9,代码来源:CustomerView.cs

示例3: DeleteCustomers

        public void DeleteCustomers(List<Customer> customers)
        {
            Customer cliente = new Customer();
              cliente.GetType();

              Type tt = typeof(Customer);
              foreach (PropertyInfo pp in tt.GetProperties())
              {
            //pp.
              }
        }
开发者ID:klassanov,项目名称:cssamples,代码行数:11,代码来源:Customer_BL.cs

示例4: UpdateCustomer

		public void UpdateCustomer(Customer customer)
		{
			NorthwindEntities model = new NorthwindEntities();
			var customerToBeUpdated = (from cust in model.Customers
									  where cust.CustomerID == customer.CustomerID
									  select cust).FirstOrDefault();
			foreach (PropertyInfo property in customer.GetType().GetProperties())
			{
				customerToBeUpdated.GetType().GetProperty(property.Name).
					SetValue(customerToBeUpdated, property.GetValue(customer, new object[] { }), new object[] {});
			}
			model.SaveChanges();
			
		}
开发者ID:angelpetrov90,项目名称:aspnet-sdk,代码行数:14,代码来源:Contractors.cs

示例5: CreateEntry

        private ODataEntry CreateEntry(Customer customer, DataServiceOperationContext operationContext)
        {
            if (customer == null) return null;

            var entry = new ODataEntry();
            entry.EditLink = new Uri(operationContext.AbsoluteServiceUri, "Customers(" + customer.ID + ")");
            entry.Id = entry.EditLink;

            var metadataProvider = (IDataServiceMetadataProvider)operationContext.GetService(typeof(IDataServiceMetadataProvider));
            ResourceType rt;
            metadataProvider.TryResolveResourceType(customer.GetType().FullName, out rt);
            entry.Properties = GetProperties(customer, rt);
            entry.TypeName = rt.FullName;
            return entry;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:15,代码来源:CreateODataWriterTests.cs

示例6: ProcessOrder

        public decimal ProcessOrder(Customer customer, IEnumerable<Product> products)
        {
            // do some processing of order
            decimal orderTotal = products.Sum(p => p.Price);

            Type customerType = customer.GetType();
            if (customerType == typeof(Employee))
            {
                orderTotal -= orderTotal * 0.15m;
            }
            else if (customerType == typeof(NonEmployee))
            {
                orderTotal -= orderTotal * 0.05m;
            }

            return orderTotal;
        }
开发者ID:aloneplayer,项目名称:BenProjects,代码行数:17,代码来源:ReplaceWithPolymorphism.cs

示例7: AddCustomer

		public void AddCustomer(Customer customer)
		{
			Customers.Add(customer);
			NorthwindEntities model = new NorthwindEntities();
			NorthwindDAL.Customer customerToBeInserted = new NorthwindDAL.Customer();
			var customerID = (from cust in model.Customers
							 where cust.CustomerID == customer.CustomerID
							 select cust).FirstOrDefault();
			if (customerID != null)
			{ return; }
			foreach (PropertyInfo property in customer.GetType().GetProperties())
			{
				customerToBeInserted.GetType().GetProperty(property.Name).
					SetValue(customerToBeInserted, property.GetValue(customer, new object[] { }), new object[] { });
			}
			model.Customers.AddObject(customerToBeInserted);
			model.SaveChanges();
		}
开发者ID:angelpetrov90,项目名称:aspnet-sdk,代码行数:18,代码来源:Contractors.cs


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