当前位置: 首页>>代码示例>>C#>>正文


C# System.Cast方法代码示例

本文整理汇总了C#中System.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# System.Cast方法的具体用法?C# System.Cast怎么用?C# System.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System的用法示例。


在下文中一共展示了System.Cast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertSeparators

        private IEnumerable<object> InsertSeparators( System.Collections.IEnumerable a, string sSeparator )
        {
            if ( a.Cast<object> ( ).Any ( ) )
            {
                yield return a.Cast<object> ( ).First ( );

                foreach ( var o in a.Cast<object> ( ).Skip ( 1 ) )
                {
                    yield return sSeparator;
                    yield return o;
                }
            }
        }
开发者ID:bl0rq,项目名称:Utilis,代码行数:13,代码来源:List.cs

示例2: ShowUsingMapView

        public void ShowUsingMapView()
        {
            var points = new[,]
                             {
                                 {new Point(0, 0), new Point(1, 0), new Point(2, 0)}, 
                                 {new Point(0, 1), new Point(1, 1), new Point(2, 1)}, 
                             };

            var coverage = new DiscreteGridPointCoverage(2, 3, points.Cast<IPoint>());

            var values = new[,]
                             {
                                 {1.0, 2.0},
                                 {3.0, 4.0},
                                 {5.0, 6.0}
                             };

            coverage.SetValues(values);

            var coverageLayer = new DiscreteGridPointCoverageLayer {Coverage = coverage};

            var map = new Map {Layers = {coverageLayer}};

            MapTestHelper.ShowModal(map);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:DiscreteGridPointCoverageLayerTest.cs

示例3: Inbox_support_queueing_multiple_queries

        public void Inbox_support_queueing_multiple_queries()
        {
            var tasks = new[]
                {
                    Task.Factory.StartNew(() => _inbox.Receive()),
                    Task.Factory.StartNew(() =>
                    {
                        Thread.Sleep(100);
                        return _inbox.ReceiveWhere(x => x.ToString() == "world"); 
                    }), 
                    Task.Factory.StartNew(() =>
                    {
                        Thread.Sleep(200);
                        return _inbox.ReceiveWhere(x => x.ToString() == "hello"); 
                    }) 
                };

            _inbox.Receiver.Tell(42);
            _inbox.Receiver.Tell("hello");
            _inbox.Receiver.Tell("world");

            Task.WaitAll(tasks.Cast<Task>().ToArray());

            tasks[0].Result.ShouldBe(42);
            tasks[1].Result.ShouldBe("world");
            tasks[2].Result.ShouldBe("hello");
        }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:27,代码来源:InboxSpec.cs

示例4: CommandComputer

        public CommandComputer(System.Collections.IList iList)
        {
            // TODO: Complete member initialization

            this.clients = (List<ClientThread>)iList.Cast<ClientThread>().ToList() ;
            InitializeComponent();
        }
开发者ID:GavinKenna,项目名称:Muroidea,代码行数:7,代码来源:CommandComputer.cs

示例5: FillControls

 public static void FillControls(Dictionary<string, string> collection, System.Windows.Forms.Control.ControlCollection controls)
 {
     foreach (Control control in controls.Cast<Control>().Where(y => y.Tag != null).OrderBy(y => y.TabIndex))
     {
         FillControl(collection, control);
     }
 }
开发者ID:smgtreker,项目名称:FetchXMLBuilder,代码行数:7,代码来源:ControlUtils.cs

示例6: ShowUsingMapViewWhereValuesContainNoDataValue

        public void ShowUsingMapViewWhereValuesContainNoDataValue()
        {
            var points = new[,]
                             {
                                 {new Point(0, 0), new Point(1, 0)},
                                 {new Point(2, 1), new Point(3, 1.5)},
                                 {new Point(1, 2), new Point(3, 3)}
                             };

            var coverage = new DiscreteGridPointCoverage(2, 3, points.Cast<IPoint>());

            var values = new[,]
                             {
                                 {1.0, 2.0},
                                 {3.0, 4.0},
                                 {5.0, -999.0}
                             };

            coverage.Components[0].NoDataValues = new [] {-999.0};
            
            coverage.SetValues(values);

            var coverageLayer = new DiscreteGridPointCoverageLayer { Coverage = coverage };

            var map = new Map { Layers = { coverageLayer } };

            MapTestHelper.ShowModal(map);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:DiscreteGridPointCoverageLayerTest.cs

示例7: CallsMemberGenerators

 public void CallsMemberGenerators()
 {
     var spies = new[]{new SpyGenerator(), new SpyGenerator()};
     var memberGenerators = spies.Cast<CodeGeneratorBase>().ToArray();
     Generator = new NamespaceGenerator(Configuration, memberGenerators);
     Generator.Generate(compileUnit, ContentType);
     Assert.That(spies.All(s => s.Called));
 }
开发者ID:scy0846,项目名称:Umbraco.CodeGen,代码行数:8,代码来源:NamespaceGeneratorTests.cs

示例8: WhenAnyWeightsArrayElementDoesNotPointToArray_Throw

 public void WhenAnyWeightsArrayElementDoesNotPointToArray_Throw()
 {
     var array1 = new[] { 1.1, 1.2 };
     ExcelFunctions.MakeArray("array1", array1.Cast<object>().ToArray());
     Action action = () => ExcelFunctions.MakeWeights("weights", new object[] {"array1", "array2"});
     action.ShouldThrow<NNXException>()
         .WithMessage("*Element at index 2 ('array2') does not point to a valid array of numbers.*");
 }
开发者ID:ikhramts,项目名称:NNX,代码行数:8,代码来源:MakeWeightsTests.cs

示例9: Write

		public bool Write(System.Collections.Generic.IEnumerable<char> buffer)
		{
			return this.backend.Write(buffer.Cast(c =>
			{
				this.OnWrite.Call(c);
				return c;
			}));
		}
开发者ID:imintsystems,项目名称:Kean,代码行数:8,代码来源:CharacterDevice.cs

示例10: SelectAllItems

		public void SelectAllItems(System.ComponentModel.ICollectionView availableItemsCollectionView)
		{
			IList<Property> itemsList = new List<Property>(availableItemsCollectionView.Cast<Property>());
			foreach (Property obj in itemsList)
			{
				SelectItem(obj);
			}
		}
开发者ID:karpinskiy,项目名称:vc-community,代码行数:8,代码来源:PropertySetViewModel.cs

示例11: WhenAnyWeightsArrayElementIsNotDoubleArray_Throw

 public void WhenAnyWeightsArrayElementIsNotDoubleArray_Throw(object bad)
 {
     var array1 = new[] { 1.1, 1.2 };
     ExcelFunctions.MakeArray("array1", array1.Cast<object>().ToArray());
     ObjectStore.Add("bad", bad);
     Action action = () => ExcelFunctions.MakeWeights("weights", new object[] { "array1", "bad" });
     action.ShouldThrow<NNXException>()
         .WithMessage("*Element at index 2 ('bad') does not point to a valid array of numbers.*");
 }
开发者ID:ikhramts,项目名称:NNX,代码行数:9,代码来源:MakeWeightsTests.cs

示例12: ShouldReturnObjectName

 public void ShouldReturnObjectName()
 {
     var array1 = new[] { 1.1, 1.2 };
     var array2 = new[] { 2.1, 2.2, 2.3 };
     ExcelFunctions.MakeArray("array1", array1.Cast<object>().ToArray());
     ExcelFunctions.MakeArray("array2", array2.Cast<object>().ToArray());
     var name = ExcelFunctions.MakeWeights("weights", new object[] { "array1", "array2" });
     name.Should().Be("weights");
 }
开发者ID:ikhramts,项目名称:NNX,代码行数:9,代码来源:MakeWeightsTests.cs

示例13: GetCacheDependency

        public override System.Web.Caching.CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
        {
            if (virtualPathDependencies == null)
            {
                return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
            }

            return Previous.GetCacheDependency(virtualPath, virtualPathDependencies.Cast<string>().Where(vp => GetCompiledType(vp) == null), utcStart);
        }
开发者ID:pleb,项目名称:Chillow,代码行数:9,代码来源:CompiledVirtualPathProvider.cs

示例14: SpecificationsMatchesConstructorSpecifications

 public void SpecificationsMatchesConstructorSpecifications()
 {
     // Fixture setup
     var expectedSpecifications = new[] { new DelegatingRequestSpecification(), new DelegatingRequestSpecification(), new DelegatingRequestSpecification() };
     var sut = new AndRequestSpecification(expectedSpecifications.Cast<IRequestSpecification>());
     // Exercise system
     IEnumerable<IRequestSpecification> result = sut.Specifications;
     // Verify outcome
     Assert.True(expectedSpecifications.SequenceEqual(result));
     // Teardown
 }
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:11,代码来源:AndRequestSpecificationTest.cs

示例15: WhenGivenArrayList_ShouldMakeWeights

        public void WhenGivenArrayList_ShouldMakeWeights()
        {
            var array1 = new[] {1.1, 1.2};
            var array2 = new[] {2.1, 2.2, 2.3};
            ExcelFunctions.MakeArray("array1", array1.Cast<object>().ToArray());
            ExcelFunctions.MakeArray("array2", array2.Cast<object>().ToArray());
            ExcelFunctions.MakeWeights("weights", new object[] {"array1", "array2"});

            var result = ObjectStore.Get<double[][]>("weights");
            result.Should().HaveCount(2);
            result[0].Should().Equal(array1);
            result[1].Should().Equal(array2);
        }
开发者ID:ikhramts,项目名称:NNX,代码行数:13,代码来源:MakeWeightsTests.cs


注:本文中的System.Cast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。