private static void RegisterComponents(FileInfo file)
        {
            CompilerResults compilerResults = CompilingService.Compile(file.FullName, false);

            if (compilerResults.Errors.HasErrors)
            {
                ComponentRecord record = new ComponentRecord(Guid.Empty, ComponentType.Unknown, file.Name, "", file, null, compilerResults.Errors);
                StrategyComponentManager.components.Add(record);
                StrategyComponentManager.EmitComponentAdded(record);
                return;
            }
            bool flag = false;

            Type[] types = compilerResults.CompiledAssembly.GetTypes();
            for (int i = 0; i < types.Length; i++)
            {
                Type            type            = types[i];
                ComponentRecord componentRecord = StrategyComponentManager.CreateRecord(type, file);
                if (componentRecord != null)
                {
                    StrategyComponentManager.components.Add(componentRecord);
                    StrategyComponentManager.EmitComponentAdded(componentRecord);
                    flag = true;
                }
            }
            if (!flag)
            {
                ComponentRecord record2 = new ComponentRecord(Guid.Empty, ComponentType.Unknown, file.Name, "", file, null, new CompilerErrorCollection(new CompilerError[]
                {
                    new CompilerError(file.FullName, -1, -1, "-1", "No components found")
                }));
                StrategyComponentManager.components.Add(record2);
                StrategyComponentManager.EmitComponentAdded(record2);
            }
        }
        public static IComponentBase GetComponent(Guid guid, object issuer)
        {
            ComponentRecord componentRecord = StrategyComponentManager.components.FindRecord(guid);

            if (componentRecord == null)
            {
                return(null);
            }
            if (componentRecord.IsChanged)
            {
                StrategyComponentManager.componentCache.Remove(componentRecord);
                CompilerResults compilerResults = CompilingService.Compile(componentRecord.File.FullName, false);
                if (compilerResults.Errors.HasErrors)
                {
                    componentRecord.SetErrors(compilerResults.Errors);
                    return(null);
                }
                componentRecord.SetIsChanged(false);
                Type[] types = compilerResults.CompiledAssembly.GetTypes();
                for (int i = 0; i < types.Length; i++)
                {
                    Type            type             = types[i];
                    ComponentRecord componentRecord2 = StrategyComponentManager.CreateRecord(type, componentRecord.File);
                    if (componentRecord2 != null)
                    {
                        componentRecord.SetRuntimeType(componentRecord2.RuntimeType);
                        break;
                    }
                }
            }
            Hashtable hashtable = StrategyComponentManager.componentCache[componentRecord] as Hashtable;

            if (hashtable == null)
            {
                hashtable = new Hashtable();
                StrategyComponentManager.componentCache.Add(componentRecord, hashtable);
            }
            IComponentBase componentBase = hashtable[issuer] as IComponentBase;

            if (componentBase == null)
            {
                ComponentRecord componentRecord3 = StrategyComponentManager.components.FindRecord(guid);
                componentBase             = (Activator.CreateInstance(componentRecord3.RuntimeType) as IComponentBase);
                componentBase.Name        = componentRecord3.Name;
                componentBase.Description = componentRecord3.Description;
                hashtable.Add(issuer, componentBase);
            }
            return(componentBase);
        }
        private static void RegisterAllComponents(FileInfo[] files)
        {
            string text = "";
            Dictionary <string, FileInfo> dictionary = new Dictionary <string, FileInfo>();
            List <FileInfo> list  = new List <FileInfo>();
            List <FileInfo> list2 = new List <FileInfo>();
            int             num   = 1;

            for (int i = 0; i < files.Length; i++)
            {
                FileInfo fileInfo = files[i];
                if (StrategyComponentManager.builtComponents.Contains(fileInfo.Name))
                {
                    StreamReader streamReader = new StreamReader(fileInfo.FullName);
                    string       text2        = "__" + num;
                    dictionary[text2] = fileInfo;
                    list.Add(fileInfo);
                    string text3 = text;
                    text = string.Concat(new string[]
                    {
                        text3,
                        "namespace ",
                        text2,
                        Environment.NewLine,
                        "{",
                        Environment.NewLine
                    });
                    text += streamReader.ReadToEnd();
                    text  = text + Environment.NewLine + "}" + Environment.NewLine;
                    num++;
                    streamReader.Close();
                }
                else
                {
                    list2.Add(fileInfo);
                }
            }
            CompilerResults compilerResults = CompilingService.CompileSource(text);

            if (compilerResults.Errors.HasErrors)
            {
                for (int j = 0; j < files.Length; j++)
                {
                    FileInfo file = files[j];
                    StrategyComponentManager.RegisterComponents(file);
                }
                return;
            }
            Type[] types = compilerResults.CompiledAssembly.GetTypes();
            for (int k = 0; k < types.Length; k++)
            {
                Type type = types[k];
                if (type.IsPublic)
                {
                    string   key       = type.FullName.Substring(0, type.FullName.IndexOf("."));
                    FileInfo fileInfo2 = dictionary[key];
                    list.Remove(fileInfo2);
                    ComponentRecord componentRecord = StrategyComponentManager.CreateRecord(type, fileInfo2);
                    if (componentRecord != null)
                    {
                        StrategyComponentManager.components.Add(componentRecord);
                        StrategyComponentManager.EmitComponentAdded(componentRecord);
                    }
                }
            }
            foreach (FileInfo current in list)
            {
                ComponentRecord record = new ComponentRecord(Guid.Empty, ComponentType.Unknown, current.Name, "", current, null, new CompilerErrorCollection(new CompilerError[]
                {
                    new CompilerError(current.FullName, -1, -1, "-1", "No components found")
                }));
                StrategyComponentManager.components.Add(record);
                StrategyComponentManager.EmitComponentAdded(record);
            }
            foreach (FileInfo current2 in list2)
            {
                StrategyComponentManager.RegisterComponents(current2);
            }
        }
        public static void RegisterDefaultComponent(Type runtimeType)
        {
            ComponentRecord record = StrategyComponentManager.CreateRecord(runtimeType, null);

            StrategyComponentManager.components.Add(record);
        }
        public static bool RebuildComponent(FileInfo file)
        {
            ComponentRecord[] array  = StrategyComponentManager.components.FindRecords(file);
            ComponentRecord[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ComponentRecord componentRecord = array2[i];
                componentRecord.SetErrors(new CompilerErrorCollection());
                StrategyComponentManager.componentCache.Remove(componentRecord);
            }
            CompilerResults compilerResults = CompilingService.Compile(file.FullName, false);

            if (compilerResults.Errors.HasErrors)
            {
                ComponentRecord[] array3 = array;
                for (int j = 0; j < array3.Length; j++)
                {
                    ComponentRecord componentRecord2 = array3[j];
                    componentRecord2.SetErrors(compilerResults.Errors);
                    StrategyComponentManager.EmitComponentReconstructed(componentRecord2);
                }
                return(false);
            }
            ArrayList arrayList = new ArrayList();

            Type[] types = compilerResults.CompiledAssembly.GetTypes();
            for (int k = 0; k < types.Length; k++)
            {
                Type            type             = types[k];
                ComponentRecord componentRecord3 = StrategyComponentManager.CreateRecord(type, file);
                if (componentRecord3 != null)
                {
                    arrayList.Add(componentRecord3);
                }
            }
            ArrayList arrayList2 = new ArrayList(array);

            foreach (ComponentRecord componentRecord4 in arrayList)
            {
                bool flag = false;
                foreach (ComponentRecord componentRecord5 in arrayList2)
                {
                    if (componentRecord5.GUID == componentRecord4.GUID)
                    {
                        componentRecord5.SetName(componentRecord4.Name);
                        componentRecord5.SetDescription(componentRecord4.Description);
                        componentRecord5.SetComponentType(componentRecord4.ComponentType);
                        componentRecord5.SetRuntimeType(componentRecord4.RuntimeType);
                        componentRecord5.SetIsChanged(false);
                        flag = true;
                        arrayList2.Remove(componentRecord5);
                        StrategyComponentManager.EmitComponentReconstructed(componentRecord5);
                        break;
                    }
                }
                if (!flag)
                {
                    StrategyComponentManager.components.Add(componentRecord4);
                    StrategyComponentManager.EmitComponentAdded(componentRecord4);
                }
            }
            foreach (ComponentRecord componentRecord6 in arrayList2)
            {
                if (componentRecord6.GUID == Guid.Empty)
                {
                    StrategyComponentManager.components.Remove(componentRecord6);
                    StrategyComponentManager.EmitComponentRemoved(componentRecord6);
                }
            }
            return(true);
        }