コード例 #1
0
        private static XamlNamespaceRegistry CreateXamlNamespaceRegistry()
        {
            var xamlNamespaceRegistry = new XamlNamespaceRegistry();

            var forcedAssemblies = new[]
            {
                typeof (Control),
                typeof(Style)
            }.Select(t => t.GetTypeInfo().Assembly);

            foreach (var nsa in 
                forcedAssemblies
                    .Concat(Locator.Current.GetService<IPclPlatformWrapper>().GetLoadedAssemblies())
                    .Distinct()
                    .SelectMany(asm
                        => asm.GetCustomAttributes<XmlnsDefinitionAttribute>().Select(attr => new {asm, attr}))
                    .GroupBy(entry => entry.attr.XmlNamespace))
            {
                var def = XamlNamespace.Map(nsa.Key)
                    .With(nsa.GroupBy(x => x.asm).Select(
                        a => Route.Assembly(a.Key)
                            .WithNamespaces(a.Select(entry => entry.attr.ClrNamespace).ToList())
                        ));
                xamlNamespaceRegistry.AddNamespace(def);
            }
            xamlNamespaceRegistry.RegisterPrefix(new PrefixRegistration(string.Empty, PerspexNs));

            return xamlNamespaceRegistry;
        }
コード例 #2
0
ファイル: BundleConfig.cs プロジェクト: bagwanshoaib/mixerp
        private static string[] GetLibrariesScript()
        {
            string[] libraries = new[]
            {
                "~/Scripts/jquery-1.9.1.js",
                "~/Scripts/jquery.address.js",
                "~/Scripts/jquery-ui.js",
                "~/Scripts/jquery-timePicker/jquery.timepicker.js",
                "~/Scripts/shortcut.js",
                "~/Scripts/colorbox/jquery.colorbox.js",
                "~/Scripts/jqueryNumber/jquery.number.js",
                "~/Scripts/date.js",
                "~/Scripts/chartjs/Chart.min.js",
                "~/Scripts/chartjs/legend.js",
                "~/Scripts/notify-combined.min.js",
                "~/Scripts/semantic-ui/semantic.js",
                "~/Scripts/jquery.signalR.js",
                "~/Scripts/vakata-jstree/dist/jstree.min.js",
                "~/Scripts/momentjs/moment-with-locales.js",
                "~/Scripts/underscore/underscore-min.js",
                "~/Scripts/angular/angular.min.js",
                "~/Scripts/linq.js/linq.js"
            };

            libraries = libraries.Concat(GetMixERPCoreScript()).ToArray();

            return libraries;
        }
コード例 #3
0
 public static IEnumerable<TestCaseData> ProjectMessageCases()
 {
     //Match
     var commands1 = new[] { CommandFactory(), CommandFactory() };
     var handler1 = new SqlProjectionHandler(typeof(object), _ => commands1);
     var resolver1 = new SqlProjectionHandlerResolver(message => new[] { handler1 });
     yield return new TestCaseData(
         resolver1,
         new object(),
         commands1);
     //Mismatch
     var resolver2 = new SqlProjectionHandlerResolver(message => new SqlProjectionHandler[0]);
     yield return new TestCaseData(
         resolver2,
         new object(),
         new SqlNonQueryCommand[0]);
     //Multimatch
     var commands3 = new[] { CommandFactory(), CommandFactory() };
     var commands4 = new[] { CommandFactory(), CommandFactory() };
     var handler3 = new SqlProjectionHandler(typeof(object), _ => commands3);
     var handler4 = new SqlProjectionHandler(typeof(object), _ => commands4);
     var resolver3 = new SqlProjectionHandlerResolver(message => new[] { handler3, handler4 });
     yield return new TestCaseData(
         resolver3,
         new object(),
         commands3.Concat(commands4).ToArray());
 }
コード例 #4
0
 public override IEnumerable<OperatorElement> FindPath(Element target)
 {
     var pathHere = new[] {this};
     if (ReferenceEquals(Elements.Lhs, target) || ReferenceEquals(Elements.Rhs, target)) return pathHere;
     var pathFromHere = Elements.Lhs.FindPath(target) ?? Elements.Rhs.FindPath(target);
     return pathFromHere != null ? pathHere.Concat(pathFromHere) : null;
 }
