Example #1
0
        public static void ValuesFromDictionary(this Object me, Dictionary <string, object> input)
        {
            if (me == null)
            {
                throw new NullReferenceException("Figlotech FromDictionary Extension method called on a null value, this is a natural NullReferenceException");
            }
            var refl = me.AsReflectable();

            foreach (var a in ReflectionTool.FieldsAndPropertiesOf(me.GetType()))
            {
                if (ReflectionTool.GetTypeOf(a).IsPublic&& input.ContainsKey(a.Name))
                {
                    refl[a.Name] = input[a.Name];
                }
            }
        }
Example #2
0
        public static Dictionary <string, object> ValuesToDictionary(this Object me)
        {
            if (me == null)
            {
                throw new NullReferenceException("Figlotech ToDictionary Extension method called on a null value, this is a natural NullReferenceException");
            }

            var retv = new Dictionary <string, object>();
            var refl = me.AsReflectable();

            foreach (var a in ReflectionTool.FieldsAndPropertiesOf(me.GetType()))
            {
                if (ReflectionTool.GetTypeOf(a).IsPublic)
                {
                    retv[a.Name] = ReflectionTool.GetMemberValue(a, me);
                }
            }
            return(retv);
        }
Example #3
0
        public static void ValuesToDataRow(this Object me, DataRow dr, Tuple <List <MemberInfo>, List <DataColumn> > meta = null)
        {
            var type = me.GetType();

            if (meta == null)
            {
                meta = Fi.Tech.Invoke <Tuple <List <MemberInfo>, List <DataColumn> > >(
                    typeof(FiTechCoreExtensions),
                    nameof(FiTechCoreExtensions.MapMeta),
                    type,
                    dr);
            }
            var refl = me.AsReflectable();

            foreach (var data in meta.Item2)
            {
                dr[data.ColumnName] = refl[data.ColumnName];
            }
        }