Ejemplo n.º 1
0
        public static void AddFunction(string category, Function function)
        {
            FunctionCategory cat = GetCategory(category);

            if (cat != null)
            {
                cat.Functions.Add(function.FunctionName);
                AllCategories[0].Functions.Add(function.FunctionName);
                AllFunctions.Add(function);
            }
        }
Ejemplo n.º 2
0
        public static void Save()
        {
            DataSafe ds = new Data.DataSafe(Data.Paths.SettingsPath, "Functions");

            ds.Ints["Categories"] = AllCategories.Count - 1;
            for (int i = 1; i < AllCategories.Count; ++i)
            {
                FunctionCategory category = AllCategories[i];
                ds.Strings["Category-" + (i - 1)] = category.Title.ToUpper();
                DataSafe catSafe = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, "Category-" + category.Title);
                catSafe.Ints["Functions"] = category.Functions.Count;
                for (int f = 0; f < category.Functions.Count; ++f)
                {
                    catSafe.Strings["Function-" + f] = category.Functions[f].ToUpper();
                    GetFunction(category.Functions[f]).Save();
                }
            }
        }
Ejemplo n.º 3
0
        public static void Load()
        {
            if (!Loaded)
            {
                AllCategories.Clear();
                AllFunctions.Clear();

                FunctionCategory AllCat = new FunctionCategory("All Functions");
                //AllCategories.Add(AllCat);

                //1) Lade alle Kategorien!
                DataSafe ds       = new Data.DataSafe(Data.Paths.SettingsPath, "Functions");
                int      catCount = ds.Ints["Categories", 0];
                for (int i = 0; i < catCount; ++i)
                {
                    string name = ds.Strings["Category-" + i, ""];

                    /*if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
                     * {
                     *  throw new Exception("Error in Function Categories -> Functions.xml");
                     * }*/

                    FunctionCategory category = new FunctionCategory(name);


                    DataSafe catSafe  = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, "Category-" + name);
                    int      funCount = catSafe.Ints["Functions", 0];
                    for (int f = 0; f < funCount; ++f)
                    {
                        string funName = catSafe.Strings["Function-" + f, ""];
                        AllCat.Functions.Add(funName);
                        category.Functions.Add(funName);

                        //Lade eine Funktion
                        AllFunctions.Add(Function.Load(funName));
                    }

                    category.Sort();
                    AllCategories.Add(category);
                }

                //AllFunctions.Sort();
                AllCat.Sort();

                AllCategories.Sort();
                AllCategories.Insert(0, AllCat);



                /*
                 * string code = "$RETURN = 1;if( $i > 1 ){ $RETURN = FAK($i - 1) * $i; }";
                 * Function fak = new Function("FAK", code, typeof(int));
                 * fak.AddParameterInt("I");
                 * AllFunctions.Add(fak);
                 */
                Loaded = true;
            }
            else
            {
                Console.WriteLine("All Functions have been loaded before!");
            }
        }
Ejemplo n.º 4
0
 public static void AddCategory(FunctionCategory fc)
 {
     AllCategories.Add(fc);
 }
Ejemplo n.º 5
0
        public int CompareTo(object obj)
        {
            FunctionCategory f = obj as FunctionCategory;

            return(String.Compare(this.Title, f.Title));
        }
Ejemplo n.º 6
0
        public static void Load()
        {
            if (!Loaded)
            {
                AllCategories.Clear();
                AllFunctions.Clear();

                FunctionCategory AllCat = new FunctionCategory("All Functions");
                //AllCategories.Add(AllCat);

                //1) Lade alle Kategorien!
                DataSafe ds = new Data.DataSafe(Data.Paths.SettingsPath, "Functions");
                int catCount = ds.Ints["Categories", 0];
                for (int i = 0; i < catCount; ++i)
                {
                    string name = ds.Strings["Category-" + i, ""];
                    /*if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
                    {
                        throw new Exception("Error in Function Categories -> Functions.xml");
                    }*/

                    FunctionCategory category = new FunctionCategory(name );

                    DataSafe catSafe = new DataSafe(Data.Paths.SettingsScriptFunctionsPath, "Category-" + name);
                    int funCount = catSafe.Ints["Functions", 0];
                    for (int f = 0; f < funCount; ++f)
                    {
                        string funName = catSafe.Strings["Function-" + f, ""];
                        AllCat.Functions.Add(funName);
                        category.Functions.Add(funName);

                        //Lade eine Funktion
                        AllFunctions.Add( Function.Load(funName) );

                    }

                    category.Sort();
                    AllCategories.Add(category);
                }

                //AllFunctions.Sort();
                AllCat.Sort();

                AllCategories.Sort();
                AllCategories.Insert(0,AllCat);

                /*
                string code = "$RETURN = 1;if( $i > 1 ){ $RETURN = FAK($i - 1) * $i; }";
                Function fak = new Function("FAK", code, typeof(int));
                fak.AddParameterInt("I");
                AllFunctions.Add(fak);
                */
                Loaded = true;
            }
            else
            {
                Console.WriteLine("All Functions have been loaded before!");
            }
        }
Ejemplo n.º 7
0
 public static void AddCategory(FunctionCategory fc)
 {
     AllCategories.Add(fc);
 }