コード例 #5
0
 private static ImmutableArray<SymbolDisplayPart> WithSupertypes(ImmutableArray<SymbolDisplayPart> defaultParts, INamedTypeSymbol type)
 {
     if (type == null || !s_TypeKindsWithUserSpecifiedSuperTypes.Contains(type.TypeKind)) return defaultParts;
     var baseTypes = new[] { type.BaseType }.Where(NonImpliedBaseType);
     var inheritsFrom = baseTypes.Concat(GetInterfaces(type)).Select(GetSimpleTypeName).ToList();
     var inheritanceSuffix = inheritsFrom.Any() ? s_InheritsFrom.Concat(CommaSeparate(inheritsFrom)) : new SymbolDisplayPart[0];
     return WithInheritsFrom(defaultParts, inheritanceSuffix);
 }
コード例 #6
0
        public void Concat()
        {
            var source = new[] {2, 3, 4};
            var expected = new[] {2, 3, 4, 5};

            CollectionAssert.AreEqual(
                expected, source.Concat(5).ToArray());
        }
コード例 #7
0
        public void ComplexValueTest()
        {
            EdmModel model = new EdmModel();

            var emptyComplexType = new EdmComplexType(DefaultNamespaceName, "EmptyComplexType");
            model.AddElement(emptyComplexType);

            var complexTypeWithStringProperty = new EdmComplexType(DefaultNamespaceName, "ComplexTypeWithStringProperty");
            complexTypeWithStringProperty.AddStructuralProperty("stringProperty", EdmCoreModel.Instance.GetString(isNullable: true));
            complexTypeWithStringProperty.AddStructuralProperty("numberProperty", EdmCoreModel.Instance.GetInt32(isNullable: false));
            model.AddElement(complexTypeWithStringProperty);

            model.Fixup();
            

            IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new[]
            {
                // Empty element is a valid complex value
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    PayloadElement = PayloadBuilder.ComplexValue("TestModel.EmptyComplexType")
                        .XmlValueRepresentation(new XNode[0])
                        .WithTypeAnnotation(emptyComplexType),
                    PayloadEdmModel = model
                },
            };

            testDescriptors = testDescriptors.Concat(
                PropertiesElementAtomValues.CreatePropertiesElementPaddingPayloads<ComplexInstance>(
                    new PayloadReaderTestDescriptor(this.Settings)
                    {
                        PayloadElement = PayloadBuilder.ComplexValue("TestModel.ComplexTypeWithStringProperty")
                            .WithTypeAnnotation(complexTypeWithStringProperty),
                        PayloadEdmModel = model
                    },
                    (complexInstance, xmlValue) => complexInstance.XmlValueRepresentation(xmlValue)));

            testDescriptors = testDescriptors.Select(td => td.InProperty());

            testDescriptors = testDescriptors.Concat(new []
            {
                // Top-level property without expected type and no type name - this is read as primitive string!
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    PayloadElement = PayloadBuilder.Property(null, PayloadBuilder.PrimitiveValue(string.Empty))
                        .XmlRepresentation("<m:value/>"),
                    PayloadEdmModel = model,
                },
            });

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.AtomFormatConfigurations,
                (testDescriptor, testConfiguration) =>
                {
                    testDescriptor.RunTest(testConfiguration);
                });
        }
コード例 #8
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxInt32()
 {
     var ten = Enumerable.Range(1, 10).ToArray();
     var minusTen = new[] { -100, -15, -50, -10 };
     var thousand = new[] { -16, 0, 50, 100, 1000 };
     Assert.Equal(10, ten.Max());
     Assert.Equal(-10, minusTen.Max());
     Assert.Equal(1000, thousand.Max());
     Assert.Equal(int.MaxValue, thousand.Concat(Enumerable.Repeat(int.MaxValue, 1)).Max());
 }
コード例 #9
0
        public void should_concat_sequences()
        {
            var left = new[] {1, 2, 3};
            var right = new[] {4, 5};

            IEnumerable<int> concat = left.Concat(right);

            // please update variable value to fix the test.
            IEnumerable<int> expectedConcatResult = new[] {1, 2, 3};

            Assert.Equal(expectedConcatResult, concat);
        }
