本文整理汇总了C#中ReadOnlyCollection.First方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.First方法的具体用法?C# ReadOnlyCollection.First怎么用?C# ReadOnlyCollection.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsDynamicComponentDictionaryGetter
public static bool IsDynamicComponentDictionaryGetter(MethodInfo method, Expression targetObject, ReadOnlyCollection<Expression> arguments, ISessionFactory sessionFactory, out string memberName)
{
memberName = null;
// A dynamic component must be an IDictionary with a string key.
if (method.Name != "get_Item" || !typeof(IDictionary).IsAssignableFrom(targetObject.Type))
return false;
var key = arguments.First().As<ConstantExpression>();
if (key == null || key.Type != typeof(string))
return false;
// The potential member name
memberName = (string)key.Value;
// Need the owning member (the dictionary).
var member = targetObject.As<MemberExpression>();
if (member == null)
return false;
var metaData = sessionFactory.GetClassMetadata(member.Expression.Type);
if (metaData == null)
return false;
// IDictionary can be mapped as collection or component - is it mapped as a component?
var propertyType = metaData.GetPropertyType(member.Member.Name);
return (propertyType != null && propertyType.IsComponentType);
}
示例2: OggStream
protected OggStream(IEnumerable<Page> pages, IEnumerable<Packet> packets)
{
if (packets == null) throw new ArgumentNullException ("packets");
Pages = new ReadOnlyCollection<Page>(pages.ToList());
Packets = new ReadOnlyCollection<Packet> (packets.ToList ());
SerialNumber = Pages.First().StreamSerialNumber;
}
示例3: RegisteredQualifier
public RegisteredQualifier(RegisteredCommand command, IEnumerable<string> names, string help)
: base(command, help)
{
_names = new ReadOnlyCollection<string>(names.ToArray());
var firstLongName = _names.FirstOrDefault(n => n.Length > 1);
var firstName = _names.First();
_name = firstLongName ?? firstName;
}
示例4: LiteralConversion
/// <summary> Creates a new literal conversion. </summary>
/// <param name="components"> The components that can be successfully parsed. </param>
/// <param name="result"> The result domain of the conversion. </param>
public LiteralConversion(Domain result, ReadOnlyCollection<Domain> components)
{
Contract.Requires(components != null);
Contract.Requires(components.Any(domain => domain.ToKind().IsLiteral()), "At least one literal must be present");
Contract.Requires(Contract.ForAll(components, domain => Enum.IsDefined(typeof(Domain), domain)), "Undefined domain kind");
Contract.Requires(Contract.ForAll(components, domain => domain.ToKind().IsOperand() || domain.ToKind().IsLiteral()), "No operators are allowed in the literal conversion");
Contract.Requires(Enum.IsDefined(typeof(Domain), result));
this.Components = components;
this.Key = components.First(domain => domain.ToKind().IsLiteral());
this.Result = result;
}
示例5: KeyBindingData
public KeyBindingData(ReadOnlyCollection<CommandKeyBinding> bindings)
{
// All bindings passed have the same KeyInput as their first key, so get it
var firstKeyInput = bindings.First().KeyBinding.FirstKeyStroke;
KeyName = KeyBinding.CreateKeyBindingStringForSingleKeyStroke(firstKeyInput);
_bindings = bindings;
_handledByOptions.AddRange(
new[] {
_visualStudioOption = new KeyBindingHandledByOption("Visual Studio", bindings.Select(binding => binding.Name)),
_vsVimOption = new KeyBindingHandledByOption("VsVim", Enumerable.Empty<string>())
});
}
示例6: BuildHql
public override HqlTreeNode BuildHql(
MethodInfo method,
Expression targetObject,
ReadOnlyCollection<Expression> arguments,
HqlTreeBuilder treeBuilder,
IHqlExpressionVisitor visitor)
{
var left = treeBuilder.Cast(visitor.Visit(targetObject).AsExpression(), typeof(string));
var right = treeBuilder.Cast(visitor.Visit(arguments.First()).AsExpression(), typeof(string));
var leftSubstring = treeBuilder.MethodCall("substring", left, treeBuilder.Constant(4));
var rightSubstring = treeBuilder.MethodCall("substring", right, treeBuilder.Constant(4));
var equals = treeBuilder.Equality(leftSubstring, rightSubstring);
return equals;
}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:15,代码来源:EntityWithUserTypePropertyIsEquivalentGenerator.cs
示例7: KeyBindingData
public KeyBindingData(ReadOnlyCollection<CommandKeyBinding> bindings)
{
// All bindings passed have the same KeyInput as their first key, so get it
var firstKeyInput = bindings.First().KeyBinding.FirstKeyStroke;
KeyName = KeyBinding.CreateKeyBindingStringForSingleKeyStroke(firstKeyInput);
// It's possible that Visual Studio will bind multiple key strokes to the same
// command. Often it will be things like "Ctrl-[, P" and "Ctr-[, Ctrl-P". In
// that case we don't want to list the command twice so filter that possibility
// out here
var commandNames = bindings.Select(x => x.Name).Distinct(StringComparer.OrdinalIgnoreCase);
_bindings = bindings;
_handledByOptions.AddRange(
new[] {
_visualStudioOption = new KeyBindingHandledByOption("Visual Studio", commandNames),
_vsVimOption = new KeyBindingHandledByOption("VsVim", Enumerable.Empty<string>())
});
}
示例8: Bind
public override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel)
{
Console.WriteLine("cache miss");
ParameterExpression firstParameterExpression = parameters.First();
return Expression.IfThenElse(
//if
Expression.GreaterThanOrEqual(
firstParameterExpression,
Expression.Constant(5)),
//then
Expression.Return(
returnLabel,
Expression.Constant(10)),
//else
Expression.Return(
returnLabel,
Expression.Constant(1)));
}
示例9: EvaluateStatardMemberAccess
protected object EvaluateStatardMemberAccess(string propertyName, ReadOnlyCollection<Expression> operands)
{
return operands[0].Type.GetProperty(propertyName).GetValue(operands.First().Evaluate(), null);
}
示例10: BuildFieldProperty
static JToken BuildFieldProperty(ReadOnlyCollection<string> fields)
{
return fields.Count == 1
? new JProperty("field", fields.First())
: new JProperty("fields", new JArray(fields));
}
示例11: OnNavigatedTo
public async override void OnNavigatedTo(object navigationParameter, NavigationMode navigationMode, Dictionary<string, object> viewState)
{
try
{
var productNumber = navigationParameter as string;
var selectedProduct = await _productCatalogRepository.GetProductAsync(productNumber);
var productViewModels = (await _productCatalogRepository.GetProductsAsync(selectedProduct.SubcategoryId))
.Select(product => new ProductViewModel(product, _shoppingCartRepository));
Items = new ReadOnlyCollection<ProductViewModel>(productViewModels.ToList());
SelectedProduct = Items.First(p => p.ProductNumber == productNumber);
Title = SelectedProduct.Title;
IsSelectedProductPinned = _tileService.SecondaryTileExists(SelectedProduct.ProductNumber);
_searchPaneService.ShowOnKeyboardInput(true);
}
catch (HttpRequestException)
{
var task = _alertService.ShowAsync(_resourceLoader.GetString("ErrorServiceUnreachable"), _resourceLoader.GetString("Error"));
}
}
示例12: PickPluginFromMultipleSupportedPlugins
/// <summary>
/// The pick plugin from multiple supported plugins.
/// </summary>
/// <param name="pluginsToUse">
/// The plugins to use.
/// </param>
/// <returns>
/// The <see cref="IPlugin"/>.
/// </returns>
public IPlugin PickPluginFromMultipleSupportedPlugins(ReadOnlyCollection<IPlugin> pluginsToUse)
{
if (pluginsToUse != null && pluginsToUse.Any())
{
return pluginsToUse.First();
}
return null;
}
示例13: PopulateStatesAsync
public async Task PopulateStatesAsync()
{
var items = new List<ComboBoxItemValue> { new ComboBoxItemValue() { Id = string.Empty, Value = _resourceLoader.GetString("State") } };
var states = await _locationService.GetStatesAsync();
items.AddRange(states.Select(state => new ComboBoxItemValue() { Id = state, Value = state }));
States = new ReadOnlyCollection<ComboBoxItemValue>(items);
// Select the first item on the list
// But disable validation first, because we don't want to fire validation at this point
_address.IsValidationEnabled = false;
_address.State = States.First().Id;
_address.IsValidationEnabled = true;
}
示例14: VisitGroupBy
private void VisitGroupBy(ReadOnlyCollection<Expression> selectGroupBy)
{
sb.Append("(");
if (selectGroupBy != null)
{
if (selectGroupBy.Count ==1)
{
ColumnExpression colexpr = (ColumnExpression) selectGroupBy.First();
sb.AppendFormat("(enlist `{0})!enlist `{0}", colexpr.Name);
}
else
{
throw new NotImplementedException("");
}
}
//&& selectGroupBy.Count > 0)
//{
// for (int i = 0, n = selectGroupBy.Count; i < n; i++)
// {
// if (i > 0)
// {
// sb.Append(", ");
// }
// VisitValue(selectGroupBy[i]);
// }
//}
sb.Append(")");
}
示例15: PopulateStatesAsync
public async Task PopulateStatesAsync()
{
string errorMessage = string.Empty;
try
{
var states = await _locationService.GetStatesAsync();
var items = new List<ComboBoxItemValue> { new ComboBoxItemValue() { Id = string.Empty, Value = _resourceLoader.GetString("State") } };
items.AddRange(states.Select(state => new ComboBoxItemValue() { Id = state, Value = state }));
States = new ReadOnlyCollection<ComboBoxItemValue>(items);
// Select the first item on the list
// But disable validation first, because we don't want to fire validation at this point
_address.IsValidationEnabled = false;
_address.State = States.First().Id;
_address.IsValidationEnabled = true;
}
catch (Exception ex)
{
errorMessage = string.Format(CultureInfo.CurrentCulture, _resourceLoader.GetString("GeneralServiceErrorMessage"), Environment.NewLine, ex.Message);
}
if (!string.IsNullOrWhiteSpace(errorMessage))
{
await _alertMessageService.ShowAsync(errorMessage, _resourceLoader.GetString("ErrorServiceUnreachable"));
}
}