Inheritance: IComparer
Exemple #1
0
        public bool Equals(Node x, Node y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            if (IncludeName && !NameComparer.Equals(x.Name, y.Name))
            {
                return(false);
            }

            if (IncludeUserData && !UserDataComparer.Equals(x.UserData, y.UserData))
            {
                return(false);
            }

            if (IncludeInDegree && x.InDegree != y.InDegree)
            {
                return(false);
            }

            if (IncludeOutDegree && x.OutDegree != y.OutDegree)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        private bool EndpointEquals(Edge x, Edge y)
        {
            if (IgnoreDirection)
            {
                if (NameComparer.Equals(x.Source.Name, y.Source.Name))
                {
                    return(NameComparer.Equals(x.Target.Name, y.Target.Name));
                }
                else
                {
                    return(NameComparer.Equals(x.Source.Name, y.Target.Name) &&
                           NameComparer.Equals(x.Target.Name, y.Source.Name));
                }
            }

            if (!NameComparer.Equals(x.Source.Name, y.Source.Name))
            {
                return(false);
            }

            if (!NameComparer.Equals(x.Target.Name, y.Target.Name))
            {
                return(false);
            }

            return(true);
        }
Exemple #3
0
        private void CustomSort(DataGrid dataGrid, DataGridColumn column, ListSortDirection listSortDirection)
        {
            IComparer comparer;

            if (column.Header.Equals("Name"))
            {
                comparer = new NameComparer(listSortDirection);
            }
            else if (column.Header.Equals("Size"))
            {
                comparer = new SizeComparer(listSortDirection);
            }
            else
            {
                comparer = new ModifiedComparer(listSortDirection);
            }
            column.SortDirection = listSortDirection;
            ListCollectionView collectionview = CollectionViewSource
                                                .GetDefaultView(dataGrid.ItemsSource) as ListCollectionView;

            if (collectionview != null)
            {
                collectionview.CustomSort = comparer;
            }
            else
            {
                return;
            }
        }
Exemple #4
0
 private bool AreParametersEqual(ParameterSymbol parameter, ParameterSymbol other)
 {
     Debug.Assert(parameter.Ordinal == other.Ordinal);
     return(NameComparer.Equals(parameter.Name, other.Name) &&
            (parameter.RefKind == other.RefKind) &&
            this.comparer.Equals(parameter.Type, other.Type));
 }
Exemple #5
0
        private static bool Compare(string lhs, string rhs, NameComparer nameComparer)
        {
            if (string.IsNullOrEmpty(lhs) || string.IsNullOrEmpty(rhs))
            {
                return(true);
            }

            switch (nameComparer)
            {
            case NameComparer.Contains:
                return(lhs.IndexOf(rhs, StringComparison.OrdinalIgnoreCase) >= 0);

            case NameComparer.StartsWith:
                return(lhs.StartsWith(rhs, StringComparison.OrdinalIgnoreCase));

            case NameComparer.EndsWith:
                return(lhs.EndsWith(rhs, StringComparison.OrdinalIgnoreCase));

            case NameComparer.Exact:
                return(string.Equals(lhs, rhs, StringComparison.OrdinalIgnoreCase));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #6
0
        private bool IsMatch(IXmlIdentity xmlIdentity)
        {
            var name = xmlIdentity.Name;

            return(NameComparer.Equals(rootLocalName, name.LocalName) &&
                   (rootNamespaceUri == null || NameComparer.Equals(rootNamespaceUri, name.NamespaceUri)));
        }
Exemple #7
0
        public bool TryGet(Type key, out TypeName value)
        {
            var keyFullName = key.FullName;
            var node        = First;

            while (node != null)
            {
                var comp = NameComparer.Compare(GetName(node.Item), keyFullName);
                if (comp < 0)
                {
                    node = node.Next;
                    continue;
                }
                else if (comp == 0)
                {
                    value = node.Item;
                    return(true);
                }
                else
                {
                    break;
                }
            }
            value = default(TypeName);
            return(false);
        }
Exemple #8
0
        public bool TryGet(string key, out INamespaceName value)
        {
            var node = First;

            while (node != null)
            {
                var comp = NameComparer.Compare(GetName(node.Item), key);
                if (comp < 0)
                {
                    node = node.Next;
                    continue;
                }
                else if (comp == 0)
                {
                    value = node.Item;
                    return(true);
                }
                else
                {
                    break;
                }
            }
            value = default(INamespaceName);
            return(false);
        }
Exemple #9
0
 private void BtnSort_Click(object sender, EventArgs e)
 {
     try
     {
         sortChoice = boxSortChoice.Text;
         if (sortChoice.Equals("Type"))
         {
             TypeComparer typeComparer = new TypeComparer();
             items.Sort(typeComparer);
             MessageBox.Show("Sorted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearShow();
         }
         else
         {
             NameComparer nameComparer = new NameComparer();
             items.Sort(nameComparer);
             MessageBox.Show("Sorted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearShow();
         }
         MessageBox.Show("Sorted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private IEnumerable <KeyValuePair <string, ICfgNode> > scanInclude(IConfigNodeProvider source, Context context)
        {
            foreach (var pair in source.Items)
            {
                var configName = pair.Key;

                if (NameComparer.Equals(configName, AppSettingExtensions.IdentitySectionName))
                {
                    continue;
                }

                var configNode = _cfgNodeConverter(configName, pair.Value);
                if (configNode == null)
                {
                    continue;
                }

                List <Include> hadlers;
                if (!_includeHandlers.TryGetValue(configName, out hadlers))
                {
                    yield return(new KeyValuePair <string, ICfgNode>(configName, configNode));

                    continue;
                }

                var includeSettings = hadlers
                                      .Select(_ => _(source, context.Deserializer, configNode, context.SearchPath))
                                      .FirstOrDefault(_ => _ != null);

                if (includeSettings == null)
                {
                    throw new NotSupportedException("any registered handlers returned null");
                }

                var includeSettingsArray = includeSettings.ToArray();
                var includeRequired      = context.Deserializer.Deserialize <RequiredContainConfig>(configNode).Required;

                if (includeRequired && includeSettingsArray.Length == 0)
                {
                    throw new ApplicationException(string.Format("include setting from section '{0}' not found", configName));
                }

                foreach (var cnProvider in includeSettingsArray)
                {
                    if (context.CheckLoaded(cnProvider))
                    {
                        continue;
                    }

                    onLoaded(cnProvider);
                    context.Sources.Add(cnProvider);

                    foreach (var includePair in scanInclude(cnProvider, context))
                    {
                        yield return(includePair);
                    }
                }
            }
        }
        public void Equal_When_All_Fields_Are_Equal()
        {
            var x = CreateName();
            var y = CreateName();

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsTrue(result);
        }
        public void Not_Equal_When_NmNm40_Is_Different()
        {
            var x = CreateName();
            var y = CreateName();
            y.NmNm40 = "E";

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsFalse(result);
        }
        public void Not_Equal_When_MutKod_Is_Different()
        {
            var x = CreateName();
            var y = CreateName();
            y.MutKod = MutKod.RecordUpdated;

            var comparer = new NameComparer();
            bool result = comparer.Equals(x, y);

            Assert.IsFalse(result);
        }
            private static int CompareProperty(IComicCollection x, IComicCollection y)
            {
                var result = -x.Comics.Count.CompareTo(y.Comics.Count);

                if (result != 0)
                {
                    return(result);
                }

                return(NameComparer.CompareProperty(x, y));
            }
        public ICfgNode CfgNodeConverter(string name, ICfgNode candidate)
        {
            if (!NameComparer.Equals(name, "variable"))
            {
                return(new CfgNodeWrapper(candidate, this));
            }

            var varConfig = DefaultDeserializer.Instance.Deserialize <VariableConfig>(candidate);

            this[varConfig.Name] = varConfig.Value;
            return(null);
        }
Exemple #16
0
        private bool IsMatchOnNamespaceUri(IXmlIdentity xmlIdentity)
        {
            var otherNamespaceUri = xmlIdentity.Name.NamespaceUri;

            if (Context.IsReservedNamespaceUri(otherNamespaceUri))
            {
                return(NameComparer.Equals(namespaceUri, otherNamespaceUri));
            }
            return(namespaceUri == null ||
                   ShouldIgnoreAttributeNamespaceUri(xmlIdentity) ||
                   NameComparer.Equals(namespaceUri, otherNamespaceUri));
        }
Exemple #17
0
        public static void Main(string[] args)
        {
            List <City> cities = CityDataImporter.LoadData();

            // TODO Swap out comparers as desired

            // 1.To sort the list by CITY
            Console.WriteLine();
            Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("** THE LIST ALPHABETICALLY SORTED BY CITY **");
            IComparer <City> comparer = new NameComparer();

            cities.Sort(comparer);

            PrintCities(cities);


            // 2.To sort the list by STATE
            Console.WriteLine();
            Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("** THE LIST ALPHABETICALLY SORTED BY STATE **");

            IComparer <City> scomparer = new StateComparer();

            cities.Sort(scomparer);

            PrintCities(cities);


            // 3.To sort the list by POPULATION largest to smallest
            Console.WriteLine();
            Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("** THE LIST SORTED BY POPULATION-LARGEST TO SMALLEST **");

            IComparer <City> pcomparer = new PopulationComparer();

            cities.Sort(pcomparer);
            cities.Reverse();
            PrintCities(cities);

            //BONUS MISSION- TO SORT FIRST BY STATE AND THEN BY POPULATION

            Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
            Console.WriteLine("** THE LIST SORTED BY STATE AND THEN BY POPULATION **");
            CompoundComparer ccomparer = new CompoundComparer();

            ccomparer.Comparers.Add(new StateComparer());
            ccomparer.Comparers.Add(new PopulationComparer());
            cities.Sort(ccomparer);
            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #18
0
        public static void Main(string[] args)
        {
            List <City> cities = CityDataImporter.LoadData();

            // TODO Swap out comparers as desired: Area  State  Population  Name
            IComparer <City> comparer = new NameComparer();

            cities.Sort(comparer);

            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #19
0
 private bool AreTypeParametersEqual(TypeParameterSymbol type, TypeParameterSymbol other)
 {
     Debug.Assert(type.Ordinal == other.Ordinal);
     Debug.Assert(NameComparer.Equals(type.Name, other.Name));
     // Comparing constraints is unnecessary: two methods cannot differ by
     // constraints alone and changing the signature of a method is a rude
     // edit. Furthermore, comparing constraint types might lead to a cycle.
     Debug.Assert(type.HasConstructorConstraint == other.HasConstructorConstraint);
     Debug.Assert(type.HasValueTypeConstraint == other.HasValueTypeConstraint);
     Debug.Assert(type.HasReferenceTypeConstraint == other.HasReferenceTypeConstraint);
     Debug.Assert(type.ConstraintTypesNoUseSiteDiagnostics.Length == other.ConstraintTypesNoUseSiteDiagnostics.Length);
     return(true);
 }
Exemple #20
0
            private bool AreMethodsEqual(MethodSymbol method, MethodSymbol other)
            {
                Debug.Assert(NameComparer.Equals(method.Name, other.Name));

                Debug.Assert(method.IsDefinition);
                Debug.Assert(other.IsDefinition);

                method = SubstituteTypeParameters(method);
                other  = SubstituteTypeParameters(other);

                return(this.comparer.Equals(method.ReturnType, other.ReturnType) &&
                       method.Parameters.SequenceEqual(other.Parameters, AreParametersEqual) &&
                       method.TypeArguments.SequenceEqual(other.TypeArguments, AreTypesEqual));
            }
            public bool Equals(BytesKey other)
            {
                if (other == null)
                {
                    return(false);
                }

                if (this == other)
                {
                    return(true);
                }

                return(NameComparer.Equals(this.UniqueName, other.UniqueName));
            }
Exemple #22
0
        public static void Main(string[] args)
        {
            List <City> cities = CityDataImporter.LoadData();

            // TODO Swap out comparers as desired
            IComparer <City> comparer = new NameComparer();

            cities.Sort(comparer);

            PrintCities(cities);

            Console.ReadLine();


            IComparer <City> comparerState = new StateComparer();

            cities.Sort(comparerState);

            PrintCities(cities);

            Console.ReadLine();

            IComparer <City> comparerArea = new AreaComparer();

            cities.Sort(comparerArea);

            PrintCities(cities);

            Console.ReadLine();

            IComparer <City> comparerPopulation = new PopulationComparer();

            cities.Sort(comparerPopulation);

            PrintCities(cities);

            Console.ReadLine();

            CompoundComparer comparerCompound = new CompoundComparer();


            comparerCompound.Comparers.Add(new StateComparer());
            //cities.Sort(comparerCompound);
            comparerCompound.Comparers.Add(new PopulationComparer());
            //cities.Sort(comparerCompound);
            cities.Sort(comparerCompound);
            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #23
0
            public int GetHashCode(IXmlIdentity name)
            {
                var code = NameComparer.GetHashCode(name.Name.LocalName);

                if (name.XsiType != XmlName.Empty)
                {
                    code = (code << 7 | code >> 25) ^ XsiTypeComparer.GetHashCode(name.XsiType);
                }

                // DO NOT include NamespaceUri in hash code.
                // That would break 'null means any' behavior.

                return(code);
            }
Exemple #24
0
        static ColorComparer()
        {
            dc = new DistanceComparer();

            nc = new NameComparer();

            sc = new SaturationComparer();

            hc = new HueComparer();

            bc = new BrightnessComparer();

            uc = new UnsortedComparer();
        }
Exemple #25
0
        public static Addin[] GetAllAddins(this AddinRegistry registry, Func <Addin, string> sortItemSelector = null)
        {
            if (sortItemSelector == null)
            {
                sortItemSelector = x => x.Id;
            }

            var array = registry.GetModules(AddinSearchFlags.IncludeAll | AddinSearchFlags.LatestVersionsOnly);

            var comparer = new NameComparer(sortItemSelector);

            Array.Sort(array, comparer);

            return(array);
        }
Exemple #26
0
        public bool Equals(Node x, Node y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
            {
                return(false);
            }

            if (IncludeName && !NameComparer.Equals(x.Name, y.Name))
            {
                return(false);
            }

            if (IncludeUserData)
            {
                if (x.UserData.Count != y.UserData.Count)
                {
                    return(false);
                }

                foreach (var entry in x.UserData)
                {
                    if (!y.UserData.TryGetValue(entry.Key, out var value) || !Equals(entry.Value, value))
                    {
                        return(false);
                    }
                }
            }

            if (IncludeInDegree && x.InDegree != y.InDegree)
            {
                return(false);
            }

            if (IncludeOutDegree && x.OutDegree != y.OutDegree)
            {
                return(false);
            }

            return(true);
        }
Exemple #27
0
        public static void Main(string[] args)
        {
            List <City> cities = CityDataImporter.LoadData();

            // TODO Swap out comparers as desired
            IComparer <City> comparer  = new NameComparer();
            IComparer <City> statecomp = new StateComparer();
            IComparer <City> popcomp   = new PopulationComparer();
            IComparer <City> areacomp  = new AreaComparer();

            //cities.Sort(comparer);
            //cities.Sort(statecomp);
            //cities.Sort(popcomp);
            //cities.Sort(areacomp);

            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #28
0
            public bool Equals(IXmlIdentity x, IXmlIdentity y)
            {
                var nameX = x.Name;
                var nameY = y.Name;

                if (!NameComparer.Equals(nameX.LocalName, nameY.LocalName))
                {
                    return(false);
                }

                if (!XsiTypeComparer.Equals(x.XsiType, y.XsiType))
                {
                    return(false);
                }

                return(nameX.NamespaceUri == null ||
                       nameY.NamespaceUri == null ||
                       NameComparer.Equals(nameX.NamespaceUri, nameY.NamespaceUri));
            }
Exemple #29
0
    bool _puedoMover;//Booleano para detectar si se puede pulsar un botón

    //----------------------------------ATRIBUTOS--------------------------------------

    //----------------------------------CICLO DE VIDA--------------------------------------

    void Start()
    {
        instance = this;

        _puedoMover = true;

        //Buscamos las fichas
        _fichas = GameObject.FindGameObjectsWithTag("Ficha");

        //Ordenamos el array de fichas por Nombre
        IComparer myComparer = new NameComparer();

        Array.Sort(_fichas, myComparer);

        //Inicializamos el tablero y lo actualizamos
        IniciaTablero();

        UpdateTablero();
    }
Exemple #30
0
        public static void Main(string[] args)
        {
            List <City> cities = CityDataImporter.LoadData();

            // TODO Swap out comparers as desired
            IComparer <City> comparerN = new NameComparer();
            IComparer <City> comparerS = new StateComparer();
            IComparer <City> comparerA = new AreaComparer();
            IComparer <City> comparerP = new PopulationComparer();


            //cities.Sort(comparerN);
            //cities.Sort(comparerS);
            cities.Sort(comparerA);
            //cities.Sort(comparerP);

            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #31
0
        public static void Main(string[] args)
        {
            List <City>      cities = CityDataImporter.LoadData();
            IComparer <City> comparer;

            Console.WriteLine("Choose to sort by: \n" +
                              "1) City name \n" +
                              "2) State name \n" +
                              "3) Population \n" +
                              "4) Area");
            string choice = Console.ReadLine();

            if (choice == "1")
            {
                comparer = new NameComparer();
            }
            else if (choice == "2")
            {
                comparer = new StateComparer();
            }
            else if (choice == "3")
            {
                comparer = new PopulationComparer();
            }
            else
            {
                comparer = new AreaComparer();
            }

            // TODO Swap out comparers as desired
            //IComparer<City> comparer = new NameComparer();
            //IComparer<City> comparer = new StateComparer();
            //IComparer<City> comparer = new PopulationComparer();
            //IComparer<City> comparer = new AreaComparer();

            cities.Sort(comparer);

            PrintCities(cities);

            Console.ReadLine();
        }
Exemple #32
0
        /// <summary>
        /// Sets up the selected comparer.
        /// </summary>
        /// <param name="commandArgument">The command argument indicating what comparer to set up.</param>
        private void SetupSelectedComparer(string commandArgument)
        {
            SortingColumn = commandArgument;
            switch (commandArgument)
            {
            case "name":
                SelectedComparer = new NameComparer(Direction);
                break;

            case "size":
                SelectedComparer = new SizeComparer(Direction);
                break;

            case "checkedOut":
                SelectedComparer = new CheckedOutByComparer(Direction);
                break;

            case "lastChanged":
                SelectedComparer = new DateComparer(Direction);
                break;
            }
        }
Exemple #33
0
        public static void Main(string[] args)
        {
            List <City>      cities             = CityDataImporter.LoadData();
            IComparer <City> comparerName       = new NameComparer();
            IComparer <City> comparerState      = new StateComparer();
            IComparer <City> comparerArea       = new AreaComparer();
            IComparer <City> comparerPopulation = new PopulationComparer();
            // TODO Swap out comparers as desired
            string choice;

            do
            {
                Console.WriteLine("Sort by (A)rea, (N)ame, (P)opulation, or (S)tate");
                choice = Console.ReadLine().ToLower();

                if (choice == "n" || choice == "name")
                {
                    cities.Sort(comparerName);
                }
                else if (choice == "a" || choice == "area")
                {
                    cities.Sort(comparerArea);
                }
                else if (choice == "s" || choice == "state")
                {
                    cities.Sort(comparerState);
                }
                else
                {
                    cities.Sort(comparerPopulation);
                }



                PrintCities(cities);

                Console.ReadLine();
            } while (choice != "");
        }
        public ActionResult SearchIndex(string sortBy, string searchOption ,string searchText,FormCollection formcol)
         {
             
             //string sortBy2= null;
             //if (int id == 1)
             //    sortBy = "Name";


             if (sortBy != null && !"".Equals(sortBy))
             {

                 Product prod = new Product();


                 prod = db.Products.Find(20);


                 PriceComparer pComparer = new PriceComparer();
                 NameComparer nComparer = new NameComparer();
                 List<Product> IndexofList = db.Products.ToList();
                 int locateName = db.Products.ToList().IndexOf(prod);
                 db.Products.ToList().IndexOf(prod);
                 if (sortBy == "ID")
                 {
                     List<Product> SortedList = db.Products.ToList();
                     SortedList.Sort();
                     return View("Index",SortedList);
                 }
                 if (sortBy == "Price")
                 {
                     List<Product> SortedList = db.Products.ToList();
                     SortedList.Sort(pComparer);
                     return View("Index",SortedList);
                 }
                 else if (sortBy == "Name")
                 {
                     List<Product> SortedList = db.Products.ToList();
                     SortedList.Sort(nComparer);
                     return View("Index",SortedList);
                 }
                 else
                 {
                     return View("Index",db.Products.ToList());
                 }
             }
             else
                 if (searchOption != null && searchText != null)
                 {
                     var products = db.Products
                    .Where(p => p.Name.Contains(searchText)).ToList();
                     List<Product> prodList = products.ToList();

                     var productPrice = db.Products.
                       Where(p => (p.Price > 0 && p.Price <= 10)).ToList();

                     return View("Index", productPrice);

                   
                 }
                 else
                 {
                     return View("Index",db.Products.ToList());
                 }

         }
        public void Return_Correct_HashCode_From_Fields()
        {
            var name = CreateName();
            int expectedHashCode = (byte)name.MutKod ^ name.NmEtiket.GetHashCode() ^ name.NmMemo.GetHashCode() ^
                                   name.NmNaam.GetHashCode() ^ name.NmNm40.GetHashCode() ^ name.NmNr;

            var comparer = new NameComparer();
            int result = comparer.GetHashCode(name);

            Assert.AreEqual(expectedHashCode, result);
        }
        public ActionResult Index(string sortBy, string searchText, int priceMinRange=0, int priceMaxRange=25000)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(currentDomain_UnhandledException);
           // Application.ThreadException += new UnhandledExceptionEventHandler(currentDomain_UnhandledException);
             #region Unhandled Exception Test
            //string testUnhandle = null;
            //testUnhandle.ToString();

            #endregion

            

            #region List to Array
            //List<Product> baseList = db.Products.ToList();
            //// int arraySize= baseList.Count;
            //Product[] productArray = baseList.ToArray();
            //Array productDestinationArray = Array.CreateInstance(typeof(Product), baseList.Count);
            //Array.Copy(productArray, productArray.GetLowerBound(0) + 5
            //    , productDestinationArray, productDestinationArray.GetLowerBound(0), productDestinationArray.GetLowerBound(0) + 25);

            //Array.ConstrainedCopy(productArray, productArray.GetLowerBound(0) + 5
            //  , productDestinationArray, productDestinationArray.GetLowerBound(0), productDestinationArray.GetLowerBound(0) + 5);
             
         

            #endregion

            #region List to XML
            List<Product> xmlList = db.Products.ToList();
            var xmlFromList = new XElement("Products"
                , xmlList.Select(x => new XElement("Product"
                , new  XAttribute("Id", x.ID)
                , new XAttribute("Name", x.Name)
                , new XAttribute("Price", x.Price))));
               
            #endregion
            IQueryable iqueryable;
            oLearner.Equals(oLearner);
            var hashCode= oLearner.GetHashCode();
            var typeCurrentInstance= oLearner.GetType();
            var objStr= oLearner.ToString();

            //FormCollection fc = new FormCollection();
            //fc.Add("oLearner",oLearner.ToString());
           // ArrayList aList = new ArrayList();



             
            Logger.logger.Info("Inside  Store Index Info");
            Logger.logger.Fatal("Inside  Store Index Fatal");
            Logger.logger.Error("Inside  Store Index Error");
            Logger.logger.Debug("Inside  Store Index Debug");
            Logger.logger.Warn("Inside  Store Index Warn");
           
            //string sortBy2= null;
            //if (int id == 1)
            //    sortBy = "Name"; 


            #region Locating Object for an element- IComparable IndexOf has to implement Equals n GetHashCode
            Product prod = new Product();

            prod = db.Products.Find(20);
            int locateName = db.Products.ToList().IndexOf(prod);
            List<Product> productsLambda = db.Products.ToList();
            #endregion





            if (sortBy != null && !"".Equals(sortBy))
            {

                

                PriceComparer pComparer = new PriceComparer();
                NameComparer nComparer = new NameComparer();
                //List<Product> IndexofList = db.Products.ToList();
              



                Product p1; Product p2;
                //Comparator pcomparator = new Comparator(StoresController.compare(p1,p2));

                //test(new Comparator(Compare));
                //test(new Comparator(Compare1));
                //SortedList.Sort(pComparer);
                
                //db.Products.ToList().IndexOf(prod);
                if (sortBy == "ID")
                {
                    List<Product> SortedList = db.Products.ToList();
                    SortedList.Sort();
                    return View(SortedList);
                }
                if (sortBy == "Price")
                {
                    List<Product> SortedList = db.Products.ToList();
                    #region Interface with one method 
                    //SortedList.Sort(pComparer);
                    #endregion
                    #region Anonymous Methods
                    //SortedList.Sort(delegate(Product x, Product y)
                    //                            {
                                                    
                    //                                    if (x.Price > y.Price)
                    //                                         return 1;
                    //                                    else if (x.Price < y.Price)
                    //                                        return -1;
                    //                                    else
                    //                                        return 0;

                    //                            });
                    #endregion
                    #region Named Delegate
                    //SortedList.Sort(Compare);
                    #endregion
                    #region Lambda Expressions
                    SortedList.Sort((p3,p4) => p3.Price.CompareTo(p4.Price));
                    SortedList.OrderByDescending(p => p.Price).ToList();
                    #endregion
                    return View(SortedList);
                }
                else if (sortBy == "Name") 
                {
                    List<Product> SortedList = db.Products.ToList();
                    SortedList.Sort(nComparer);
                    SortedList.Reverse();
                    return View(SortedList);
                }
                else
                {
                    return View(db.Products.ToList());
                }
            }
            else
                {
                    var products = db.Products.ToList();
                    if (searchText != null && !"".Equals(searchText))
                    {
                        products = products
                       .Where(p => p.Name.Contains(searchText) && (p.Price > priceMinRange && p.Price <= priceMaxRange)).ToList();
                        List<Product> prodList = products.ToList();
                        

                        //var productPrice = db.Products.
                        //  Where(p => (p.Price > 0 && p.Price <= 10)).ToList();
                    }
                    else
                    {
                        products = products
                      .Where(p => (p.Price > priceMinRange && p.Price <= priceMaxRange)).ToList();
                        List<Product> prodList = products.ToList();
                        

                    }

                        return View("Index", products);

                }

        }