コード例 #10
0
ファイル: MinMaxTests.cs プロジェクト: jmhardison/corefx
 public void MaxInt32()
 {
     var ten = Enumerable.Range(1, 10).ToArray();
     var minusTen = new[] { -100, -15, -50, -10 };
     var thousand = new[] { -16, 0, 50, 100, 1000 };
     Assert.Equal(42, Enumerable.Repeat(42, 1).Max());
     Assert.Equal(10, ten.Max());
     Assert.Equal(-10, minusTen.Max());
     Assert.Equal(1000, thousand.Max());
     Assert.Equal(int.MaxValue, thousand.Concat(Enumerable.Repeat(int.MaxValue, 1)).Max());
     Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<int>().Max());
 }
コード例 #11
0
ファイル: MinMaxTests.cs プロジェクト: jmhardison/corefx
 public void MaxInt64()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (long)i).ToArray();
     var minusTen = new[] { -100L, -15, -50, -10 };
     var thousand = new[] { -16L, 0, 50, 100, 1000 };
     Assert.Equal(42, Enumerable.Repeat(42L, 1).Max());
     Assert.Equal(10, ten.Max());
     Assert.Equal(-10, minusTen.Max());
     Assert.Equal(1000, thousand.Max());
     Assert.Equal(long.MaxValue, thousand.Concat(Enumerable.Repeat(long.MaxValue, 1)).Max());
     Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<long>().Max());
 }
コード例 #12
0
 public static IEnumerable<TestCaseData> ProjectMessagesCases()
 {
     //Partial match
     var commands1 = new[] { CommandFactory(), CommandFactory() };
     var handler1 = new SqlProjectionHandler(typeof(string), _ => commands1);
     var resolver1 = Resolve.WhenEqualToHandlerMessageType(new[] { handler1 });
     yield return new TestCaseData(
         resolver1,
         new object[] { "123", 123 },
         commands1);
     //Mismatch
     var resolver2 = Resolve.WhenEqualToHandlerMessageType(new SqlProjectionHandler[0]);
     yield return new TestCaseData(
         resolver2,
         new object[] { new object(), 123 },
         new SqlNonQueryCommand[0]);
     //Multimatch
     var commands3 = new[] { CommandFactory(), CommandFactory() };
     var commands4 = new[] { CommandFactory(), CommandFactory() };
     var handler3 = new SqlProjectionHandler(typeof(object), _ => commands3);
     var handler4 = new SqlProjectionHandler(typeof(object), _ => commands4);
     var resolver3 = Resolve.WhenEqualToHandlerMessageType(new[] { handler3, handler4 });
     yield return new TestCaseData(
         resolver3,
         new object[] { new object(), new object() },
         commands3.Concat(commands4).Concat(commands3).Concat(commands4).ToArray());
     //Multitype Match
     var commands5 = new[] { CommandFactory(), CommandFactory() };
     var commands6 = new[] { CommandFactory(), CommandFactory() };
     var handler5 = new SqlProjectionHandler(typeof(string), _ => commands5);
     var handler6 = new SqlProjectionHandler(typeof(int), _ => commands6);
     var resolver4 = Resolve.WhenEqualToHandlerMessageType(new[] { handler5, handler6 });
     yield return new TestCaseData(
         resolver4,
         new object[] { "123", 123 },
         commands5.Concat(commands6).ToArray());
     //Match
     var commands7 = new[] { CommandFactory(), CommandFactory() };
     var commands8 = new[] { CommandFactory(), CommandFactory() };
     var handler7 = new SqlProjectionHandler(typeof(object), _ => commands7);
     var handler8 = new SqlProjectionHandler(typeof(object), _ => commands8);
     var resolver5 = Resolve.WhenEqualToHandlerMessageType(new[] { handler7, handler8 });
     yield return new TestCaseData(
         resolver5,
         new object[] { new object() },
         commands7.Concat(commands8).ToArray());
 }
        public void WhenNewInstancesAdded_ShouldIncludeAllInstancesInDistribution()
        {
            var strategy = new SingleInstanceRoundRobinDistributionStrategy("endpointA", DistributionStrategyScope.Send);

            var instances = new []
            {
                "1",
                "2",
            };

            var result = new List<string>();
            result.Add(strategy.SelectReceiver(instances));
            result.Add(strategy.SelectReceiver(instances));
            instances = instances.Concat(new [] { "3" }).ToArray(); // add new instance
            result.Add(strategy.SelectReceiver(instances));

            Assert.That(result.Count, Is.EqualTo(3));
            Assert.That(result, Has.Exactly(1).EqualTo(instances[0]));
            Assert.That(result, Has.Exactly(1).EqualTo(instances[1]));
            Assert.That(result, Has.Exactly(1).EqualTo(instances[2]));
        }
