示例#1
0
        static void Main(string[] args)
        {
            Incr incr = count => count + 2;

            Console.WriteLine("Use incr lambda Expression: ");
            int x = -10;

            while (x <= 0)
            {
                Console.WriteLine(x + " ");
                x = incr(x);
            }

            Console.WriteLine("\n");

            IsEven isEven = n => n % 2 == 0;

            Console.WriteLine("Use isEven lambda expression:");

            for (int i = 1; i <= 10; i++)
            {
                if (isEven(i))
                {
                    Console.WriteLine(i + " is even");
                }
            }
        }
示例#2
0
        static void Main()
        {
            // Создать делегат Incr, ссылающийся на лямбда-выражение.
            // увеличивающее свой параметр на 2.
            Incr incr = count => count + 2;

            // А теперь использовать лямбда-выражение incr.
            Console.WriteLine("Использование лямбда-выражения incr: ");
            int x = -10;

            while (x <= 0)
            {
                Console.Write(x + " ");
                x = incr(x); // увеличить значение x на 2
            }

            Console.WriteLine("\n");

            // Создать экземпляр делегата IsEven, ссылающийся на лямбда-выражение,
            // возвращающее логическое значение true, если его параметр имеет четное
            // значение, а иначе — логическое значение false.
            IsEven isEven = n => n % 2 == 0;

            // А теперь использовать лямбда-выражение isEven.
            Console.WriteLine("Использование лямбда - выражения isEven: ");
            for (int i = 1; i <= 10; i++)
            {
                if (isEven(i))
                {
                    Console.WriteLine(i + " четное.");
                }
            }
        }
