Ejemplo n.º 1
0
        public virtual bool SetInstanceProperty(ModuleConfig propertyContent)
        {
            bool result = false;

            if ((Instance != null) && (propertyContent != null))
            {
                if (propertyContent.IsProperty())
                {
                    Type           instanceType = Instance.GetType();
                    PropertyInfo[] properties   = instanceType.GetProperties();
                    for (int i = 0; i < properties.Length; i++)
                    {
                        PropertyInfo property = properties[i];
                        if (property.Name.Equals(propertyContent["Property"]))
                        {
                            property.SetValue(Instance, propertyContent.Instance);
                            result = true;
                            break;
                        }
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 protected virtual Boolean LoadModules(ModuleConfig parent, int depth)
 {
     ModuleConfigCollection collection = parent.ModuleConfigCollection;
       Boolean result = false;
       if (collection != null)
       {
     IEnumerator moduleEnum = collection.GetEnumerator();
     if (moduleEnum != null)
     {
       result = CreateInstances(moduleEnum, depth, parent);
       if (depth == 0)
       {
     modules = collection;
     result = result && ConnectPropertyReferences();
     result = result && ConfigureInstances();
     result = result && ConnectReferences();
     result = result && FillAttributes();
     result = result && FillProperties();
     result = result && FillPipes();
       }
     }
       }
       return result;
 }
Ejemplo n.º 3
0
 protected virtual Boolean LoadModule(ModuleConfig config)
 {
     if ((config != null) && config.IsInstance())
     return CreateInstance(config);
       return false;
 }
Ejemplo n.º 4
0
        protected virtual void FindParentGenerics(ModuleConfig config, TypeFabrication moduleType)
        {
            ModuleConfig parentConfig = config.Parent;
              while (moduleType.GenericTypes.Count < moduleType.GenericCnt)
              {
            if (parentConfig == null)
              break;

            TypeFabrication parentType = typeFactory.Fabricate(parentConfig.Type);
            if (parentType.GenericTypes.Count == moduleType.GenericCnt)
            {
              moduleType.GenericTypes.AddRange(parentType.GenericTypes);
              break;
            }

            parentConfig = parentConfig.Parent;
              }
        }
Ejemplo n.º 5
0
 protected virtual Boolean FindInstance(ModuleConfig config)
 {
     if (modules != null)
       {
     IEnumerator enumerator = modules.GetEnumerator();
     if (enumerator != null)
     {
       while (enumerator.MoveNext())
       {
     ModuleConfig instance = enumerator.Current as ModuleConfig;
     if (instance != null && instance.IsInstance())
     {
       if (instance.HasProperty("Key") && instance.GetConfigurationProperty("Key") == config.GetConfigurationProperty("Key"))
       {
         config.Instance = instance.Instance;
         return config.Instance != null;
       }
     }
       }
     }
       }
       return false;
 }
Ejemplo n.º 6
0
 protected Boolean FillAttributes(ModuleConfig module)
 {
     bool result = true;
       IEnumerator modInstEnum = module.ModuleConfigCollection.GetEnumerator();
       ModuleConfig propertyModule = null;
       while (modInstEnum.MoveNext())
       {
     propertyModule = modInstEnum.Current as ModuleConfig;
     if (propertyModule != null)
     {
       result = result && FillAttributes(propertyModule);
       if (propertyModule.HasProperty("Property", false))
     result = result && module.SetInstanceProperty(propertyModule);
     }
     else
       result = false;
       }
       return result;
 }
Ejemplo n.º 7
0
 protected virtual Boolean CreateInstances(IEnumerator moduleEnum, int depth, ModuleConfig parent = null)
 {
     bool result = true;
       while (moduleEnum.MoveNext())
       {
     ModuleConfig moduleConfig = moduleEnum.Current as ModuleConfig;
     if (moduleConfig != null)
     {
       if (moduleConfig.IsInstance())
       {
     moduleConfig.Parent = parent;
     moduleInstances[moduleConfig.UniqueId] = moduleConfig;
     result = LoadModules(moduleConfig, depth + 1) && result;
     result = LoadModule(moduleConfig) && result;
       }
       else
     moduleReferences[moduleConfig.UniqueId] = moduleConfig;
     }
       }
       return result;
 }
Ejemplo n.º 8
0
 protected virtual Boolean CreateInstance(ModuleConfig config)
 {
     TypeFabrication moduleType = typeFactory.Fabricate(config.Type);
       moduleType.BaseType = typeFactory.FindBaseType(moduleType);
       if (moduleType.FindBaseType() && moduleType.FindCreateType())
       {
     config.Instance = moduleType.Fabricate();
       }
       IEnumerator enumerator = config.PropertyConfigCollection.GetEnumerator();
       while (enumerator.MoveNext())
       {
     PropertyConfig propertyConfig = enumerator.Current as PropertyConfig;
     propertyReferences[propertyConfig.UniqueId] = propertyConfig;
     propertyConfig.Parent = config;
       }
       return config.Instance != null;
 }
Ejemplo n.º 9
0
 public virtual bool FromConfig(ModuleConfig config)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
Archivo: Job.cs Proyecto: bolke/Mod
 public override bool FromConfig(ModuleConfig config)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
        public virtual bool SetInstanceProperty(ModuleConfig propertyContent)
        {
            bool result = false;
              if ((Instance != null) && (propertyContent != null))
              {
            if (propertyContent.IsProperty())
            {
              Type instanceType = Instance.GetType();
              PropertyInfo[] properties = instanceType.GetProperties();
              for (int i = 0; i < properties.Length; i++)
              {
            PropertyInfo property = properties[i];
            if (property.Name.Equals(propertyContent["Property"]))
            {
              property.SetValue(Instance, propertyContent.Instance);
              result = true;
              break;
            }
              }
            }
            else
              return true;
              }

              return result;
        }