コード例 #14
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxDateTime()
 {
     var ten = Enumerable.Range(1, 10).Select(i => new DateTime(2000, 1, i)).ToArray();
     var newYearsEve = new[]
     {
         new DateTime(2000, 12, 1),
         new DateTime(2000, 12, 31),
         new DateTime(2000, 1, 12)
     };
     var threeThousand = new[]
     {
         new DateTime(3000, 1, 1),
         new DateTime(100, 1, 1),
         new DateTime(200, 1, 1),
         new DateTime(1000, 1, 1)
     };
     Assert.Equal(new DateTime(2000, 1, 10), ten.Max());
     Assert.Equal(new DateTime(2000, 12, 31), newYearsEve.Max());
     Assert.Equal(new DateTime(3000, 1, 1), threeThousand.Max());
     Assert.Equal(DateTime.MaxValue, threeThousand.Concat(Enumerable.Repeat(DateTime.MaxValue, 1)).Max());
 }
コード例 #15
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxNullableDecimal()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (decimal?)i).ToArray();
     var minusTen = new[] { default(decimal?), -100M, -15, -50, -10 };
     var thousand = new[] { default(decimal?), -16M, 0, 50, 100, 1000 };
     Assert.Equal(42M, Enumerable.Repeat((decimal?)42, 1).Max());
     Assert.Equal(10M, ten.Max());
     Assert.Equal(-10M, minusTen.Max());
     Assert.Equal(1000M, thousand.Max());
     Assert.Equal(decimal.MaxValue, thousand.Concat(Enumerable.Repeat((decimal?)decimal.MaxValue, 1)).Max());
 }
コード例 #16
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxNullableDouble()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (double?)i).ToArray();
     var minusTen = new[] { default(double?), -100D, -15, -50, -10 };
     var thousand = new[] { default(double?), -16D, 0, 50, 100, 1000 };
     Assert.Equal(10D, ten.Max());
     Assert.Equal(-10D, minusTen.Max());
     Assert.Equal(1000D, thousand.Max());
     Assert.Equal(double.MaxValue, thousand.Concat(Enumerable.Repeat((double?)double.MaxValue, 1)).Max());
 }
コード例 #17
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxNullableSingle()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (float?)i).ToArray();
     var minusTen = new[] { default(float?), -100F, -15, -50, -10 };
     var thousand = new[] { default(float?), -16F, 0, 50, 100, 1000 };
     Assert.Equal(10F, ten.Max());
     Assert.Equal(-10F, minusTen.Max());
     Assert.Equal(1000F, thousand.Max());
     Assert.Equal(float.MaxValue, thousand.Concat(Enumerable.Repeat((float?)float.MaxValue, 1)).Max());
 }
コード例 #18
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxNullableInt64()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (long?)i).ToArray();
     var minusTen = new[] { default(long?), -100L, -15, -50, -10 };
     var thousand = new[] { default(long?), -16L, 0, 50, 100, 1000 };
     Assert.Equal(10, ten.Max());
     Assert.Equal(-10, minusTen.Max());
     Assert.Equal(1000, thousand.Max());
     Assert.Equal(long.MaxValue, thousand.Concat(Enumerable.Repeat((long?)long.MaxValue, 1)).Max());
     Assert.Null(Enumerable.Repeat(default(long?), 100).Max());
 }
