Ejemplo n.º 1
0
        private static void applyO2ConfigDependeciesInjection(KO2Config kO2Config)
        {

            if (kO2Config != null && kO2Config.dependenciesInjection != null)
            {
                DI.log.info("Applying O2Config Depedency Injections");
                foreach (var dependency in kO2Config.dependenciesInjection)
                {
                    DI.log.debug("[setting dependecy injection]: {0}.{1} = {2}", dependency.Type, dependency.Parameter, dependency.Value);
                    var targetType = DI.reflection.getType(dependency.Type);
                    if (targetType == null)
                        DI.log.error(" [in applyO2ConfigDependeciesInjection]  Could not get type: {0}", dependency.Type);
                    else
                    {
                        var propertyInfo = DI.reflection.getPropertyInfo(dependency.Parameter, targetType);
                        if (propertyInfo == null)
                            DI.log.error(" [in applyO2ConfigDependeciesInjection]  Could not get property {0} from type: {1}", dependency.Parameter,  dependency.Type);
                        else
                        {
                            if (false == DI.reflection.setProperty(propertyInfo, dependency.Value))                             
                                DI.log.error(" [in applyO2ConfigDependeciesInjection]  Could not set property {0} from type: {1} with value {2}",
                                     dependency.Parameter,  dependency.Type, dependency.Value);                                                        
                        }
                    }

                }
            }
                
        }
Ejemplo n.º 2
0
 private static void saveO2ConfigFile(KO2Config o2ConfigFileToSave, string path)
 {
     O2Kernel_Serialize.createSerializedXmlFileFromObject(o2ConfigFileToSave, path, null);
 }
Ejemplo n.º 3
0
        public static void mergeO2ConfigFiles(KO2Config source, KO2Config target)
        {
            if (source!=null & target!=null)
            {
                foreach (var property in DI.reflection.getProperties(source))
                {
                    var sourceValue = DI.reflection.getProperty(property.Name, source,false);
                    if (sourceValue != null)
                    {
                        switch (property.Name)
                        {        
                            case "dependenciesInjection":
                                var sourceDependenciesInjection = (List<DependencyInjection>)DI.reflection.getProperty(property.Name, source);
                                var targetDependenciesInjection = (List<DependencyInjection>)DI.reflection.getProperty(property.Name, target);
                                targetDependenciesInjection.AddRange(sourceDependenciesInjection);
                                break;
                            case "dependencyInjectionTest":         // we don't want this to be set from here (and it couldn't be anyway since it is static)
                                KO2Config.dependencyInjectionTest = "";
                                break;
                            default:
                                DI.reflection.setProperty(property.Name, target, sourceValue);
                                break;
                        }
                    }
                }

            }
            else
                DI.log.error("in mergeO2ConfigFiles false == (source!=null & target!=null)");
        }
Ejemplo n.º 4
0
 public static KO2Config createO2ConfigFile(string pathToO2ConfigFile)
 {
     var newO2ConfigFile = new KO2Config(pathToO2ConfigFile);
     saveO2ConfigFile(newO2ConfigFile, pathToO2ConfigFile);
     return newO2ConfigFile;
 }