Ejemplo n.º 1
0
 public override string SelectAction(
     Microsoft.AspNet.OData.Routing.ODataPath odataPath,
     System.Web.Http.Controllers.HttpControllerContext controllerContext,
     System.Linq.ILookup <string, System.Web.Http.Controllers.HttpActionDescriptor> actionMap)
 {
     return(null);
 }
Ejemplo n.º 2
0
 public override int Execute(Settings settings, System.Linq.ILookup <string, string> unmapped)
 {
     WriteLine($"Memery {this.GetType().Assembly.GetName().Version}");
     WriteLine($"{this.GetType().Assembly.Location}: Application root is {System.IO.Directory.GetCurrentDirectory()}");
     WriteLine($"Using server at '{_options.Value.Server}'");
     WriteLine($"SSL Verification is {(_options.Value.DisableSSLVerification ? "DISABLED!" : "enabled.")}");
     return(0);
 }
Ejemplo n.º 3
0
            // DDB:171937
            public static int Test7()
            {
                string[] key     = { null };
                string[] element = { null };
                string[] source  = new string[] { null };

                System.Linq.ILookup <string, string> result = source.ToLookup((e) => e, (e) => e, EqualityComparer <string> .Default);

                return(Helper.MatchAll(key, element, result));
            }
Ejemplo n.º 4
0
            //Overload-4: source is empty
            public static int Test5()
            {
                string[] key     = { };
                int[]    element = { };
                Record[] source  = new Record[] { };

                System.Linq.ILookup <string, int> result = source.ToLookup((e) => e.Name, (e) => e.Score, new AnagramEqualityComparer());

                return(Helper.MatchAll(key, element, result));
            }
Ejemplo n.º 5
0
    /// <summary>
    /// Initializes the class.
    /// </summary>
    static AssemblyAttribute()
    {
        var type    = typeof(Opcode);
        var opcodes = (from Opcode opcode in Enum.GetValues(type)
                       let name = Enum.GetName(type, opcode)
                                  from info in type.GetField(name).GetCustomAttributes().Cast <AssemblyAttribute>()
                                  select(opcode, info)).ToArray();

        foreach (var item in opcodes)
        {
            item.info.Opcode = item.opcode;
        }

        OpcodeToInfo   = opcodes.ToLookup(i => i.opcode, i => i.info);
        MnemonicToInfo = opcodes.ToDictionary(i => i.info.Mnemonic, i => i.info);
    }
Ejemplo n.º 6
0
            // Overload-4: keySelector has duplicate values
            public static int Test4()
            {
                string[] key     = { "Chris", "Prakash", "Robert" };
                int[]    element = { 50, 80, 100, 95, 99, 56 };
                Record[] source  = new Record[6];

                source[0].Name = key[0]; source[0].Score = element[0];
                source[1].Name = key[1]; source[1].Score = element[2];
                source[2].Name = key[2]; source[2].Score = element[5];
                source[3].Name = key[1]; source[3].Score = element[3];
                source[4].Name = key[0]; source[4].Score = element[1];
                source[5].Name = key[1]; source[5].Score = element[4];

                System.Linq.ILookup <string, int> result = source.ToLookup((e) => e.Name, (e) => e.Score, new AnagramEqualityComparer());

                return(Helper.MatchAll(key, element, result));
            }
Ejemplo n.º 7
0
        public override int Execute(Settings settings, System.Linq.ILookup <string, string> unmapped)
        {
            var file = new FileInfo(settings.FilePath);

            if (!file.Exists)
            {
                throw new FileNotFoundException("File not found!", settings.FilePath);
            }
            ImageResponse image = string.IsNullOrWhiteSpace(settings.Name)
                ? _client.UploadImage(file).Result
                : _client.UploadImage(file, settings.Name).Result;

            if (string.IsNullOrWhiteSpace(settings.Name))
            {
                image = _client.UploadImage(file).Result;
            }
            WriteLine("Your image has been successfully uploaded and can now be reached at:");
            WriteLine($"\t{_client.BaseAddress}{image.Id}");
            WriteLine($"\t{_client.BaseAddress}{image.Name}");
            return(0);
        }