コード例 #19
0
        /// <summary>
        /// Adds view locations formats for non-themed views in custom orchard modules.
        /// </summary>
        private void AddOrchardLocationsFormats()
        {
            IEnumerable<string> orchardMasterLocationFormats = new[] {
                    "~/Modules/{2}/Views/{1}/{0}.master",
                    "~/Modules/{2}/Views/Shared/{0}.master",
                    "~/Core/{2}/Views/{1}/{0}.master",
                    "~/Core/{2}/Views/Shared/{0}.master",
                    "~/Areas/{2}/Views/{1}/{0}.master",
                    "~/Areas/{2}/Views/Shared/{0}.master",
                };

            IEnumerable<string> orchardLocationFormats = new[] {
                    "~/Modules/{2}/Views/{1}/{0}.aspx",
                    "~/Modules/{2}/Views/{1}/{0}.ascx",
                    "~/Modules/{2}/Views/Shared/{0}.aspx",
                    "~/Modules/{2}/Views/Shared/{0}.ascx",
                    "~/Core/{2}/Views/{1}/{0}.aspx",
                    "~/Core/{2}/Views/{1}/{0}.ascx",
                    "~/Core/{2}/Views/Shared/{0}.aspx",
                    "~/Core/{2}/Views/Shared/{0}.ascx",
                    "~/Areas/{2}/Views/{1}/{0}.aspx",
                    "~/Areas/{2}/Views/{1}/{0}.ascx",
                    "~/Areas/{2}/Views/Shared/{0}.aspx",
                    "~/Areas/{2}/Views/Shared/{0}.ascx",
                };

            var viewEngine = _viewEngines.OfType<VirtualPathProviderViewEngine>().Single();
            viewEngine.AreaMasterLocationFormats = orchardMasterLocationFormats
                .Concat(viewEngine.AreaMasterLocationFormats)
                .Distinct()
                .ToArray();
            viewEngine.AreaViewLocationFormats = orchardLocationFormats
                .Concat(viewEngine.AreaViewLocationFormats)
                .Distinct()
                .ToArray();
            viewEngine.AreaPartialViewLocationFormats = orchardLocationFormats
                .Concat(viewEngine.AreaPartialViewLocationFormats)
                .Distinct()
                .ToArray();
        }
コード例 #20
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxNullableInt32WithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (int?)i).ToArray();
     var minusTen = new[] { default(int?), -100, -15, -50, -10 };
     var thousand = new[] { default(int?), -16, 0, 50, 100, 1000 };
     Assert.Equal(42, Enumerable.Repeat((int?)42, 1).Max(x => x));
     Assert.Equal(10, ten.Max(x => x));
     Assert.Equal(-10, minusTen.Max(x => x));
     Assert.Equal(1000, thousand.Max(x => x));
     Assert.Equal(int.MaxValue, thousand.Concat(Enumerable.Repeat((int?)int.MaxValue, 1)).Max(x => x));
     Assert.Null(Enumerable.Repeat(default(int?), 100).Max(x => x));
 }
コード例 #21
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxDecimalWithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (decimal)i).ToArray();
     var minusTen = new[] { -100M, -15, -50, -10 };
     var thousand = new[] { -16M, 0, 50, 100, 1000 };
     Assert.Equal(42M, Enumerable.Repeat(42M, 1).Max(x => x));
     Assert.Equal(10M, ten.Max(x => x));
     Assert.Equal(-10M, minusTen.Max(x => x));
     Assert.Equal(1000M, thousand.Max(x => x));
     Assert.Equal(decimal.MaxValue, thousand.Concat(Enumerable.Repeat(decimal.MaxValue, 1)).Max(x => x));
 }
