// private static Lazy<WorkQueuer> _globalQueuer = new Lazy<WorkQueuer>(()=> new WorkQueuer("FIGLOTECH_GLOBAL_QUEUER", Environment.ProcessorCount, true)); // public static WorkQueuer GlobalQueuer { get => _globalQueuer.Value; } // public static int currentBDadosConnections = 0; // public static List<string> RanChecks = new List<string>(); // public static string DefaultLogRepository = "Logs\\Fi.TechLogs"; // public static String DefaultBackupStore { get; set; } = "../Backups/"; // public static String Version { // get { // return Assembly.GetExecutingAssembly().GetName().Version.ToString(); // } // } // public static void As<T>(this Fi _selfie, object input, Action<T> act) { // if ( // (typeof(T).IsInterface && input.GetType().GetInterfaces().Contains(typeof(T))) || // input.GetType().IsAssignableFrom(typeof(T)) // ) { // act((T)input); // } // } // public static void RecursiveGiveRids(this Fi _selfie, IDataObject obj) { // if(obj.RID == null) { // obj.RID = Fi.Tech.GenerateIdString(obj.GetType().Name, 64); // var props = ReflectionTool.FieldsAndPropertiesOf(obj.GetType()); // for(int i = 0; i < props.Count; i++) { // var t = ReflectionTool.GetTypeOf(props[i]); // if (t.GetInterfaces().Contains(typeof(IDataObject))) { // Fi.Tech.RecursiveGiveRids((IDataObject) ReflectionTool.GetValue(obj, props[i].Name)); // } // } // } // } // public static T Deserialize<T>(this Fi _selfie, String txt) where T: IDataObject, new() { // var v = JsonConvert.DeserializeObject<T>(txt); // Fi.Tech.RecursiveGiveRids(v); // return v; // } /// <summary> /// deprecated /// this gimmick should barely be used by the data accessors /// provided by the rdbms language providers /// But it's a contravention, must be avoided whenever possible. /// </summary> /// <param name="valor"></param> /// <returns></returns> public static IEnumerable <T> MapFromReader <T>(this Fi _selfie, IDataReader reader, bool ignoreCase = false) where T : new() { var refl = new ObjectReflector(); var existingKeys = new string[reader.FieldCount]; for (int i = 0; i < reader.FieldCount; i++) { var name = reader.GetName(i); if (name != null) { if (ReflectionTool.DoesTypeHaveFieldOrProperty(typeof(T), name)) { existingKeys[i] = name; } } } while (reader.Read()) { T obj = new T(); refl.Slot(obj); for (int i = 0; i < existingKeys.Length; i++) { if (existingKeys[i] != null) { try { var o = reader.GetValue(i); refl[existingKeys[i]] = Fi.Tech.ProperMapValue(o); } catch (Exception x) { Debugger.Break(); throw x; } } } yield return((T)refl.Retrieve()); } yield break; }