Esempio n. 1
0
        static void Main(string[] args)
        {
            IEnumerable <int> list = new List <int> {
                1, 2, 5, 6, 7, 6, 9, 2, 3, 0, 6, 2, 3, 8
            };

            foreach (var item in list)
            {
                Console.Write(item + "\t");
            }
            Console.WriteLine();

            IEnumerable <string> list2 = list.ExtensionSelect(x => x.ToString());

            foreach (var item in list2)
            {
                Console.Write(item + "\t");
            }
            Console.WriteLine();

            IEnumerable <int> list3 = list.ExtensionWhere(x => x > 4);

            foreach (var item in list3)
            {
                Console.Write(item + "\t");
            }
            Console.WriteLine();

            IEnumerable <int> list4 = LINQ.ExtensionWhere(list.ExtensionToList(), x => x > 5);

            foreach (var item in list4)
            {
                Console.Write(item + "\t");
            }
            Console.WriteLine();

            var list5 = list.ExtensionToDictionary(x => x.ToString()).ExtensionGroupBy(x => x.Key);

            foreach (var item in list5)
            {
                Console.Write("{" + item.Key + "\t");
            }
            Console.WriteLine();

            var list6 = list.ExtensionOrderByDescending(x => x);

            foreach (var item in list6)
            {
                Console.Write(item + "\t");
            }
            Console.WriteLine();

            Dictionary <string, int> dict = list.ExtensionToDictionary(x => x.ToString());

            foreach (var item in dict)
            {
                Console.Write("[" + item.Key + "\t" + item.Value + "]\t");
            }
            Console.WriteLine();
        }
Esempio n. 2
0
    public override bool TrySetMember(SetMemberBinder binder, object?value) => LINQ.TryDo(() =>
    {
        Type.InvokeMember(
            binder.Name,
            BindingFlags.SetProperty,
            Type.DefaultBinder,
            Unwrap(),
            new object[] { WrapIfRequired(value) }
            );

        return(true);
    }, false);
Esempio n. 3
0
    private void FindBooks()
    {
        if (spinbuttonDateFrom.ValueAsInt > spinbuttonDateTo.ValueAsInt ||
            spinbuttonPagesFrom.ValueAsInt > spinbuttonPagesTo.ValueAsInt)
        {
            MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal,
                                                     MessageType.Error, ButtonsType.Ok, "gddhfdh");
            dialog.Text = "Некоректно введені дата або кількість сторінок";
            dialog.Run();
            dialog.Destroy();
            return;
        }
        Book book = new Book
        {
            title     = comboboxTitle.ActiveText == null ? "" : comboboxTitle.ActiveText,
            author    = comboboxAuthor.ActiveText == null ? "" : comboboxAuthor.ActiveText,
            genre     = comboboxGenre.ActiveText == null ? "" : comboboxGenre.ActiveText,
            language  = comboboxLanguage.ActiveText == null ? "" : comboboxLanguage.ActiveText,
            dateFrom  = spinbuttonDateFrom.ValueAsInt,
            dateTo    = spinbuttonDateTo.ValueAsInt,
            pagesFrom = spinbuttonPagesFrom.ValueAsInt,
            pagesTo   = spinbuttonPagesTo.ValueAsInt
        };


        ISearchAlgoritm algoritm;

        if (radiobuttonDOM.Active)
        {
            algoritm = new DOM();
        }
        else if (radiobuttonSAX.Active)
        {
            algoritm = new SAX();
        }
        else
        {
            algoritm = new LINQ();
        }

        XmlDocument xDoc = algoritm.Search(book, lastxDoc);

        comboboxTitle.Model    = new ListStore(typeof(string), typeof(string));
        comboboxGenre.Model    = new ListStore(typeof(string), typeof(string));
        comboboxLanguage.Model = new ListStore(typeof(string), typeof(string));
        comboboxAuthor.Model   = new ListStore(typeof(string), typeof(string));
        OpenData(xDoc);
        lastxDoc = xDoc;
    }
Esempio n. 4
0
        private void LinqCommand(string action)
        {
            LINQ linq = new LINQ(zoo);

            switch (action)
            {
            case "1": linq.ShowAnimalsGroupByType(); break;

            case "2":
            {
                Console.Write("Enter animal state: ");
                linq.ShowAnimalByState(GetState(Console.ReadLine()));
                break;
            }

            case "3": linq.ShowAllSickTigers(); break;

            case "4":
            {
                Console.Write("Enter elephant name: ");
                linq.ShowElephantByName(Console.ReadLine());
                break;
            }

            case "5": linq.ShowAllNamesHungryAnimals(); break;

            case "6": linq.ShowMostHealthAnimalByType(); break;

            case "7": linq.ShowDeadAnimalCountByType(); break;

            case "8": linq.ShowWolfAndBearByHealth(); break;

            case "9": linq.ShowMinAndMaxHeathAnimal(); break;

            case "10": linq.ShowAverageAnimalHeath(); break;

            default: throw new InvalidCommandException();
            }
        }
