示例#1
0
        private static List <Tuple <String, String, object> > RunMethods(ViableMapAndData aMap, List <dynamic> objects)
        {
            List <Tuple <String, String, object> > results = new List <Tuple <String, String, object> >();
            var methodStore = aMap.StoredData.Where(x => x.MapType.Equals(DataMapType.MethodParameterMap) && !x.DataStoreName.Equals(ParameterExtruder.Constructor));

            if (methodStore.Any())
            {
                foreach (DataStore aStore in methodStore)
                {
                    foreach (DataRow aRow in aStore.ActualData.Rows)
                    {
                        foreach (dynamic anObject in objects)
                        {
                            MethodInfo method = anObject.GetType().GetMethod(aStore.DataStoreName);

                            List <object[]> paramList = ParameterExtruder.BuildParameterArrayList(aMap, method.Name);
                            if (paramList.Count > 0)
                            {
                                foreach (Object[] parameters in paramList)
                                {
                                    results.Add(InvokeMethod(method, anObject, parameters, aStore.DataStoreName));
                                }
                            }
                            else
                            {
                                results.Add(InvokeMethod(method, anObject, null, aStore.DataStoreName));
                            }
                        }
                    }
                }
            }

            return(results);
        }
示例#2
0
        public static ViableMapAndData LoadMap(string fileName)
        {
            ViableMapAndData loadedMap = null;

            FileSerializations.FileDeserialization(fileName, ref loadedMap);
            return(loadedMap);
        }
示例#3
0
        public static List <Object[]> BuildParameterArrayList(ViableMapAndData aMap, string methodName)
        {
            List <Object[]> parameterList = new List <object[]>();
            var             methodStores  = aMap.StoredData.Where(x => x.MapType.Equals(DataMapType.MethodParameterMap));

            if (methodStores.Any())
            {
                var parameterStores = methodStores.Where(x => x.DataStoreName.Equals(methodName));
                if (parameterStores != null)
                {
                    foreach (DataStore aStore in parameterStores)
                    {
                        if (aStore.ActualData != null)
                        {
                            MethodParameterMap aParamMap = ParameterExtruder.GetParameterMap(methodName, aMap.TheMap, aStore.ActualData.Columns.Count);
                            foreach (DataRow aRow in aStore.ActualData.Rows)
                            {
                                object[] parameters = ParameterExtruder.ExtractParameters(aParamMap, aRow);
                                parameterList.Add(parameters);
                            }
                        }
                        else
                        {
                            parameterList.Add(null);
                        }
                    }
                }
            }

            return(parameterList);
        }
示例#4
0
        /// <summary>
        /// intitializes objects with properties and fields from data stores.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        public static List <dynamic> CreateAndIntializePropertiesAndFields(ViableMapAndData aMap, Assembly anAssembly)
        {
            List <dynamic> results = new List <dynamic>();

            results.AddRange(CreateAndInitializeProperties(aMap, anAssembly));
            InitializeFields(aMap, results);
            return(results);
        }
示例#5
0
        /// <summary>
        /// intitializes objects fields from data stores.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        private static void InitializeFields(ViableMapAndData aMap, List <dynamic> createdObjects)
        {
            var FieldStore = aMap.StoredData.Where(x => x.MapType.Equals(DataMapType.FieldColumnMap)).FirstOrDefault();
            int count      = -1;

            foreach (dynamic anObject in createdObjects)
            {
                InI.InitializeFields(anObject, aMap.TheMap, FieldStore.ActualData.Rows[count]);
            }
        }
示例#6
0
        public static List <String> CreateTemplateParams(ViableMapAndData data)
        {
            List <String> results = new List <string>();

            foreach (DataStore aStore in data.StoredData)
            {
                results.AddRange(CreateTemplateParams(aStore.ActualData, data.TheMap, aStore.DataStoreName, String.Empty));
            }

            return(results);
        }
示例#7
0
        /// <summary>
        /// intitializes objects with fields from data stores.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        private static List <dynamic> CreateAndInitializeFields(ViableMapAndData aMap, Assembly anAssembly, object[] parameters)
        {
            List <dynamic> result     = new List <dynamic>();
            var            fieldStore = aMap.StoredData.Where(x => x.MapType.Equals(DataMapType.FieldColumnMap)).FirstOrDefault();

            foreach (DataRow aRow in fieldStore.ActualData.Rows)
            {
                dynamic anObject = InI.CreateObjectFromAssembly(anAssembly, aMap.TheMap.ClassName, parameters);
                InI.InitializeFields(anObject, aMap.TheMap, aRow);

                result.Add(anObject);
            }
            return(result);
        }
示例#8
0
        /// <summary>
        /// creates objects with parameters in their constructors
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="anAssembly"></param>
        private static List <dynamic> CreateAndInitializeFields(ViableMapAndData aMap, Assembly anAssembly)
        {
            List <dynamic>  result        = new List <dynamic>();
            List <Object[]> parameterList = ParameterExtruder.BuildParameterArrayList(aMap, ".ctor");

            if (parameterList.Count > 0)
            {
                foreach (Object[] parameters in parameterList)
                {
                    result.AddRange(CreateAndInitializeFields(aMap, anAssembly, parameters));
                }
            }
            else
            {
                result.AddRange(CreateAndInitializeFields(aMap, anAssembly, null));
            }
            return(result);
        }