示例#3
0
        private void BtnCheck_Click(object sender, EventArgs e)
        {
            try
            {
                // Retrieve user's input
                int num = Convert.ToInt32(txtInputNumber.Text);

                // Determine whether an int is even
                IsEven isEven = number => number % 2 == 0;

                // Determine whether an int is odd
                IsOdd isOdd = number => number % 2 == 1;

                if (isEven(num))
                {
                    lblTorF.Text = "Even.";
                }
                else
                {
                    lblTorF.Text = "Odd.";
                }
            }
            catch (Exception)
            {
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            int[]  arr  = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            int[]  arr1 = new int[arr.Length];
            int    j    = 0;
            IsEven even = (n) => {
                int s = n.Length;

                for (int i = 0; i < s; i++)
                {
                    if (n[i] % 2 == 0)
                    {
                        arr1[j++] = arr[i];
                    }
                }
            };

            even(arr);

            Console.WriteLine("Even Numbers");
            for (int i = 0; i < j; i++)
            {
                Console.WriteLine(arr1[i]);
            }

            Console.ReadLine();
        }
示例#5
0
        static void Main()
        {
            // Create an Incr delegate instance that refers to
            // a lambda expression that increases its parameter by 2.
            Incr incr = count => count + 2;

            //  Incr incr = (int count) => count + 2; // You can specify the type of count if you want
            // Now, use the incr lambda expression.
            Console.WriteLine("Use incr lambda expression: ");
            int x = -10;

            while (x <= 0)
            {
                Console.Write(x + " ");
                x = incr(x);     // increase x by 2
            }
            Console.WriteLine("\n");
            // Create an IsEven delegate instance that refers to
            // a lambda expression that returns true if its parameter
            // is even and false otherwise.
            IsEven isEven = n => n % 2 == 0;

            // Now, use the isEven lambda expression.
            Console.WriteLine("Use isEven lambda expression: ");
            for (int i = 1; i <= 10; i++)
            {
                if (isEven(i))
                {
                    Console.WriteLine(i + " is even.");
                }
            }
        }     // end Main
示例#6
0
        public void IsEvenShouldReturnCorrectResult()
        {
            var args   = FunctionsHelper.CreateArgs(4.123);
            var func   = new IsEven();
            var result = func.Execute(args, _context);

            Assert.IsTrue((bool)result.Result);
        }
示例#7
0
        public void IsEvenShouldPoundValueOnNonNumericInput()
        {
            var args   = FunctionsHelper.CreateArgs("Not odd");
            var func   = new IsEven();
            var result = func.Execute(args, _context);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
示例#8
0
        public void IsEvenWithInvalidArgumentReturnsPoundValue()
        {
            var func           = new IsEven();
            var parsingContext = ParsingContext.Create();
            var args           = FunctionsHelper.CreateArgs();
            var result         = func.Execute(args, parsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
示例#9
0
        public static void lambda()
        {
            Incr incr = (count, b) => count + b;

            Console.WriteLine(incr(-10, 5));

            IsEven ie = count => count % 2 == 0;


            Console.WriteLine(ie(2));
        }
示例#10
0
 static void Main(string[] args)
 {
   Increment Incr = count => count + 1;
   IsEven isEven = n => n % 2 == 0;
    Console.WriteLine("Use incr lambda expression:");
    int x = -10;
    while (x <= 0)
    {
        Console.Write(x + " ");
        bool result = isEven(x);
        Console.WriteLine(" is " + (result == true ? "even" : "odd"));
        x = Incr(x);
    }
示例#11
0
    public static void Main()
    {
        Sum    sum    = (x, y) => x + y + 1;
        IsEven iseven = (x) => x % 2 == 0;

        Console.WriteLine("sum 1 2: " + sum(1, 2));
        Console.WriteLine("is even 4: " + iseven(4));

//find all ony 'Ram' in following list

        ArrayList al = new ArrayList();

        al.Add("Ram");  al.Add("shyam");        al.Add("Ram");  al.Add("Ganesh");
    }
示例#12
0
        static void Main(string[] args)
        {
            var text = SomeText.LoremIpsum();

            text = text.Replace('a', 'A');
            Console.WriteLine(text);

            Console.WriteLine();

            text = SomeText.LoremIpsum();

            var reversedText = text.Reverse();

            Console.WriteLine(reversedText);

            var removedUseless = text.RemoveUseless();

            Console.WriteLine(removedUseless);

            CustomAlmonds();

            var number = 5;
            var result = number.IsEven();

            Console.WriteLine(result);

            IsEven function = delegate(int a) { return(a % 2 == 0); };

            function = (a) => { return(a % 2 == 0); };

            text = text.Replace(",", "").Replace(".", "");
            var words = text.Split(' ').ToList();

            words = words.Where(v => v.StartsWith('l') || v.StartsWith('L')).ToList();

            words = (from w in words where w.StartsWith('l') || w.StartsWith('L') select w).ToList();

            Console.WriteLine("----------------------------Lorem Ipsum words----------------------------");

            foreach (var word in words)
            {
                Console.WriteLine(word);
            }

            var loremCount = 0;

            loremCount = words.Count(v => v == "Lorem" || v == "lorem");
            Console.WriteLine($"Number of Lorem is {loremCount}");
        }
        static void Main(string[] args)
        {
            IsEven e = (num) =>
            {
                return(num % 2 == 0);
            };

            Console.WriteLine("Enter number : ");

            int no = int.Parse(Console.ReadLine());

            Console.WriteLine("IsEven : " + e(no));

            Console.ReadLine();
        }
示例#14
0
        static void Main(string[] args)
        {
            IsEven e1 = (number) =>
            {
                return(number % 2 == 0);
            };

            Console.WriteLine("Enter number : ");

            int temp = int.Parse(Console.ReadLine());

            Console.WriteLine("IsEvent : " + e1(temp));

            Console.ReadLine();
        }
示例#15
0
            public new static IsEven FromJsonToken(JToken token)
            {
                //IL_0001: Unknown result type (might be due to invalid IL or missing references)
                //IL_0007: Invalid comparison between Unknown and I4
                //IL_000f: Unknown result type (might be due to invalid IL or missing references)
                if ((int)token.get_Type() != 1)
                {
                    Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                    return(null);
                }
                JObject jsonObject = Extensions.Value <JObject>((IEnumerable <JToken>)token);
                IsEven  isEven     = new IsEven();

                isEven.PopulateFromJson(jsonObject);
                return(isEven);
            }
示例#16
0
        static void Main(string[] args)
        {
            //создать делегат Incr,ссылающийся на лямбда-выражение,увеличивающее свой параметр на 2
            Incr incr = count => count + 2;

            //Incr incr = (int count) => count + 2; альтернативный способ объявления делегата
            //использование лямбда-выражение incr
            Console.WriteLine("Использование лямбда-выражения incr: ");
            int x = -10;

            while (x <= 0)
            {
                Console.Write(x + " ");
                x = incr(x); //увеличить значение x на 2
            }
            Console.WriteLine();
            //создать экземпляр делегата IsEven,ссылающийся на лямбда-выражение,возвращающее результат типа bool
            IsEven isEven = n => n % 2 == 0;

            //использование лямбда-выражение isEven
            Console.WriteLine("Использование лямбда-выражения isEven: ");
            for (int i = 1; i <= 10; i++)
            {
                if (isEven(i))
                {
                    Console.WriteLine(i + " чётное");
                }
            }
            //создать экземпляр делегата InRange,ссылающийся на лямбда-выражение,возвращающее результат типа bool
            InRange rangeOK = (low, high, val) => val >= low && val <= high;

            //использование лямбда-выражение rangeOK
            if (rangeOK(1, 5, 3))
            {
                Console.WriteLine("Число 3 находится в пределах от 1 до 5");
            }
        }
示例#17
0
            static void Main()
            {
                Incr incr = count => count + 2;

                Console.WriteLine("Использование лямбда-выражения incr: ");
                int x = -10;

                while (x <= 0)
                {
                    Console.Write(x + " ");
                    x = incr(x);
                }
                Console.WriteLine("\n");
                IsEven isEven = n => n % 2 == 0;

                Console.WriteLine("Использование лямбда-выражения isEven: ");
                for (int i = 0; i <= 10; i++)
                {
                    if (isEven(i))
                    {
                        Console.WriteLine(i + " четное.");
                    }
                }
            }
示例#18
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["asin"]        = new Asin();
     Functions["asinh"]       = new Asinh();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countblank"]  = new CountBlank();
     Functions["countif"]     = new CountIf();
     Functions["countifs"]    = new CountIfs();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumifs"]      = new SumIfs();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["median"]      = new Median();
     Functions["min"]         = new Min();
     Functions["mina"]        = new Mina();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["averageifs"]  = new AverageIfs();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["rank"]        = new Rank();
     Functions["rank.eq"]     = new Rank();
     Functions["rank.avg"]    = new Rank(true);
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["atanh"]       = new Atanh();
     Functions["acos"]        = new Acos();
     Functions["acosh"]       = new Acosh();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     Functions["large"]       = new Large();
     Functions["small"]       = new Small();
     Functions["degrees"]     = new Degrees();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     // Logical
     Functions["if"]      = new If();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["pmt"] = new Pmt();
 }
示例#19
0
 public void Test1()
 {
     Assert.True(IsEven.check(2));
     Assert.False(IsEven.check(1));
 }
示例#20
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["rept"]        = new Rept();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["concat"]      = new Concat();
     Functions["textjoin"]    = new Textjoin();
     Functions["char"]        = new CharFunction();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["fixed"]       = new Fixed();
     Functions["proper"]      = new Proper();
     Functions["search"]      = new Search();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     Functions["hyperlink"]   = new Hyperlink();
     Functions["value"]       = new Value(CultureInfo.CurrentCulture);
     Functions["trim"]        = new Trim();
     Functions["clean"]       = new Clean();
     Functions["unicode"]     = new Unicode();
     Functions["unichar"]     = new Unichar();
     Functions["numbervalue"] = new NumberValue();
     Functions["dollar"]      = new Dollar();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["aggregate"]       = new Aggregate();
     Functions["abs"]             = new Abs();
     Functions["asin"]            = new Asin();
     Functions["asinh"]           = new Asinh();
     Functions["acot"]            = new Acot();
     Functions["acoth"]           = new Acoth();
     Functions["cos"]             = new Cos();
     Functions["cot"]             = new Cot();
     Functions["coth"]            = new Coth();
     Functions["cosh"]            = new Cosh();
     Functions["csc"]             = new Csc();
     Functions["csch"]            = new Csch();
     Functions["power"]           = new Power();
     Functions["gcd"]             = new Gcd();
     Functions["lcm"]             = new Lcm();
     Functions["sec"]             = new Sec();
     Functions["sech"]            = new SecH();
     Functions["sign"]            = new Sign();
     Functions["sqrt"]            = new Sqrt();
     Functions["sqrtpi"]          = new SqrtPi();
     Functions["pi"]              = new Pi();
     Functions["product"]         = new Product();
     Functions["ceiling"]         = new Ceiling();
     Functions["ceiling.precise"] = new CeilingPrecise();
     Functions["ceiling.math"]    = new CeilingMath();
     Functions["iso.ceiling"]     = new IsoCeiling();
     Functions["combin"]          = new Combin();
     Functions["combina"]         = new Combina();
     Functions["permut"]          = new Permut();
     Functions["permutationa"]    = new Permutationa();
     Functions["count"]           = new Count();
     Functions["counta"]          = new CountA();
     Functions["countblank"]      = new CountBlank();
     Functions["countif"]         = new CountIf();
     Functions["countifs"]        = new CountIfs();
     Functions["fact"]            = new Fact();
     Functions["factdouble"]      = new FactDouble();
     Functions["floor"]           = new Floor();
     Functions["floor.precise"]   = new FloorPrecise();
     Functions["floor.math"]      = new FloorMath();
     Functions["radians"]         = new Radians();
     Functions["roman"]           = new Roman();
     Functions["sin"]             = new Sin();
     Functions["sinh"]            = new Sinh();
     Functions["sum"]             = new Sum();
     Functions["sumif"]           = new SumIf();
     Functions["sumifs"]          = new SumIfs();
     Functions["sumproduct"]      = new SumProduct();
     Functions["sumsq"]           = new Sumsq();
     Functions["sumxmy2"]         = new Sumxmy2();
     Functions["sumx2my2"]        = new SumX2mY2();
     Functions["sumx2py2"]        = new SumX2pY2();
     Functions["seriessum"]       = new Seriessum();
     Functions["stdev"]           = new Stdev();
     Functions["stdeva"]          = new Stdeva();
     Functions["stdevp"]          = new StdevP();
     Functions["stdevpa"]         = new Stdevpa();
     Functions["stdev.s"]         = new StdevDotS();
     Functions["stdev.p"]         = new StdevDotP();
     Functions["subtotal"]        = new Subtotal();
     Functions["exp"]             = new Exp();
     Functions["log"]             = new Log();
     Functions["log10"]           = new Log10();
     Functions["ln"]              = new Ln();
     Functions["max"]             = new Max();
     Functions["maxa"]            = new Maxa();
     Functions["median"]          = new Median();
     Functions["min"]             = new Min();
     Functions["mina"]            = new Mina();
     Functions["mod"]             = new Mod();
     Functions["mode"]            = new Mode();
     Functions["mode.sngl"]       = new ModeSngl();
     Functions["mround"]          = new Mround();
     Functions["multinomial"]     = new Multinomial();
     Functions["average"]         = new Average();
     Functions["averagea"]        = new AverageA();
     Functions["averageif"]       = new AverageIf();
     Functions["averageifs"]      = new AverageIfs();
     Functions["round"]           = new Round();
     Functions["rounddown"]       = new Rounddown();
     Functions["roundup"]         = new Roundup();
     Functions["rand"]            = new Rand();
     Functions["randbetween"]     = new RandBetween();
     Functions["rank"]            = new Rank();
     Functions["rank.eq"]         = new RankEq();
     Functions["rank.avg"]        = new RankAvg();
     Functions["percentile"]      = new Percentile();
     Functions["percentile.inc"]  = new PercentileInc();
     Functions["percentile.exc"]  = new PercentileExc();
     Functions["quartile"]        = new Quartile();
     Functions["quartile.inc"]    = new QuartileInc();
     Functions["quartile.exc"]    = new QuartileExc();
     Functions["percentrank"]     = new Percentrank();
     Functions["percentrank.inc"] = new PercentrankInc();
     Functions["percentrank.exc"] = new PercentrankExc();
     Functions["quotient"]        = new Quotient();
     Functions["trunc"]           = new Trunc();
     Functions["tan"]             = new Tan();
     Functions["tanh"]            = new Tanh();
     Functions["atan"]            = new Atan();
     Functions["atan2"]           = new Atan2();
     Functions["atanh"]           = new Atanh();
     Functions["acos"]            = new Acos();
     Functions["acosh"]           = new Acosh();
     Functions["covar"]           = new Covar();
     Functions["covariance.p"]    = new CovarianceP();
     Functions["covariance.s"]    = new CovarianceS();
     Functions["var"]             = new Var();
     Functions["vara"]            = new Vara();
     Functions["var.s"]           = new VarDotS();
     Functions["varp"]            = new VarP();
     Functions["varpa"]           = new Varpa();
     Functions["var.p"]           = new VarDotP();
     Functions["large"]           = new Large();
     Functions["small"]           = new Small();
     Functions["degrees"]         = new Degrees();
     Functions["odd"]             = new Odd();
     Functions["even"]            = new Even();
     // Information
     Functions["isblank"]    = new IsBlank();
     Functions["isnumber"]   = new IsNumber();
     Functions["istext"]     = new IsText();
     Functions["isnontext"]  = new IsNonText();
     Functions["iserror"]    = new IsError();
     Functions["iserr"]      = new IsErr();
     Functions["error.type"] = new ErrorType();
     Functions["iseven"]     = new IsEven();
     Functions["isodd"]      = new IsOdd();
     Functions["islogical"]  = new IsLogical();
     Functions["isna"]       = new IsNa();
     Functions["na"]         = new Na();
     Functions["n"]          = new N();
     Functions["type"]       = new TypeFunction();
     // Logical
     Functions["if"]      = new If();
     Functions["ifs"]     = new Ifs();
     Functions["maxifs"]  = new MaxIfs();
     Functions["minifs"]  = new MinIfs();
     Functions["iferror"] = new IfError();
     Functions["ifna"]    = new IfNa();
     Functions["not"]     = new Not();
     Functions["and"]     = new And();
     Functions["or"]      = new Or();
     Functions["true"]    = new True();
     Functions["false"]   = new False();
     Functions["switch"]  = new Switch();
     Functions["xor"]     = new Xor();
     // Reference and lookup
     Functions["address"]  = new Address();
     Functions["hlookup"]  = new HLookup();
     Functions["vlookup"]  = new VLookup();
     Functions["lookup"]   = new Lookup();
     Functions["match"]    = new Match();
     Functions["row"]      = new Row();
     Functions["rows"]     = new Rows();
     Functions["column"]   = new Column();
     Functions["columns"]  = new Columns();
     Functions["choose"]   = new Choose();
     Functions["index"]    = new RefAndLookup.Index();
     Functions["indirect"] = new Indirect();
     Functions["offset"]   = new Offset();
     // Date
     Functions["date"]             = new Date();
     Functions["datedif"]          = new DateDif();
     Functions["today"]            = new Today();
     Functions["now"]              = new Now();
     Functions["day"]              = new Day();
     Functions["month"]            = new Month();
     Functions["year"]             = new Year();
     Functions["time"]             = new Time();
     Functions["hour"]             = new Hour();
     Functions["minute"]           = new Minute();
     Functions["second"]           = new Second();
     Functions["weeknum"]          = new Weeknum();
     Functions["weekday"]          = new Weekday();
     Functions["days"]             = new Days();
     Functions["days360"]          = new Days360();
     Functions["yearfrac"]         = new Yearfrac();
     Functions["edate"]            = new Edate();
     Functions["eomonth"]          = new Eomonth();
     Functions["isoweeknum"]       = new IsoWeekNum();
     Functions["workday"]          = new Workday();
     Functions["workday.intl"]     = new WorkdayIntl();
     Functions["networkdays"]      = new Networkdays();
     Functions["networkdays.intl"] = new NetworkdaysIntl();
     Functions["datevalue"]        = new DateValue();
     Functions["timevalue"]        = new TimeValue();
     // Database
     Functions["dget"]     = new Dget();
     Functions["dcount"]   = new Dcount();
     Functions["dcounta"]  = new DcountA();
     Functions["dmax"]     = new Dmax();
     Functions["dmin"]     = new Dmin();
     Functions["dsum"]     = new Dsum();
     Functions["daverage"] = new Daverage();
     Functions["dvar"]     = new Dvar();
     Functions["dvarp"]    = new Dvarp();
     //Finance
     Functions["cumipmt"]    = new Cumipmt();
     Functions["cumprinc"]   = new Cumprinc();
     Functions["dollarde"]   = new DollarDe();
     Functions["dollarfr"]   = new DollarFr();
     Functions["ddb"]        = new Ddb();
     Functions["effect"]     = new Effect();
     Functions["fvschedule"] = new FvSchedule();
     Functions["pduration"]  = new Pduration();
     Functions["rri"]        = new Rri();
     Functions["pmt"]        = new Pmt();
     Functions["ppmt"]       = new Ppmt();
     Functions["ipmt"]       = new Ipmt();
     Functions["ispmt"]      = new IsPmt();
     Functions["pv"]         = new Pv();
     Functions["fv"]         = new Fv();
     Functions["npv"]        = new Npv();
     Functions["rate"]       = new Rate();
     Functions["nper"]       = new Nper();
     Functions["nominal"]    = new Nominal();
     Functions["irr"]        = new Irr();
     Functions["mirr"]       = new Mirr();
     Functions["xirr"]       = new Xirr();
     Functions["sln"]        = new Sln();
     Functions["syd"]        = new Syd();
     Functions["xnpv"]       = new Xnpv();
     Functions["coupdays"]   = new Coupdays();
     Functions["coupdaysnc"] = new Coupdaysnc();
     Functions["coupdaybs"]  = new Coupdaybs();
     Functions["coupnum"]    = new Coupnum();
     Functions["coupncd"]    = new Coupncd();
     Functions["couppcd"]    = new Couppcd();
     Functions["price"]      = new Price();
     Functions["yield"]      = new Yield();
     Functions["yieldmat"]   = new Yieldmat();
     Functions["duration"]   = new Duration();
     Functions["disc"]       = new Disc();
     //Engineering
     Functions["bitand"]       = new BitAnd();
     Functions["bitor"]        = new BitOr();
     Functions["bitxor"]       = new BitXor();
     Functions["bitlshift"]    = new BitLshift();
     Functions["bitrshift"]    = new BitRshift();
     Functions["convert"]      = new ConvertFunction();
     Functions["bin2dec"]      = new Bin2Dec();
     Functions["bin2hex"]      = new Bin2Hex();
     Functions["bin2oct"]      = new Bin2Oct();
     Functions["dec2bin"]      = new Dec2Bin();
     Functions["dec2hex"]      = new Dec2Hex();
     Functions["dec2oct"]      = new Dec2Oct();
     Functions["hex2bin"]      = new Hex2Bin();
     Functions["hex2dec"]      = new Hex2Dec();
     Functions["hex2oct"]      = new Hex2Oct();
     Functions["oct2bin"]      = new Oct2Bin();
     Functions["oct2dec"]      = new Oct2Dec();
     Functions["oct2hex"]      = new Oct2Hex();
     Functions["delta"]        = new Delta();
     Functions["erf"]          = new Erf();
     Functions["erf.precise"]  = new ErfPrecise();
     Functions["erfc"]         = new Erfc();
     Functions["erfc.precise"] = new ErfcPrecise();
     Functions["besseli"]      = new BesselI();
     Functions["besselj"]      = new BesselJ();
     Functions["besselk"]      = new BesselK();
     Functions["bessely"]      = new BesselY();
 }
示例#21
0
        public static ValueFilter FromJsonToken(JToken token)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            //IL_0007: Invalid comparison between Unknown and I4
            //IL_000f: Unknown result type (might be due to invalid IL or missing references)
            if ((int)token.get_Type() != 1)
            {
                Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found"));
                return(null);
            }
            JObject val  = Extensions.Value <JObject>((IEnumerable <JToken>)token);
            JToken  val2 = default(JToken);

            if (!val.TryGetValue("type", ref val2))
            {
                Debug.LogWarning((object)"Malformed json: no 'type' property in object of class ValueFilter");
                return(null);
            }
            string      text = Extensions.Value <string>((IEnumerable <JToken>)val2);
            ValueFilter valueFilter;

            switch (text)
            {
            case "IsEven":
                valueFilter = new IsEven();
                break;

            case "IsOdd":
                valueFilter = new IsOdd();
                break;

            case "Between":
                valueFilter = new Between();
                break;

            case "EqualsTo":
                valueFilter = new EqualsTo();
                break;

            case "LowerThan":
                valueFilter = new LowerThan();
                break;

            case "GreaterThan":
                valueFilter = new GreaterThan();
                break;

            case "NotEqualsTo":
                valueFilter = new NotEqualsTo();
                break;

            case "LowerEqualThan":
                valueFilter = new LowerEqualThan();
                break;

            case "GreaterEqualThan":
                valueFilter = new GreaterEqualThan();
                break;

            default:
                Debug.LogWarning((object)("Unknown type: " + text));
                return(null);
            }
            valueFilter.PopulateFromJson(val);
            return(valueFilter);
        }
示例#22
0
            public static IsEven FromJsonProperty(JObject jsonObject, string propertyName, IsEven defaultValue = null)
            {
                //IL_0011: Unknown result type (might be due to invalid IL or missing references)
                //IL_0018: Invalid comparison between Unknown and I4
                JProperty val = jsonObject.Property(propertyName);

                if (val == null || (int)val.get_Value().get_Type() == 10)
                {
                    return(defaultValue);
                }
                return(FromJsonToken(val.get_Value()));
            }
示例#23
0
        static void Main(string[] args)
        {
            StringOperation strMod;
            string          str;

            strMod = ReplaceSpaces;
            str    = "This is a simple test.";
            strMod(ref str);
            Console.WriteLine("Result string: " + str);
            Console.WriteLine();

            strMod = RemoveSpaces;
            str    = "This is a simple test.";
            strMod(ref str);
            Console.WriteLine("Result string: " + str);
            Console.WriteLine();

            strMod = Reverse;
            str    = "This is a simple test.";
            strMod(ref str);
            Console.WriteLine("Result string: " + str);
            Console.WriteLine();

            strMod  = ReplaceSpaces;
            strMod += Reverse;
            str     = "This is a simple test.";
            strMod(ref str);
            Console.WriteLine("Result string: " + str);
            Console.WriteLine();

            strMod -= ReplaceSpaces;
            strMod += RemoveSpaces;
            str     = "This is a simple test.";
            strMod(ref str);
            Console.WriteLine("Result string: " + str);
            Console.WriteLine();

            int     result;
            Counter count = delegate(int end)
            {
                int sum = 0;

                for (int i = 0; i <= end; i++)
                {
                    Console.WriteLine(i);
                    sum += i;
                }

                return(sum);
            };

            result = count(3);
            Console.WriteLine("Sum 3 is equals " + result);
            Console.WriteLine();
            result = count(5);
            Console.WriteLine("Sum 5 is equals " + result);
            Console.WriteLine();

            Increment increment = count => count + 2;

            Console.WriteLine("Using of lambda expressions increment: ");
            int x = -10;

            while (x <= 0)
            {
                Console.Write(x + " ");
                x = increment(x);
            }
            Console.WriteLine();
            Console.WriteLine();

            IsEven isEven = n => n % 2 == 0;

            Console.WriteLine("Using of lambda expressions isEven: ");
            for (int i = 1; i <= 10; i++)
            {
                if (isEven(i))
                {
                    Console.WriteLine(i + " is even.");
                }
            }
            Console.WriteLine();


            IntOperation fact = n =>
            {
                int r = 1;
                for (int i = 1; i <= n; i++)
                {
                    r = i * r;
                }
                return(r);
            };

            Console.WriteLine("Factorial 3 is equals " + fact(3));
            Console.WriteLine("Factorial 5 is equals " + fact(5));
            Console.WriteLine();

            Event        evt         = new Event();
            EventHandler firstEvent  = (sender, args) => Console.WriteLine("First event has happend.");
            EventHandler secondEvent = (sender, args) => Console.WriteLine("Second event has happend.");
            EventHandler thirdEvent  = (sender, args) => Console.WriteLine("Third event has happend.");
            EventHandler fourthEvent = (sender, args) => Console.WriteLine("Fourth event has happend.");

            Console.WriteLine("Events adding.");
            evt.SomeEvent += firstEvent;
            evt.SomeEvent += secondEvent;
            evt.SomeEvent += thirdEvent;
            Console.WriteLine();

            Console.WriteLine("Try to add fourth event handler.");
            evt.SomeEvent += fourthEvent;
            evt.OnSomeEvent();
            Console.WriteLine();

            Console.WriteLine("Removing of first event handler.");
            evt.SomeEvent -= firstEvent;
            evt.OnSomeEvent();
            Console.WriteLine();

            Console.WriteLine("Try to remove first event handler again.");
            evt.SomeEvent -= firstEvent;
            evt.OnSomeEvent();
            Console.WriteLine();

            Console.WriteLine("Adding of fourth event handler.");
            evt.SomeEvent += fourthEvent;
            evt.OnSomeEvent();
        }
示例#24
0
 public BuiltInFunctions()
 {
     // Text
     Functions["len"]         = new Len();
     Functions["lower"]       = new Lower();
     Functions["upper"]       = new Upper();
     Functions["left"]        = new Left();
     Functions["right"]       = new Right();
     Functions["mid"]         = new Mid();
     Functions["replace"]     = new Replace();
     Functions["substitute"]  = new Substitute();
     Functions["concatenate"] = new Concatenate();
     Functions["exact"]       = new Exact();
     Functions["find"]        = new Find();
     Functions["proper"]      = new Proper();
     Functions["text"]        = new Text.Text();
     Functions["t"]           = new T();
     // Numbers
     Functions["int"] = new CInt();
     // Math
     Functions["abs"]         = new Abs();
     Functions["cos"]         = new Cos();
     Functions["cosh"]        = new Cosh();
     Functions["power"]       = new Power();
     Functions["sign"]        = new Sign();
     Functions["sqrt"]        = new Sqrt();
     Functions["sqrtpi"]      = new SqrtPi();
     Functions["pi"]          = new Pi();
     Functions["product"]     = new Product();
     Functions["ceiling"]     = new Ceiling();
     Functions["count"]       = new Count();
     Functions["counta"]      = new CountA();
     Functions["countif"]     = new CountIf();
     Functions["fact"]        = new Fact();
     Functions["floor"]       = new Floor();
     Functions["sin"]         = new Sin();
     Functions["sinh"]        = new Sinh();
     Functions["sum"]         = new Sum();
     Functions["sumif"]       = new SumIf();
     Functions["sumproduct"]  = new SumProduct();
     Functions["sumsq"]       = new Sumsq();
     Functions["stdev"]       = new Stdev();
     Functions["stdevp"]      = new StdevP();
     Functions["stdev.s"]     = new Stdev();
     Functions["stdev.p"]     = new StdevP();
     Functions["subtotal"]    = new Subtotal();
     Functions["exp"]         = new Exp();
     Functions["log"]         = new Log();
     Functions["log10"]       = new Log10();
     Functions["ln"]          = new Ln();
     Functions["max"]         = new Max();
     Functions["maxa"]        = new Maxa();
     Functions["min"]         = new Min();
     Functions["mod"]         = new Mod();
     Functions["average"]     = new Average();
     Functions["averagea"]    = new AverageA();
     Functions["averageif"]   = new AverageIf();
     Functions["round"]       = new Round();
     Functions["rounddown"]   = new Rounddown();
     Functions["roundup"]     = new Roundup();
     Functions["rand"]        = new Rand();
     Functions["randbetween"] = new RandBetween();
     Functions["quotient"]    = new Quotient();
     Functions["trunc"]       = new Trunc();
     Functions["tan"]         = new Tan();
     Functions["tanh"]        = new Tanh();
     Functions["atan"]        = new Atan();
     Functions["atan2"]       = new Atan2();
     Functions["var"]         = new Var();
     Functions["varp"]        = new VarP();
     // Information
     Functions["isblank"]   = new IsBlank();
     Functions["isnumber"]  = new IsNumber();
     Functions["istext"]    = new IsText();
     Functions["iserror"]   = new IsError();
     Functions["iserr"]     = new IsErr();
     Functions["iseven"]    = new IsEven();
     Functions["isodd"]     = new IsOdd();
     Functions["islogical"] = new IsLogical();
     Functions["isna"]      = new IsNa();
     Functions["na"]        = new Na();
     Functions["n"]         = new N();
     // Logical
     Functions["if"]   = new If();
     Functions["not"]  = new Not();
     Functions["and"]  = new And();
     Functions["or"]   = new Or();
     Functions["true"] = new True();
     // Reference and lookup
     Functions["address"] = new Address();
     Functions["hlookup"] = new HLookup();
     Functions["vlookup"] = new VLookup();
     Functions["lookup"]  = new Lookup();
     Functions["match"]   = new Match();
     Functions["row"]     = new Row();
     Functions["rows"]    = new Rows()
     {
         SkipArgumentEvaluation = true
     };
     Functions["column"]  = new Column();
     Functions["columns"] = new Columns()
     {
         SkipArgumentEvaluation = true
     };
     Functions["choose"]   = new Choose();
     Functions["index"]    = new Index();
     Functions["indirect"] = new Indirect();
     // Date
     Functions["date"]       = new Date();
     Functions["today"]      = new Today();
     Functions["now"]        = new Now();
     Functions["day"]        = new Day();
     Functions["month"]      = new Month();
     Functions["year"]       = new Year();
     Functions["time"]       = new Time();
     Functions["hour"]       = new Hour();
     Functions["minute"]     = new Minute();
     Functions["second"]     = new Second();
     Functions["weeknum"]    = new Weeknum();
     Functions["weekday"]    = new Weekday();
     Functions["days360"]    = new Days360();
     Functions["yearfrac"]   = new Yearfrac();
     Functions["edate"]      = new Edate();
     Functions["eomonth"]    = new Eomonth();
     Functions["isoweeknum"] = new IsoWeekNum();
     Functions["workday"]    = new Workday();
 }