예제 #1
0
        public void Initialize(bool force = false)
        {
            if (initialized && !force)
            {
                return;
            }

            try
            {
                var allNodes =
                    new List <Pair <ConfigNodeAttribute, Type> >(ReflectionUtils
                                                                 .FindAttribute <ConfigNodeAttribute>(false));

                foreach (Pair <ConfigNodeAttribute, Type> pair in allNodes)
                {
                    if (!pair.First.IsRoot)
                    {
                        continue;
                    }
                    var node = NodeReflection.GetReflection(pair.Second);
                    nodes.Add(node.Id,
                              new ReflectedConfig
                    {
                        Instance   = ReflectionUtils.FindInstance(pair.Second),
                        Reflection = node
                    });
                }

                FARLogger.TraceFormat("Config nodes found: {0}", string.Join(", ", nodes.Select(p => p.Key)));
            }
            finally
            {
                initialized = true;
            }
        }