本文整理汇总了C#中IEnumerable.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.ToArray方法的具体用法?C# IEnumerable.ToArray怎么用?C# IEnumerable.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public string Build(BundleType type, IEnumerable<string> files)
{
if (files == null || !files.Any())
return string.Empty;
string bundleVirtualPath = this.GetBundleVirtualPath(type, files);
var bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
if (bundleFor == null)
{
lock (s_lock)
{
bundleFor = BundleTable.Bundles.GetBundleFor(bundleVirtualPath);
if (bundleFor == null)
{
var nullOrderer = new NullOrderer();
Bundle bundle = (type == BundleType.Script) ?
new CustomScriptBundle(bundleVirtualPath) as Bundle :
new SmartStyleBundle(bundleVirtualPath) as Bundle;
bundle.Orderer = nullOrderer;
bundle.Include(files.ToArray());
BundleTable.Bundles.Add(bundle);
}
}
}
if (type == BundleType.Script)
return Scripts.Render(bundleVirtualPath).ToString();
return Styles.Render(bundleVirtualPath).ToString();
}
示例2: VertexArray
public VertexArray(IOpenGL30 gl, IEnumerable<IVertexBuffer> buffers, IEnumerable<IVertexDescriptor> descriptors)
{
IVertexBuffer[] bufferObjects = buffers.ToArray();
IVertexDescriptor[] descs = descriptors.ToArray();
if (descs.Length != bufferObjects.Length)
throw new InvalidOperationException("Number of buffers and number of descriptors must match.");
uint[] handles = new uint[1];
gl.GenVertexArrays(1, handles);
if(handles[0] == 0u)
throw new NoHandleCreatedException();
_gl = gl;
Handle = handles.Single();
Buffers = bufferObjects;
using (Bind())
{
int count = 0;
for (int index = 0; index < bufferObjects.Length; index++)
{
var buffer = bufferObjects[index];
var desc = descs[index];
buffer.Bind();
Apply(desc, count);
count += desc.Elements.Count();
}
}
}
示例3: ManaMismatchException
public ManaMismatchException(GameCard card, Player player, IEnumerable<Mana> mana)
: base("Error: " + player + " attempted to cast " + card + " with " + mana.ToArray() + ".")
{
this.card = card;
this.player = player;
this.mana = mana.ToArray();
}
示例4: GetAssemblyNames
GetAssemblyNames(IEnumerable<string> filenames, Predicate<Assembly> filter)
{
#if PCL
throw new NotImplementedException();
#else
#if !WINRT
var assemblyCheckerType = typeof(AssemblyChecker);
var temporaryDomain = CreateTemporaryAppDomain();
try
{
var checker = (AssemblyChecker)temporaryDomain.CreateInstanceAndUnwrap(
assemblyCheckerType.Assembly.FullName,
assemblyCheckerType.FullName ?? string.Empty);
return checker.GetAssemblyNames(filenames.ToArray(), filter);
#else
var checker = new AssemblyCheckerWinRT();
return checker.GetAssemblyListAsync(filenames.ToArray(), filter);
#endif
#if !WINRT
}
finally
{
AppDomain.Unload(temporaryDomain);
}
#endif
#endif
}
示例5: CrateJudgmentTree
public static JudgmentModel CrateJudgmentTree(JudgmentModel judgmentModel, IEnumerable<Property> properties, IEnumerable<Mark> marks)
{
for (Int32 i = 0; i < properties.Count() - 1; i++)
{
MarkOfPropertyModel shortInventoryObjectModel = new MarkOfPropertyModel
{
PropertyId = properties.ToArray()[i].Id,
PropertyName = properties.ToArray()[i].Name,
Objects = new List<MarkOfPropertyModel>()
};
for (var j = i + 1; j < properties.Count(); j++)
{
shortInventoryObjectModel.Objects.Add(new MarkOfPropertyModel
{
PropertyId = properties.ToArray()[j].Id,
PropertyName = properties.ToArray()[j].Name,
Mark = marks.First(m => m.IsDefault).Id
});
}
judgmentModel.Objects.Add(shortInventoryObjectModel);
}
return judgmentModel;
}
示例6: Delete
public int Delete(IEnumerable<int> Ids)
{
int num = _database.Execute("Delete from Terms where Id in (" + string.Join(",", Ids.ToArray()) + ")", new Dictionary<string, object>());
_database.Execute("Delete from UserTerms where TermId in (" + string.Join(",", Ids.ToArray()) + ")", new Dictionary<string, object>());
_database.Execute("Delete from GroupTerms where TermId in (" + string.Join(",", Ids.ToArray()) + ")", new Dictionary<string, object>());
return num;
}
示例7: DoWork
public override void DoWork(IEnumerable<string> args)
{
if (Utils.CheckArgs(ArgsNeed, args.Count()))
{
if (Utils.IsInGame())
{
var request = new MoveRequest
{
From = args.ToArray()[0],
To = args.ToArray()[1],
InWhom = null,
Player = CurrentUser.Name,
GameId = CurrentUser.CurrentGame.Value
};
var response = ServerProvider.MakeRequest(request);
switch (response.Status)
{
case Statuses.Ok:
Console.WriteLine("Move done.");
CurrentUser.LastMove = new Move
{
From = request.From,
InWhom = null,
Player = CurrentUser.Name,
To = request.To
};
break;
case Statuses.NeedPawnPromotion:
Utils.Print("This pawn need promotion!");
Utils.Print("Your choise? (r - rook, n - knight, b - bishop, q - queen, c - cancel):");
CurrentUser.LastMove = new Move
{
From = request.From,
InWhom = null,
Player = CurrentUser.Name,
To = request.To
};
CurrentUser.NeedPawnPromotion = true;
break;
case Statuses.NoUser:
Console.WriteLine("No opponent yet.");
break;
case Statuses.OpponentTurn:
Console.WriteLine("Now is opponent turn.");
break;
case Statuses.WrongMove:
Console.WriteLine("Wrong move.");
break;
case Statuses.WrongMoveNotation:
Console.WriteLine("Wrong move notation.");
break;
default:
Console.WriteLine("Wrong status.");
break;
}
}
}
}
示例8: RegisterOperatorsForType
public void RegisterOperatorsForType(Type type, IEnumerable<Operator> possibleOperators) {
if (type == null) throw new ArgumentNullException("type");
if (_opmap.ContainsKey(type))
_opmap[type] = possibleOperators.ToArray();
else
_opmap.Add(type, possibleOperators.ToArray());
}
示例9: PreprocessLines
private IEnumerable<ScenarioLine> PreprocessLines(IEnumerable<ScenarioLine> lines, IEnumerable<string> fieldNames,
IEnumerable<string> example)
{
foreach (var line in lines)
{
var processed = line.Text;
for (var fieldIndex = 0; fieldIndex < fieldNames.ToArray().Length; fieldIndex++)
{
var name = fieldNames.ToArray()[fieldIndex];
processed = processed.Replace("<" + name + ">", example.ElementAtOrDefault(fieldIndex));
}
yield return new ScenarioLine {Text = processed, LineNumber = line.LineNumber};
}
}
示例10: GetXMktSpreads
internal static List<BondStructureOTRCreator> GetXMktSpreads(IEnumerable<BondMarket> markets_, int index_ = -1)
{
var ret = new List<BondStructureOTRCreator>();
var markets = markets_.ToArray();
for (int i = 0; i < markets.Length; ++i)
for (int j = i + 1; j < markets.Length; ++j)
{
// James needs to supply the order of convention to make this accurage
var higherTenor = markets[i];
var lowerTenor = markets[j];
if (index_ == -1)
{
ret.AddRange(StructureConfigs.InterCountrySpreadPoints.Select(conf => new BondStructureOTRCreator(new[]
{
new Tuple<int, BondMarket, double>(conf[0], higherTenor, StructureWeightings.Curve_Near),
new Tuple<int, BondMarket, double>(conf[0], lowerTenor, StructureWeightings.Curve_Far)
})));
}
else
{
ret.Add(new BondStructureOTRCreator(new[]
{
new Tuple<int,BondMarket,double>(StructureConfigs.InterCountrySpreadPoints[index_][0],higherTenor,StructureWeightings.Curve_Near),
new Tuple<int,BondMarket,double>(StructureConfigs.InterCountrySpreadPoints[index_][0],lowerTenor,StructureWeightings.Curve_Far)
}));
}
}
return ret;
}
示例11: SaveAssemblies
/// <summary>
/// Saves all assemblies and returns true if all assemblies were saved to disk
/// </summary>
/// <param name="asms">All assemblies to save</param>
/// <returns></returns>
public static bool SaveAssemblies(IEnumerable<LoadedAssembly> asms)
{
var asmsAry = asms.ToArray();
if (asmsAry.Length == 0)
return true;
if (asmsAry.Length == 1) {
var optsData = new SaveModuleOptionsVM(asmsAry[0].ModuleDefinition);
var optsWin = new SaveModuleOptions();
optsWin.Owner = MainWindow.Instance;
optsWin.DataContext = optsData;
var res = optsWin.ShowDialog();
if (res != true)
return false;
var data = new SaveMultiModuleVM(optsData);
var win = new SaveSingleModule();
win.Owner = MainWindow.Instance;
win.DataContext = data;
data.Save();
win.ShowDialog();
return MarkAsSaved(data, asmsAry);
}
else {
var data = new SaveMultiModuleVM(asmsAry.Select(a => a.ModuleDefinition));
var win = new SaveMultiModule();
win.Owner = MainWindow.Instance;
win.DataContext = data;
win.ShowDialog();
return MarkAsSaved(data, asmsAry);
}
}
示例12: Context
public Context(MethodCall methodCall, IEnumerable<Step> steps)
{
Guard.AgainstNullArgument("steps", steps);
this.methodCall = methodCall;
this.steps = steps.ToArray();
}
示例13: solve
public static double solve (bool isFine, IEnumerable<Constraint> cons)
{
var constraints = cons.ToArray ();
// Get the parameters that need solving by selecting "free" ones
Parameter[] x = constraints.SelectMany (p=>p)
.Distinct ()
.Where(p=>p.free==true)
.ToArray ();
Console.WriteLine ("Number of free vars is " + x.Length);
// Wrap our constraint error function for Accord.NET
Func<double[], double> objective = args => {
int i = 0;
foreach (var arg in args) {
x [i].Value = arg;
i++;
}
return Constraint.calc (constraints);
};
var nlConstraints = new List<NonlinearConstraint> ();
// Finally, we create the non-linear programming solver
var solver = new AugmentedLagrangianSolver(x.Length, nlConstraints);
// Copy in the initial conditions
x.Select(v=>v.Value).ToArray().CopyTo (solver.Solution,0);
// And attempt to solve the problem
return solver.Minimize(LogWrap(objective), LogWrap(Grad(x.Length, objective)));
}
示例14: Get
/// <summary>
/// Gets the <see cref="Type" /> matching the provided members.
/// </summary>
/// <param name="sourceType">The <see cref="Type" /> to generate the runtime type from.</param>
/// <param name="properties">The <see cref="MemberInfo" /> to use to generate properties.</param>
/// <returns>A <see cref="Type" /> mathing the provided properties.</returns>
public Type Get(Type sourceType, IEnumerable<MemberInfo> properties)
{
properties = properties.ToArray();
if (!properties.Any())
{
throw new ArgumentOutOfRangeException("properties",
"properties must have at least 1 property definition");
}
var dictionary = properties.ToDictionary(f => _nameResolver.ResolveName(f), memberInfo => memberInfo);
var className = GetTypeKey(sourceType, dictionary);
return BuiltTypes.GetOrAdd(
className,
s =>
{
var typeBuilder = ModuleBuilder.DefineType(
className,
TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Serializable);
Contract.Assume(typeBuilder != null);
SetAttributes(typeBuilder, sourceType);
foreach (var field in dictionary)
{
CreateProperty(typeBuilder, field);
}
return typeBuilder.CreateType();
});
}
示例15: OnLanguageCreated
public void OnLanguageCreated(IEnumerable<Language> languages)
{
if (languages != null)
{
OnLanguageCreated(languages.ToArray());
}
}