本文整理汇总了C#中System.Linq类的典型用法代码示例。如果您正苦于以下问题:C# System.Linq类的具体用法?C# System.Linq怎么用?C# System.Linq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Linq类属于命名空间,在下文中一共展示了System.Linq类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NURBS1
public static void NURBS1()
{
// Draw a simple NURBS
// Example from this page:http://www.robthebloke.org/opengl_programming.html
var page = SampleEnvironment.Application.ActiveDocument.Pages.Add();
var points = new[]
{
new VA.Drawing.Point(10, 10),
new VA.Drawing.Point(5, 10),
new VA.Drawing.Point(-5, 5),
new VA.Drawing.Point(-10, 5),
new VA.Drawing.Point(-4, 10),
new VA.Drawing.Point(-4, 5),
new VA.Drawing.Point(-8, 1)
};
var origin = new VA.Drawing.Point(4, 4);
var scale = new VA.Drawing.Size(1.0/4.0, 1.0/4.0);
var controlpoints = points.Select(x => (x*scale) + origin).ToList();
var knots = new double[] {0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4};
var degree = 3;
var weights = controlpoints.Select(i => 1.0).ToList();
var s0 = page.DrawNURBS(controlpoints, knots, weights, degree);
s0.Text = "Generic NURBS shape";
}
开发者ID:firestream99,项目名称:VisioAutomation,代码行数:29,代码来源:SimpleGeometrySamples.cs
示例2: RuleMethodTest
public void RuleMethodTest()
{
const string expectedName = "Test";
var expectedVariables = new[] { VariableUnitTest.simpleVariable, VariableUnitTest.listVariable };
var statements = new RuleStatementChecker[]
{
new TextRuleStatementChecker( "text" ),
new ValueRuleStatementChecker( "value", " " ),
new TextRuleStatementChecker( "text" ),
};
var ruleMethodStatement = RuleMethodStartToString( expectedName, expectedVariables, ",", "<", ">" ) +
"\r\n" + statements.Select( t => t.Text ).Aggregate( ( s1, s2 ) => s1 + s2 ) +
"\r\n" + "<%end%>";
var actualRuleMethod = ParserHelper.ParseRuleMethod( ruleMethodStatement );
Assert.That( actualRuleMethod.Name, Is.EqualTo( expectedName ) );
AssertHelper.AssertVariables( expectedVariables, actualRuleMethod.Variables );
for (var i = 0; i < statements.Length; i++)
{
var statement = statements[i];
statement.CheckAssert( actualRuleMethod.Statements[i] );
}
}
开发者ID:werwolfby,项目名称:wolfgenerator,代码行数:27,代码来源:RuleMethodUnitTest.cs
示例3: GeoShapeMultiLineString_Deserializes
public void GeoShapeMultiLineString_Deserializes()
{
var coordinates = new[]
{
new[] { new[] { 102.0, 2.0 }, new[] { 103.0, 2.0 }, new[] { 103.0, 3.0 }, new[] { 102.0, 3.0 } },
new[] { new[] { 100.0, 0.0 }, new[] { 101.0, 0.0 }, new[] { 101.0, 1.0 }, new[] { 100.0, 1.0 } },
new[] { new[] { 100.2, 0.2 }, new[] { 100.8, 0.2 }, new[] { 100.8, 0.8 }, new[] { 100.2, 0.8 } }
};
var q = this.SerializeThenDeserialize(
f => f.GeoShape,
f => f.GeoShapeMultiLineString(gq => gq
.OnField(p => p.MyGeoShape)
.Coordinates(coordinates)
)
);
var query = q as IGeoShapeMultiLineStringQuery;
query.Should().NotBeNull();
query.Field.Should().Be("myGeoShape");
query.Shape.Should().NotBeNull();
query.Shape.Type.Should().Be("multilinestring");
query.Shape.Coordinates.SelectMany(c => c.SelectMany(cc => cc)).Should()
.BeEquivalentTo(coordinates.SelectMany(c => c.SelectMany(cc => cc)));
}
开发者ID:BiYiTuan,项目名称:elasticsearch-net,代码行数:25,代码来源:GeoShapeQueryTests.cs
示例4: Test14_1Intersection
public void Test14_1Intersection()
{
var array1 = new[] { 1, 1, 1, 2, 3, 4, 5, 7, 7, 10 };
var array2 = new[] { 1, 1, 2, 2, 3, 4, 6, 7, 9, 9, 10, 11, 11, 25 };
Assert.IsTrue(Enumerable.SequenceEqual(Problem14_1.GetSortedArrayIntersection(array1, array2), Problem14_1.GetSortedArrayIntersection1(array1, array2)));
}
开发者ID:quails4Eva,项目名称:ElementsOfProgrammingInterviews,代码行数:7,代码来源:Test14_1.cs
示例5: CsdlSemanticsNavigationPropertyTests
public CsdlSemanticsNavigationPropertyTests()
{
var constraints = new[] { new CsdlReferentialConstraint("FK", "ID", null, null) };
this.collectionProperty = new CsdlNavigationProperty("Collection", "Collection(FQ.NS.EntityType)", null, "Reference", false, null, constraints, null, null);
this.referenceProperty = new CsdlNavigationProperty("Reference", "FQ.NS.EntityType", false, null, false, null, Enumerable.Empty<CsdlReferentialConstraint>(), null, null);
var navigationWithoutPartner = new CsdlNavigationProperty("WithoutPartner", "FQ.NS.EntityType", false, null, false, null, Enumerable.Empty<CsdlReferentialConstraint>(), null, null);
var idProperty = new CsdlProperty("ID", new CsdlNamedTypeReference("Edm.Int32", false, null), false, null, null, null);
var fkProperty = new CsdlProperty("FK", new CsdlNamedTypeReference("Edm.Int32", false, null), false, null, null, null);
this.csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, new CsdlKey(new[] { new CsdlPropertyReference("ID", null) }, null), new[] { idProperty, fkProperty }, new[] { collectionProperty, referenceProperty, navigationWithoutPartner }, null, null);
var csdlSchema = new CsdlSchema("FQ.NS", null, null, new[] { this.csdlEntityType }, Enumerable.Empty<CsdlEnumType>(), Enumerable.Empty<CsdlOperation>(),Enumerable.Empty<CsdlTerm>(),Enumerable.Empty<CsdlEntityContainer>(),Enumerable.Empty<CsdlAnnotations>(), Enumerable.Empty<CsdlTypeDefinition>(), null, null);
var csdlModel = new CsdlModel();
csdlModel.AddSchema(csdlSchema);
var semanticModel = new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty<IEdmModel>());
this.semanticEntityType = semanticModel.FindType("FQ.NS.EntityType") as CsdlSemanticsEntityTypeDefinition;
this.semanticEntityType.Should().NotBeNull();
this.semanticCollectionNavigation = this.semanticEntityType.FindProperty("Collection") as CsdlSemanticsNavigationProperty;
this.semanticReferenceNavigation = this.semanticEntityType.FindProperty("Reference") as CsdlSemanticsNavigationProperty;
this.semanticNavigationWithoutPartner = this.semanticEntityType.FindProperty("WithoutPartner") as CsdlSemanticsNavigationProperty;
this.semanticCollectionNavigation.Should().NotBeNull();
this.semanticReferenceNavigation.Should().NotBeNull();
this.semanticNavigationWithoutPartner.Should().NotBeNull();
}
开发者ID:larsenjo,项目名称:odata.net,代码行数:29,代码来源:CsdlSemanticsNavigationPropertyTests.cs
示例6: StartsWith_Remote
public void StartsWith_Remote()
{
using (var store = NewRemoteDocumentStore())
{
var names = new[]
{
"user/aaaaaa/foo a/bar",
"user/aaaaaa/foo b/bar",
"user/aaaaaa/foo-c/bar",
"user/aaaaaa/foo d/bar",
"user/aaaaaa/foo e/bar",
"user/bazbar/foo1/baz",
"user/bazbar/foo2/baz",
"user/bazbar/foo3/baz",
"user/bazbar/foo4/baz",
"user/bazbar/foo5/baz"
};
using (var session = store.OpenSession())
{
foreach (var name in names)
{
session.Store(new object(), name);
}
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var objects = session.Advanced.LoadStartingWith<object>(keyPrefix: "user/");
Assert.Equal(objects.Length, names.Length);
}
}
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:34,代码来源:Marisic.cs
示例7: GetBounds
public Rectangle2D GetBounds()
{
float ymin = 0;
float xmin = 0;
float xmax = this.Viewport.Width;
float ymax = this.Viewport.Height;
var matrix = Matrix.Invert(this.GetMatrix() * SpriteBatchExtensions.GetUndoMatrix(this.Viewport));
var corners = new[]
{
new Vector2(xmin, ymin),
new Vector2(xmax, ymin),
new Vector2(xmin, ymax),
new Vector2(xmax, ymax),
};
var vectors = corners.Select(x => Vector2.Transform(x, matrix)).ToList();
xmin = vectors.Min(x => x.X);
xmax = vectors.Max(x => x.X);
ymin = vectors.Min(x => x.Y);
ymax = vectors.Max(x => x.Y);
return new Rectangle2D(xmin, xmax, ymax, ymin);
}
开发者ID:AndrewHackler,项目名称:shooter,代码行数:26,代码来源:Perspective.cs
示例8: GetData
public object GetData(int lotId, string path)
{
Lot lot = this.lotRepository.GetLotIndex(lotId);
AircraftDataDO aircraftData = lot.Index.GetPart<AircraftDataDO>("aircraftData").Content;
AircraftCertAirworthinessDO airworthinessData = lot.Index.GetPart<AircraftCertAirworthinessDO>(path).Content;
string regPath = string.Format("aircraftCertRegistrationsFM/{0}", airworthinessData.Registration.NomValueId);
AircraftCertRegistrationFMDO registration = lot.Index.GetPart<AircraftCertRegistrationFMDO>(regPath).Content;
var json = new
{
root = new
{
REG_MARK = registration != null ? registration.RegMark : null,
PRODUCER_ALT = aircraftData.AircraftProducer != null ? aircraftData.AircraftProducer.NameAlt: null,
PRODUCER_DESIGNATION_ALT = aircraftData.ModelAlt,
PRODUCER = aircraftData.AircraftProducer != null ? aircraftData.AircraftProducer.Name : null,
PRODUCER_DESIGNATION = aircraftData.Model,
AIR_CATEGORY = aircraftData.AirCategory != null ? aircraftData.AirCategory.Name : null,
REF_NUMBER = airworthinessData.DocumentNumber,
MSN = aircraftData.ManSN,
}
};
return json;
}
开发者ID:MartinBG,项目名称:Gva,代码行数:25,代码来源:Form15a.cs
示例9: TestWithProvidedExample
public void TestWithProvidedExample()
{
var universe = new[] { 1, 3, 5, 7, 9, 11, 20, 30, 40 };
var sets = new[]
{
new[] { 20 },
new[] { 1, 5, 20, 30 },
new[] { 3, 7, 20, 30, 40 },
new[] { 9, 30 },
new[] { 11, 20, 30, 40 },
new[] { 3, 7, 40 }
};
var selectedSets = SetCover.ChooseSets(sets.ToList(), universe.ToList());
var expectedResult = new[]
{
sets[2],
sets[1],
sets[3],
sets[4]
};
CollectionAssert.AreEqual(expectedResult, selectedSets);
}
开发者ID:EBojilova,项目名称:Algorithms-CSharp,代码行数:25,代码来源:SetCoverTests.cs
示例10: CorrectReferenceToNewCssFile
public void CorrectReferenceToNewCssFile()
{
var testData = new[]
{
"<html>",
" <head>",
" <style type=\"text/css\">",
" body{float:left;}",
" </style>",
" </head>",
" <body>",
" <div>some text</div>",
" <body>",
"</html>"
};
var result = Run(testData);
Assert.AreEqual("<html>", result.StripedContent[0]);
Assert.AreEqual(" <head>", result.StripedContent[1]);
Assert.AreEqual("<link href=\"~/Content/BlockCss/Search/LoggingResultGrid.css\" rel=\"stylesheet\" />", result.StripedContent[2]);
Assert.AreEqual(" </head>", result.StripedContent[3]);
Assert.AreEqual(" <body>", result.StripedContent[4]);
Assert.AreEqual(" <div>some text</div>", result.StripedContent[5]);
Assert.AreEqual(" <body>", result.StripedContent[6]);
Assert.AreEqual("</html>", result.StripedContent[7]);
}
开发者ID:nathanmurados,项目名称:MetricsEvaluator,代码行数:27,代码来源:PageCssSeperationEvaluatorTests.cs
示例11: SetAlias
private void SetAlias(string nextIndex, string alias)
{
var indicesForAlias = _client.GetIndicesPointingToAlias(Settings.Alias).ToList();
var newIndices = new[] {nextIndex};
_client = new ElasticClientWrapper();
_client.Swap(alias, indicesForAlias, newIndices);
}
开发者ID:necroscope,项目名称:NestDemo,代码行数:7,代码来源:PostEndpoint.cs
示例12: ClassifyComplexCodeSnippet
public void ClassifyComplexCodeSnippet()
{
SetText("function foo() { var s = 's'; }");
var expected = new[]
{
Keyword(0, 8),
WhiteSpace(8, 1),
Identifier(9, 3),
Punctuation(12, 2),
WhiteSpace(14, 1),
Punctuation(15, 1),
WhiteSpace(16, 1),
Keyword(17, 3),
WhiteSpace(20, 1),
Identifier(21, 1),
WhiteSpace(22, 1),
Operator(23, 1),
WhiteSpace(24, 1),
String(25, 3),
Punctuation(28, 1),
WhiteSpace(29, 1),
Punctuation(30, 1)
};
AssertClassificationsOf(TextLine(0), expected);
}
开发者ID:madsnyholm,项目名称:CodeEditor,代码行数:25,代码来源:UnityScriptClassifierTest.cs
示例13: EDamage
private static float EDamage(Obj_AI_Base target)
{
if (target.IsMinion || target.IsMonster)
{
int stacksMin = GetMinionStacks(target);
var indexMin = Program.E.Level - 1;
var EDamageMinion = new float[] { 20, 30, 40, 50, 60 }[indexMin] + (0.6 * ObjectManager.Player.TotalAttackDamage);
if (stacksMin > 1)
{
EDamageMinion += ((new float[] { 10, 14, 19, 25, 32 }[indexMin] + (new float[] { 0.2f, 0.225f, 0.25f, 0.275f, 0.3f }[indexMin] * ObjectManager.Player.TotalAttackDamage)) * (stacksMin - 1));
}
return ObjectManager.Player.CalculateDamageOnUnit(target, DamageType.Physical, (float)EDamageMinion) * 0.9f;
}
else
{
if (GetStacks(target) == 0) return 0;
int stacksChamps = GetStacks(target);
var indexChamp = Program.E.Level - 1;
var EDamageChamp = new[] { 0, 20, 30, 40, 50, 60 }[indexChamp] + (0.6 * ObjectManager.Player.TotalAttackDamage);
if (stacksChamps > 1)
{
EDamageChamp += ((new[] { 0, 10, 14, 19, 25, 32 }[indexChamp] + (new[] { 0, 0.2, 0.225, 0.25, 0.275, 0.3 }[indexChamp] * ObjectManager.Player.TotalAttackDamage)) * (stacksChamps - 1));
}
return ObjectManager.Player.CalculateDamageOnUnit(target, DamageType.Physical, (float)EDamageChamp);
}
}
开发者ID:yashine59fr,项目名称:PortAIO,代码行数:33,代码来源:Damage.cs
示例14: LoadGrid
public ActionResult LoadGrid()
{
var result = this.students.GetAllStudents().ToList();
var jsonData = new
{
total = 1,
page = 1,
records = result.Count,
rows = (
from item in result
select new
{
id = item.Id,
cell = new string[]
{
item.FirstName,
item.LastName,
item.Course.ToString(),
item.GroupNumber.ToString(),
item.FacultyName,
item.Room?.RoomName,
item.Room?.Floor.FloorNumber.ToString(),
item.Room?.Floor.Building.Name
}
}).ToArray()
};
return this.Json(jsonData, JsonRequestBehavior.AllowGet);
}
开发者ID:vlad-sp,项目名称:CampusSystem,代码行数:30,代码来源:StudentController.cs
示例15: CorrectMultipleBoostTestDiscovererDispatchingNoExternal
public void CorrectMultipleBoostTestDiscovererDispatchingNoExternal()
{
var sources = new[]
{
"ListContentSupport" + BoostTestDiscoverer.ExeExtension,
"ParseSources1" + BoostTestDiscoverer.ExeExtension,
"ParseSources2" + BoostTestDiscoverer.ExeExtension,
"DllProject1" + BoostTestDiscoverer.DllExtension,
"DllProject2" + BoostTestDiscoverer.DllExtension,
};
var results = this.DiscovererFactory.GetDiscoverers(sources, CreateAdapterSettings());
Assert.That(results.Count(), Is.EqualTo(2));
Assert.That(results.FirstOrDefault(x => x.Discoverer is ListContentDiscoverer), Is.Not.Null);
var lcd = results.First(x => x.Discoverer is ListContentDiscoverer);
Assert.That(lcd.Sources, Is.EqualTo(new[] { "ListContentSupport" + BoostTestDiscoverer.ExeExtension }));
Assert.That(results.FirstOrDefault(x => x.Discoverer is SourceCodeDiscoverer), Is.Not.Null);
var scd = results.First(x => x.Discoverer is SourceCodeDiscoverer);
Assert.That(scd.Sources, Is.EqualTo(new[] { "ParseSources1" + BoostTestDiscoverer.ExeExtension,
"ParseSources2" + BoostTestDiscoverer.ExeExtension }));
Assert.That(results.FirstOrDefault(x => x.Sources.Contains("DllProject1" + BoostTestDiscoverer.DllExtension)), Is.Null);
Assert.That(results.FirstOrDefault(x => x.Sources.Contains("DllProject2" + BoostTestDiscoverer.DllExtension)), Is.Null);
}
开发者ID:Flamefire,项目名称:vs-boost-unit-test-adapter,代码行数:26,代码来源:BoostTestDiscovererFactoryTest.cs
示例16: When_laird_is_defeated_then_all_kobolds_in_hall_are_defeated
public void When_laird_is_defeated_then_all_kobolds_in_hall_are_defeated()
{
// Arrange
var context = new TestContext();
var player = context.Player;
var laird = context.CreateCard<KoboldHumanoid>("Drakeclan Laird");
var ambusher = context.CreateCard<KoboldHumanoid>("Drakeclan Ambusher");
var cutter = context.CreateCard<KoboldHumanoid>("Drakeclan Cutter");
var shaman = context.CreateCard<KoboldHumanoid>("Drakeclan Shaman");
var kobolds = new[] {laird, ambusher, cutter, shaman};
context.SetTopOfDungeonDeck(kobolds);
context.AdvanceMonsterToFirstRank(laird);
var hand = Enumerable.Range(0, 6).Select(x => context.CreateCard<Criochan>("Criochan Captain")).ToArray();
context.SetPlayerHand(hand);
var startingXp = player.Xp;
var startingVp = player.Vp;
// Act
context.WhenBattling(laird);
player.DetermineBattleResult();
// Assert
kobolds.Each(x => Assert.That(player.Discard.Contains(x), "Discard does not contain {0}".Template(x.Name)));
context.Game.Dungeon.Ranks.Each(r=> Assert.That(r.Card, Is.Not.Null, "Rank {0} is empty".Template(r.Number)));
kobolds.Each(x => Assert.That(context.Game.Dungeon.Ranks.All(rank => rank.Card != x)));
Assert.That(player.Xp, Is.EqualTo(startingXp + laird.Xp));
Assert.That(player.Vp, Is.EqualTo(startingVp + kobolds.Sum(x => x.Vp)));
}
开发者ID:Slugburn,项目名称:Thunderstone,代码行数:28,代码来源:KoboldHumanoidTest.cs
示例17: Render
public void Render(GraphicsBuffer buffer)
{
var pattern = new[]
{
scheme.Base,
scheme.Light,
scheme.Lighter,
scheme.Light,
scheme.Base
};
foreach (var index in Enumerable.Range(0, pattern.Length))
buffer.DrawFrame(
topRow + index,
leftColumn + index,
width - 2 * index,
height - 2 * index,
pattern[index]);
buffer.DrawBackground(
background,
topRow + pattern.Length,
leftColumn + pattern.Length,
width - 2 * pattern.Length,
height - 2 * pattern.Length,
paletteIndex);
}
开发者ID:jmfb,项目名称:XComGenerations,代码行数:25,代码来源:Border.cs
示例18: GetSensorTable
public object GetSensorTable(HttpRequestParams request)
{
using (var session = Context.OpenSession())
{
var info = new
{
host = MqttPlugin.Host,
port = MqttPlugin.Port,
path = MqttPlugin.Path
};
var messages = session
.Query<ReceivedData>()
.OrderBy(m => m.Path)
.Select(m => new
{
id = m.Id,
path = m.Path,
message = m.Message,
timestamp = m.Timestamp
}).ToList();
return new { info, messages };
}
}
开发者ID:hokilpet,项目名称:thinking-home,代码行数:25,代码来源:MqttUiPlugin.cs
示例19: Execute
public void Execute()
{
//
// Take拡張メソッドは、シーケンスの先頭から指定された件数分を返すメソッド。
//
// ・シーケンスの要素数より多い数を指定した場合、そのシーケンス全てが返る.
// ・0以下の値を指定した場合、空のシーケンスが返る.
//
var names = new[] {"gsf_zero1", "gsf_zero2", "gsf_zero3", "gsf_zero4", "gsf_zero5"};
Output.WriteLine("================ Take ======================");
var top3 = names.Take(3);
foreach (var item in top3)
{
Output.WriteLine(item);
}
foreach (var item in names.Take(20))
{
Output.WriteLine(item);
}
Output.WriteLine("0以下の数値を指定: COUNT={0}", names.Take(-1).Count());
//
// TakeWhile拡張メソッドは、指定された条件が満たされる間シーケンスから要素を抽出し
// 返すメソッド。
//
Output.WriteLine("================ TakeWhile ======================");
var lessThan4 = names.TakeWhile(name => int.Parse(name.Last().ToString()) <= 4);
foreach (var item in lessThan4)
{
Output.WriteLine(item);
}
}
开发者ID:devlights,项目名称:Sazare,代码行数:35,代码来源:LinqSamples43.cs
示例20: Test1Number
public void Test1Number()
{
var sequence = new[] { 5 };
var expectedSeq = new[] { 5 };
var actualSeq = LongestIncreasingSubsequence.FindLongestIncreasingSubsequence(sequence);
CollectionAssert.AreEqual(expectedSeq, actualSeq);
}
开发者ID:iliankostov,项目名称:Algorithms,代码行数:7,代码来源:LongestIncreasingSubsequenceTests.cs
注:本文中的System.Linq类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论