示例#1
0
        public void DeserializeItemsInList(string fileName, AllProductsFactory formEditorFactory)
        {
            StreamReader file         = new StreamReader(fileName, Encoding.Default);
            string       dataFromFile = file.ReadToEnd();

            file.Close();

            List <string> dataSeparated = dataFromFile.Split(separator).ToList();

            dataSeparated.RemoveAt(dataSeparated.Count - 1);

            while (dataSeparated.Count != 0)
            {
                try
                {
                    int classIndex = Convert.ToInt32(dataSeparated[classIndexPosition]);
                    dataSeparated.RemoveAt(classIndexPosition);
                    CosmeticProduct productToAdd = formEditorFactory.FactoryList[classIndex].GetSomeCosmeticProduct(classIndex);
                    productToAdd.DeserializeObject(dataSeparated);
                    CosmeticList.Add(productToAdd);
                }
                catch
                {
                    throw new Exception("Не удалось десериализовать!");
                }
            }
        }
示例#2
0
        public static void ProccessLoadingOfPlugins(string pluginPath, AllProductsFactory factoryFormEditor, ComboBox comboBoxToUse)
        {
            Assembly    assembly    = Assembly.LoadFrom(pluginPath);
            List <Type> pluginTypes = GetTypes <IPlugin>(assembly);

            if (pluginTypes.Count != 0)
            {
                int prevIndex = factoryFormEditor.FactoryList.Count();
                for (int i = 0; i < pluginTypes.Count; i++)
                {
                    IPlugin plugin = Activator.CreateInstance(pluginTypes[i]) as IPlugin;
                    factoryFormEditor.AddProduct(plugin.GetFormLoader());
                }

                for (int i = prevIndex; i < factoryFormEditor.FactoryList.Count; i++)
                {
                    comboBoxToUse.Items.Add(factoryFormEditor.FactoryList[i].GetClassName());
                }
            }
        }