public void LoadData() { BeanContext context = BeanContext.GetInstance(); Object ObjectInstance = null; Object Data = null; List <Type> Accessors = context.GetAccessorTypes(); foreach (Type Accessor in Accessors) { if (!Accessor.IsInterface) { ObjectInstance = null; Data = null; MethodInfo Method = Accessor.GetMethod("LoadData"); ObjectInstance = context.GetBean(Accessor); Data = Method.Invoke(ObjectInstance, null); if (Data != null) { PropertyInfo propertyInfo = Accessor.GetProperty("KeyName"); Object KeyName = propertyInfo.GetValue(ObjectInstance); if (KeyName != null) { this.Put(KeyName.ToString(), Data); } } } } }
public ServiceResult ValidateModalFieldsService <T>(dynamic ReferencedObject) { Type ObjectType = typeof(T); ServiceResult serviceResult = null; IList <string> ErrorColumnName = new List <string>(); PropertyInfo[] fields = ObjectType.GetProperties(); CustomAttributeData Attr = null; int Index = 0; while (Index < fields.Length) { int InnerIndex = 0; while (InnerIndex < fields[Index].CustomAttributes.Count()) { Attr = fields[Index].CustomAttributes.ElementAt(InnerIndex); if (Attr.AttributeType.Name == "Required") { if (fields[Index].PropertyType == typeof(System.String)) { var Data = fields[Index].GetValue(ReferencedObject); if (Data == null || Data == "") { ErrorColumnName.Add(fields[Index].Name); } } } InnerIndex++; } Index++; } serviceResult = context.GetBean <ServiceResult>(); if (ErrorColumnName.Count > 0) { serviceResult.IsValidModal = false; } else { serviceResult.IsValidModal = true; } serviceResult.ErrorResultedList = ErrorColumnName; return(serviceResult); }
public List <T> MapTo <T>(DataTable table) { Type ExpectedType = typeof(T); Object NewObject = null; string ColumnName = null; PropertyInfo property = null; List <T> DynamicListObject = new List <T>(); NewObject = context.GetBean <T>(); if (NewObject != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { NewObject = null; NewObject = Activator.CreateInstance(ExpectedType); foreach (DataColumn column in table.Columns) { ColumnName = (column.ColumnName[0]).ToString().ToUpper() + column.ColumnName.Substring(1, column.ColumnName.Length - 1); property = ExpectedType.GetProperty(ColumnName, BindingFlags.Instance | BindingFlags.Public); if (property != null) { if (dr[column] == DBNull.Value) { property.SetValue(NewObject, null); } else { property.SetValue(NewObject, dr[column]); } } } DynamicListObject.Add((T)NewObject); } } return(DynamicListObject); }
public object CreateController(ControllerContext context) { try { BeanContext beanContext = BeanContext.GetInstance(); Type ClassType = context.ActionDescriptor.ControllerTypeInfo.AsType(); Object NewInstance = beanContext.GetBean(ClassType, context.HttpContext); return(NewInstance); } catch (Exception ex) { throw ex; } }
public void InitScopeQueue(string UniqueKey) { Parallel.ForEach(ScopedClassList, ClassName => { Object NewObject = context.GetBean(ClassName, null); if (NewObject != null) { if (!ScopeObjectList.ContainsKey(UniqueKey)) { ScopeObjectList.TryAdd(UniqueKey, new List <InjectionObjects>()); } var CurrentSesstionObjectList = ScopeObjectList.Where(x => x.Key == UniqueKey).FirstOrDefault().Value; if (CurrentSesstionObjectList != null) { CurrentSesstionObjectList.Add(new InjectionObjects { QualifiedName = ClassName, ClassObject = NewObject }); ScopeObjectList.TryAdd(UniqueKey, CurrentSesstionObjectList); } } }); }