コード例 #22
0
        public void Can_add_aggregate_with_other_linked_aggregate_not_attached()
        {
            using (var context = new AggregateContext())
            {
                var reminders = new[] { new Reminder { Id = 11 }, new Reminder { Id = 12 } };
                var author = new Author { Id = 22, Reminders = reminders.ToList() };

                var comments0 = new[] { new Comment { Id = 33, Author = author }, new Comment { Id = 34, Author = author } };
                var comments1 = new[] { new Comment { Id = 44, Author = author }, new Comment { Id = 45, Author = author } };
                var posts = new[]
                    {
                        new Post { Id = 55, Author = author, Comments = comments0.ToList() },
                        new Post { Id = 56, Author = author, Comments = comments1.ToList() }
                    };
                var blog = new Blog { Id = 66, Author = author, Posts = posts.ToList() };

                author.Comments = comments0.Concat(comments1).ToList();
                comments0[0].Post = posts[0];
                posts[0].Blog = blog;

                context.Add(author);

                Assert.Equal(EntityState.Detached, context.Entry(blog).State);
                Assert.Equal(EntityState.Detached, context.Entry(posts[0]).State);
                Assert.Equal(EntityState.Detached, context.Entry(posts[1]).State);
                Assert.Equal(EntityState.Added, context.Entry(comments0[0]).State);
                Assert.Equal(EntityState.Added, context.Entry(comments0[1]).State);
                Assert.Equal(EntityState.Added, context.Entry(comments1[0]).State);
                Assert.Equal(EntityState.Added, context.Entry(comments1[1]).State);
                Assert.Equal(EntityState.Added, context.Entry(author).State);
                Assert.Equal(EntityState.Added, context.Entry(reminders[0]).State);
                Assert.Equal(EntityState.Added, context.Entry(reminders[1]).State);
            }
        }
コード例 #23
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxInt64WithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (long)i).ToArray();
     var minusTen = new[] { -100L, -15, -50, -10 };
     var thousand = new[] { -16L, 0, 50, 100, 1000 };
     Assert.Equal(42, Enumerable.Repeat(42L, 1).Max(x => x));
     Assert.Equal(10, ten.Max(x => x));
     Assert.Equal(-10, minusTen.Max(x => x));
     Assert.Equal(1000, thousand.Max(x => x));
     Assert.Equal(long.MaxValue, thousand.Concat(Enumerable.Repeat(long.MaxValue, 1)).Max(x => x));
 }
コード例 #24
0
ファイル: MinMaxTests.cs プロジェクト: jmhardison/corefx
 public void MaxDateTimeWithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => new DateTime(2000, 1, i)).ToArray();
     var newYearsEve = new[]
     {
         new DateTime(2000, 12, 1),
         new DateTime(2000, 12, 31),
         new DateTime(2000, 1, 12)
     };
     var threeThousand = new[]
     {
         new DateTime(3000, 1, 1),
         new DateTime(100, 1, 1),
         new DateTime(200, 1, 1),
         new DateTime(1000, 1, 1)
     };
     Assert.Equal(new DateTime(2000, 1, 10), ten.Max(x => x));
     Assert.Equal(new DateTime(2000, 12, 31), newYearsEve.Max(x => x));
     Assert.Equal(new DateTime(3000, 1, 1), threeThousand.Max(x => x));
     Assert.Equal(DateTime.MaxValue, threeThousand.Concat(Enumerable.Repeat(DateTime.MaxValue, 1)).Max(x => x));
     Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<DateTime>().Max(x => x));
 }
コード例 #25
0
ファイル: Editor.cs プロジェクト: ChinaJason/Typewriter
        public IEnumerable<Completion> GetCompletions(ITextBuffer buffer, SnapshotSpan span, IGlyphService glyphService)
        {
            var semanticModel = GetSemanticModel(buffer);
            var identifiers = semanticModel.GetIdentifiers(span.Start);
            var contextSpan = semanticModel.GetContextSpan(span.Start);
            var prefix = contextSpan.Type == ContextType.Template ? "$" : "";

            var completions = identifiers.Select(i =>
            {
                var imageSource = glyphService.GetGlyph(i.Glyph, StandardGlyphItem.GlyphItemPublic);
                var quickInfo = i.IsParent ? i.QuickInfo.Replace("Item", contextSpan.ParentContext?.Name) : i.QuickInfo;

                return new Completion(prefix + i.Name, prefix + i.Name, quickInfo, imageSource, null);
            });

            if (contextSpan.Type == ContextType.Template && contextSpan.Context.Name == nameof(File))
            {
                var imageSource = glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                var codeBlock = new[]
                {
                    new Completion("${ }", "${\r\n}", "Insert a custom C# code block.", imageSource, null)
                };

                return codeBlock.Concat(completions);
            }

            return completions;
        }
