Reflection etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Reflection etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

30 Temmuz 2018 Pazartesi

Tüm TimeZone'ları çekip veritabanına ekleme

            var tzCollection = TimeZoneInfo.GetSystemTimeZones();
            var timeZoneTypes = new List<TimeZoneType>();
            foreach (var timeZoneInfo in tzCollection)
            {
                var timeZoneType = new TimeZoneType
                {
                    TimeZoneInfoId = timeZoneInfo.Id,
                    DaylightName = timeZoneInfo.DaylightName,
                    DisplayName = timeZoneInfo.DisplayName,
                    StandardName = timeZoneInfo.StandardName,
                    SupportsDaylightSavingTime = timeZoneInfo.SupportsDaylightSavingTime,
                    Ticks = timeZoneInfo.BaseUtcOffset.Ticks
                };
                timeZoneTypes.Add(timeZoneType);
            }
            foreach (var timeZoneType in timeZoneTypes)
            {
                db.TimeZoneTypes.Add(timeZoneType);

                db.Commit();
            }


15 Ağustos 2016 Pazartesi

Çalışma zamanı metot üretip çalıştırma

                Type type = Type.GetType("Namespace.ClassName");
                MethodInfo method = type.GetMethod("MethodName");
                object targetClass = Activator.CreateInstance(type);
                object[] paramters= new object[] { paramter1,..., parameterN };
                method.Invoke(targetClass, paramters);

29 Nisan 2015 Çarşamba

Model property doğrulama

            // Arrange
            var propertyInfo = typeof(TEntity).GetProperty("PropertyName");

            // Act
            var attribute = propertyInfo.GetCustomAttributes(typeof(RequiredAttribute))
                                        .Cast<RequiredAttribute>()
                                        .FirstOrDefault();

attribute null değilse PropertyName özelliği [Required]'dır

.net 6 mapget kullanımı

 app.UseEndpoints(endpoints => {     endpoints.MapGet("/", async context =>     {         var response = JsonConvert.Seriali...