Ejemplo n.º 8
0
        private static void AssertMatches <K, T>(IEnumerable <K> keys, IEnumerable <T> elements, System.Linq.ILookup <K, T> lookup)
        {
            Assert.NotNull(lookup);
            Assert.NotNull(keys);
            Assert.NotNull(elements);

            int num = 0;

            using (IEnumerator <K> keyEnumerator = keys.GetEnumerator())
                using (IEnumerator <T> elEnumerator = elements.GetEnumerator())
                {
                    while (keyEnumerator.MoveNext())
                    {
                        Assert.True(lookup.Contains(keyEnumerator.Current));

                        foreach (T e in lookup[keyEnumerator.Current])
                        {
                            Assert.True(elEnumerator.MoveNext());
                            Assert.Equal(e, elEnumerator.Current);
                        }
                        ++num;
                    }
                    Assert.False(elEnumerator.MoveNext());
                }
            Assert.Equal(num, lookup.Count);
        }
Ejemplo n.º 9
0
            // The following helper verification function will be used when the PLINQ team runs these tests
            // This is a non-order preserving verification function
#if PLINQ
            public static int MatchAll <K, T>(IEnumerable <K> key, IEnumerable <T> element, System.Linq.ILookup <K, T> lookup)
            {
                int num = 0;

                if ((lookup == null) && (key == null) && (element == null))
                {
                    return(0);
                }

                if ((lookup == null) || (key == null && element == null))
                {
                    Console.WriteLine("expected key : {0}", key == null ? "null" : key.Count().ToString());
                    Console.WriteLine("expected element : {0}", element == null ? "null" : element.Count().ToString());
                    Console.WriteLine("actual lookup: {0}", lookup == null ? "null" : lookup.Count().ToString());
                    return(1);
                }

                try
                {
                    List <T> expectedResults = new List <T>(element);

                    using (IEnumerator <K> k1 = key.GetEnumerator())
                        using (IEnumerator <T> e1 = element.GetEnumerator())
                        {
                            while (k1.MoveNext())
                            {
                                if (!lookup.Contains(k1.Current))
                                {
                                    return(1);
                                }

                                foreach (T e in lookup[k1.Current])
                                {
                                    if (!expectedResults.Contains(e))
                                    {
                                        return(1);
                                    }
                                    expectedResults.Remove(e);
                                }
                                num = num + 1;
                            }
                        }

                    if (expectedResults.Count != 0)
                    {
                        return(1);
                    }
                    if (lookup.Count != num)
                    {
                        return(1);
                    }
                    return(0);
                }
                catch (AggregateException ae)
                {
                    var innerExceptions = ae.Flatten().InnerExceptions;
                    if (innerExceptions.Where(ex => ex != null).Select(ex => ex.GetType()).Distinct().Count() == 1)
                    {
                        throw innerExceptions.First();
                    }
                    else
                    {
                        Console.WriteLine(ae);
                    }
                    return(1);
                }
            }
Ejemplo n.º 10
0
            // Helper function to verify that all elements in dictionary are matched (Order Preserving)
            public static int MatchAll <K, T>(IEnumerable <K> key, IEnumerable <T> element, System.Linq.ILookup <K, T> lookup)
            {
                int num = 0;

                if ((lookup == null) && (key == null) && (element == null))
                {
                    return(0);
                }
                using (IEnumerator <K> k1 = key.GetEnumerator())
                    using (IEnumerator <T> e1 = element.GetEnumerator())
                    {
                        while (k1.MoveNext())
                        {
                            if (!lookup.Contains(k1.Current))
                            {
                                return(1);
                            }

                            foreach (T e in lookup[k1.Current])
                            {
                                e1.MoveNext();
                                if (!Equals(e, e1.Current))
                                {
                                    return(1);
                                }
                            }
                            num = num + 1;
                        }
                    }
                if (lookup.Count != num)
                {
                    return(1);
                }
                return(0);
            }