Esempio n. 5
0
        private void DoSearch()
        {
            richTextBox1.Clear();
            Student BestStudent = GetBestStudentType();

            if (SaxButton.Checked)
            {
                IStrategy Strategy = new SAX(path);
                Info = Strategy.Search(BestStudent, path);
                Output(Info);
            }
            else if (DomButton.Checked)
            {
                IStrategy Strategy = new DOM(path);
                Info = Strategy.Search(BestStudent, path);
                Output(Info);
            }
            else if (LinqButton.Checked)
            {
                IStrategy Strategy = new LINQ(path);
                Info = Strategy.Search(BestStudent, path);
                Output(Info);
            }
        }
Esempio n. 6
0
        protected override void GetGui()
        {
            GUILayout.BeginVertical();

            bool enabled = GUI.enabled;

            if (this.Button("FB.Init"))
            {
                FB.Init(this.OnInitComplete, this.OnHideUnity);
                this.Status = "FB.Init() called with " + FB.AppId;
            }

            GUILayout.BeginHorizontal();

            GUI.enabled = enabled && FB.IsInitialized;
            if (this.Button("Login"))
            {
                this.CallFBLogin();
                this.Status = "Login called";
            }

            GUI.enabled = FB.IsLoggedIn;
            if (this.Button("Get publish_actions"))
            {
                this.CallFBLoginForPublish();
                this.Status = "Login (for publish_actions) called";
            }

            // Fix GUILayout margin issues
            GUILayout.Label(GUIContent.none, GUILayout.MinWidth(ConsoleBase.MarginFix));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();

            // Fix GUILayout margin issues
            GUILayout.Label(GUIContent.none, GUILayout.MinWidth(ConsoleBase.MarginFix));
            GUILayout.EndHorizontal();

            #if !UNITY_WEBGL
            if (this.Button("Logout"))
            {
                CallFBLogout();
                this.Status = "Logout called";
            }
            #endif

            GUI.enabled = enabled && FB.IsInitialized;
            if (this.Button("Share Dialog"))
            {
                this.SwitchMenu(typeof(DialogShare));
            }

            bool savedEnabled = GUI.enabled;
            GUI.enabled = enabled &&
                          AccessToken.CurrentAccessToken != null &&
                          LINQ.Contains(AccessToken.CurrentAccessToken.Permissions, "publish_actions");
            if (this.Button("Game Groups"))
            {
                this.SwitchMenu(typeof(GameGroups));
            }

            GUI.enabled = savedEnabled;

            if (this.Button("App Requests"))
            {
                this.SwitchMenu(typeof(AppRequests));
            }

            if (this.Button("Graph Request"))
            {
                this.SwitchMenu(typeof(GraphRequest));
            }

            if (Constants.IsWeb && this.Button("Pay"))
            {
                this.SwitchMenu(typeof(Pay));
            }

            if (this.Button("App Events"))
            {
                this.SwitchMenu(typeof(AppEvents));
            }

            if (this.Button("App Links"))
            {
                this.SwitchMenu(typeof(AppLinks));
            }

            if (Constants.IsMobile && this.Button("App Invites"))
            {
                this.SwitchMenu(typeof(AppInvites));
            }

            if (Constants.IsMobile && this.Button("Access Token"))
            {
                this.SwitchMenu(typeof(AccessTokenMenu));
            }

            GUILayout.EndVertical();

            GUI.enabled = enabled;
        }
Esempio n. 7
0
 public Channel getChannelByName(string name)
 {
     return(LINQ.FirstOrDefault(channels, channel => channel.getChannelName().Equals(name)));
 }