コード例 #26
0
ファイル: MinMaxTests.cs プロジェクト: jmhardison/corefx
 public void MaxSingle()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (float)i).ToArray();
     var minusTen = new[] { -100F, -15, -50, -10 };
     var thousand = new[] { -16F, 0, 50, 100, 1000 };
     Assert.Equal(42F, Enumerable.Repeat(42F, 1).Max());
     Assert.Equal(10F, ten.Max());
     Assert.Equal(-10F, minusTen.Max());
     Assert.Equal(1000F, thousand.Max());
     Assert.Equal(float.MaxValue, thousand.Concat(Enumerable.Repeat(float.MaxValue, 1)).Max());
     Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<float>().Max());
 }
コード例 #27
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxSingleWithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (float)i).ToArray();
     var minusTen = new[] { -100F, -15, -50, -10 };
     var thousand = new[] { -16F, 0, 50, 100, 1000 };
     Assert.Equal(42F, Enumerable.Repeat(42F, 1).Max(x => x));
     Assert.Equal(10F, ten.Max(x => x));
     Assert.Equal(-10F, minusTen.Max(x => x));
     Assert.Equal(1000F, thousand.Max(x => x));
     Assert.Equal(float.MaxValue, thousand.Concat(Enumerable.Repeat(float.MaxValue, 1)).Max(x => x));
 }
コード例 #28
0
ファイル: MaxTests.cs プロジェクト: er0dr1guez/corefx
 public void MaxDoubleWithSelector()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (double)i).ToArray();
     var minusTen = new[] { -100D, -15, -50, -10 };
     var thousand = new[] { -16D, 0, 50, 100, 1000 };
     Assert.Equal(42D, Enumerable.Repeat(42D, 1).Max(x => x));
     Assert.Equal(10D, ten.Max(x => x));
     Assert.Equal(-10D, minusTen.Max(x => x));
     Assert.Equal(1000D, thousand.Max(x => x));
     Assert.Equal(double.MaxValue, thousand.Concat(Enumerable.Repeat(double.MaxValue, 1)).Max(x => x));
 }
コード例 #29
0
ファイル: WinMdDumpTest.cs プロジェクト: GloryChou/roslyn
        private string Dump(MetadataReference winmd, MetadataReference[] additionalRefs = null)
        {
            IEnumerable<MetadataReference> references = new[] { MscorlibRef_v4_0_30316_17626, _systemRuntimeRef, _systemObjectModelRef, _windowsRuntimeUIXamlRef, _interopServicesWindowsRuntimeRef, winmd };

            if (additionalRefs != null)
            {
                references = references.Concat(additionalRefs);
            }

            var comp = CreateCompilation("", references, options: TestOptions.ReleaseDll.WithMetadataImportOptions(MetadataImportOptions.All));

            var writer = new StringBuilder();
            AppendAssemblyRefs(writer, (PEAssemblySymbol)comp.GetReferencedAssemblySymbol(winmd));

            AppendMembers(writer, comp.GetReferencedAssemblySymbol(winmd).GlobalNamespace, "");
            return writer.ToString();
        }
コード例 #30
0
ファイル: MinMaxTests.cs プロジェクト: jmhardison/corefx
 public void MaxDecimal()
 {
     var ten = Enumerable.Range(1, 10).Select(i => (decimal)i).ToArray();
     var minusTen = new[] { -100M, -15, -50, -10 };
     var thousand = new[] { -16M, 0, 50, 100, 1000 };
     Assert.Equal(42M, Enumerable.Repeat(42M, 1).Max());
     Assert.Equal(10M, ten.Max());
     Assert.Equal(-10M, minusTen.Max());
     Assert.Equal(1000M, thousand.Max());
     Assert.Equal(decimal.MaxValue, thousand.Concat(Enumerable.Repeat(decimal.MaxValue, 1)).Max());
     Assert.Throws<InvalidOperationException>(() => Enumerable.Empty<decimal>().Max());
 }