示例#9
0
        /// <summary>
        /// creates objects with parameters in their constructors
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        /// <returns></returns>
        private static List <dynamic> CreateAndInitializeProperties(ViableMapAndData aMap, string assemblyLocation)
        {
            Assembly anAssembly = Assembly.LoadFrom(assemblyLocation);

            return(CreateAndInitializeProperties(aMap, anAssembly));
        }
示例#10
0
        private static List <Tuple <String, String, object> > CreateObjectInitializeFieldsAndRunMethods(ViableMapAndData aMap, Assembly anAssembly)
        {
            List <Tuple <String, String, object> > results = new List <Tuple <String, String, object> >();
            List <dynamic>  injectedObjects   = new List <dynamic>();
            List <Object[]> constructorParams = ParameterExtruder.BuildParameterArrayList(aMap, ParameterExtruder.Constructor);

            foreach (Object[] ctorParameters in constructorParams)
            {
                injectedObjects.Add(CreateAndInitializeFields(aMap, anAssembly, ctorParameters));
            }

            if (injectedObjects.Any())
            {
                results = RunMethods(aMap, injectedObjects);
            }



            return(results);
        }
示例#11
0
        public static List <Tuple <String, String, object> > CreateObjectInitializeFieldsAndRunMethods(string fileName, Assembly anAssembly)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateObjectInitializeFieldsAndRunMethods(aMap, anAssembly));
        }
示例#12
0
        /// <summary>
        /// No parameters in Constructor
        /// </summary>
        /// <param name="aMap"></param>
        /// <param name="anAssembly"></param>
        /// <returns></returns>
        private static List <Tuple <String, String, object> > CreateInitializePropertiesFieldsAndRunMethodsWoParams(ViableMapAndData aMap, Assembly anAssembly)
        {
            List <dynamic> injectedObjects = new List <dynamic>();

            injectedObjects.AddRange(CreateAndIntializePropertiesAndFieldsWoParams(aMap, anAssembly));
            return(RunMethods(aMap, injectedObjects));
        }
示例#13
0
        //creates objects and initializes fields wiht paramters in constructor
        public static List <dynamic> CreateAndInitializeFields(string fileName, Assembly anAssembly)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateAndInitializeFields(aMap, anAssembly));
        }
示例#14
0
 private void lstMappedSources_SelectedIndexChanged(object sender, EventArgs e)
 {
     currentMappedSource = (ViableMapAndData)lstMappedSources.SelectedItems[0].Tag;
 }
示例#15
0
        /// <summary>
        /// No parameters in constructor
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="anAssembly"></param>
        /// <returns></returns>
        public static List <Tuple <String, String, object> > CreateObjectAndRunMethodsNoParams(string fileName, Assembly anAssembly)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateObjectAndRunMethodsNoParams(aMap, anAssembly, null));
        }
示例#16
0
        /// <summary>
        /// creates objects without parameters in their constructors
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        /// <returns></returns>
        public static List <dynamic> CreateAndInitializePropertiesWoParams(string fileName, Assembly anAssembly)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateAndInitializeProperties(aMap, anAssembly, null));
        }
示例#17
0
        /// <summary>
        /// No parameters in constructor
        /// </summary>
        /// <param name="aMap"></param>
        /// <param name="anAssembly"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static List <Tuple <String, String, object> > CreateObjectAndRunMethodsNoParams(ViableMapAndData aMap, Assembly anAssembly, object[] parameters)
        {
            List <dynamic> injectedObjects = new List <dynamic>();
            dynamic        anObject        = InI.CreateObjectFromAssembly(anAssembly, aMap.TheMap.ClassName, parameters);

            injectedObjects.Add(anObject);
            return(RunMethods(aMap, injectedObjects));
        }
示例#18
0
 private static List <dynamic> CreateAndInitializePropertiesWoParams(ViableMapAndData aMap, Assembly anAssembly)
 {
     return(CreateAndInitializeProperties(aMap, anAssembly, null));
 }
示例#19
0
        /// <summary>
        /// creates objects with parameters in their constructors
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="assemblyLocation"></param>
        /// <returns></returns>
        public static List <dynamic> CreateAndInitializeProperties(string fileName, string assemblyLocation)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateAndInitializeProperties(aMap, assemblyLocation));
        }
示例#20
0
        /// <summary>
        /// No paramters in constuctor
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="anAssembly"></param>
        /// <returns></returns>
        private static List <Tuple <String, String, object> > CreateInitializePropertiesFieldsAndRunMethodsWoParams(string fileName, Assembly anAssembly)
        {
            ViableMapAndData aMap = ReadObject.LoadMap(fileName);

            return(CreateInitializePropertiesFieldsAndRunMethodsWoParams(aMap, anAssembly));
        }
示例#21
0
 public static void Buildrule(MappedSourceRule aRule, ViableMapAndData mappedSource)
 {
     aRule.MappedSource = mappedSource;
 }
 public static void StoreMapAndData(ViableMapAndData all, String fileName)
 {
     FileSerializations.FileSerialization(fileName, all);
 }