Esempio n. 8
0
        public static void CASES()
        {
            int x_choose;

            try
            {
                x_choose = Convert.ToInt32(Console.ReadLine());
                if (x_choose > 26 || x_choose < 1)
                {
                    Console.WriteLine("\t\t\tEntered number is out of scope!");
                    Console.WriteLine("\t\t\tPlease, reenter number!");
                    CASES();
                }
                else
                {
                    switch (x_choose)
                    {
                    case 1:     //Working with variables
                    {
                        Console.BackgroundColor = ConsoleColor.Green;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.WriteLine("1\t\t\t\tVARIABLE TYPES & LITERALS & CASTING and TYPE CONVERSIONS");
                        Console.WriteLine("1_1\tLITERALS");
                        Console.WriteLine("1_2\tVARIABLE TYPES");
                        Console.WriteLine("1_3\tCASTING & TYPE CONVERSIONS");
                        VARIABLES vars = new VARIABLES();
                        vars.VARIABLES_TYPES_CAST_M();
                        break;
                    }

                    case 2:     //Basic operations
                    {
                        Console.BackgroundColor = ConsoleColor.Yellow;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Black;
                        OPERATORS oper = new OPERATORS();
                        oper.OPERATIONS();
                        break;
                    }

                    case 3:     //Conditions (IF/ELSE, SWITCH/CASE)
                    {
                        Console.BackgroundColor = ConsoleColor.DarkGreen;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.White;
                        CONDITIONS cond = new CONDITIONS();
                        cond.CONDITIONS_M();
                        break;
                    }

                    case 4:     //Loops (FOR/WHILE/DO WHILE)
                    {
                        Console.BackgroundColor = ConsoleColor.Cyan;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        LOOPS loop_block = new LOOPS();
                        loop_block.LOOPS_M();
                        break;
                    }

                    case 5:     //ARRAYS
                    {
                        Console.BackgroundColor = ConsoleColor.DarkMagenta;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.White;
                        ARRAYS arr = new ARRAYS();
                        arr.ARRAYS_M();
                        break;
                    }

                    case 6:     //Multi-dimensional arrays
                    {
                        Console.BackgroundColor = ConsoleColor.DarkGray;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        MULTI_ARRAYS arr_m = new MULTI_ARRAYS();
                        arr_m.MULTI_ARRAYS_M();
                        break;
                    }

                    case 7:     //Lists - we don't know number of elements, uses more memory
                    {
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.White;
                        LISTS list = new LISTS();
                        list.LISTS_M();
                        break;
                    }

                    case 8:     //Strings
                    {
                        STRINGS str = new STRINGS();
                        str.STRINGS_M();
                        break;
                    }

                    case 9:     //Try & Catch
                    {
                        TRY_CATCH tr = new TRY_CATCH();
                        tr.TRY_CATCH_M();
                        break;
                    }

                    case 10:     //Object & Classes, Properties, GET/SETS (for private)
                    {
                        CLASSES_OBJECTS clas = new CLASSES_OBJECTS();
                        clas.CLASSES_OBJECTS_M();
                        break;
                    }

                    case 11:     //METHODS, FUNCTIONS,
                    {
                        METHODS_FUNCTIONS mth = new METHODS_FUNCTIONS();
                        mth.METHODS_FUNCTIONS_M();
                        break;
                    }

                    case 12:     //INHERITANCE, AS/IS, Virtual methods (From External Class file)
                    {
                        INHERITANCE_ASIS_VIRT inh = new INHERITANCE_ASIS_VIRT();
                        inh.INHERITANCE_ASIS_M();
                        break;
                    }

                    case 13:
                    {
                        MULTI_INHERITANCE m_inh = new MULTI_INHERITANCE();
                        m_inh.MULTI_INHERITANCE_M();
                        break;
                    }

                    case 14:
                    {
                        RELOAD_METHODS_OPERAT_TYPES reloading = new RELOAD_METHODS_OPERAT_TYPES();
                        reloading.RELOAD_METHODS_OPERAT_TYPES_M();
                        break;
                    }

                    case 15:
                    {
                        ENUMS enums = new ENUMS();
                        enums.ENUMS_M();
                        break;
                    }

                    case 16:
                    {
                        STRUCTURES str = new STRUCTURES();
                        str.STRUCTURES_M();
                        break;
                    }

                    case 17:
                    {
                        TUPLES tupl = new TUPLES();
                        tupl.TUPLES_M();
                        break;
                    }

                    case 18:
                    {
                        REFERENCES refer = new REFERENCES();
                        refer.REFERENCES_M();
                        break;
                    }

                    case 19:
                    {
                        SHADOWING_HIDING_METHODS shad = new SHADOWING_HIDING_METHODS();
                        shad.SHADOWING_HIDING_METHODS_M();
                        break;
                    }

                    case 20:
                    {
                        REGUL_EXP_IO reg = new REGUL_EXP_IO();
                        reg.REGUL_EXP_IO_M();
                        break;
                    }

                    case 21:
                    {
                        PREPROCESSOR_DIRECTIVES prep = new PREPROCESSOR_DIRECTIVES();
                        prep.PREPROCESSOR_DIRECTIVES_M();
                        break;
                    }

                    case 22:
                    {
                        NAMESPACES nam = new NAMESPACES();
                        nam.NAMESPACES_M();
                        break;
                    }

                    case 23:
                    {
                        NullableTypesExamples nullab = new NullableTypesExamples();
                        nullab.NULLABLES_M();
                        break;
                    }

                    case 24:
                    {
                        IDENTIFIERS iden = new IDENTIFIERS();
                        iden.IDENTIFIERS_M();
                        break;
                    }

                    case 25:
                    {
                        FILE_SYSTEM files = new FILE_SYSTEM();
                        files.FILE_SYSTEM_M();
                        break;
                    }

                    case 26:
                    {
                        LINQ link = new LINQ();
                        link.LINQ_M();
                        break;
                    }
                    }
                }
            }
            catch (Exception x)
            {
                Console.WriteLine("INFORMATIVE DESCRIPTION OF ERROR: \n " + x);
                CheckReturnToContent();
            }
        }