本文整理汇总了C#中ILookup类的典型用法代码示例。如果您正苦于以下问题:C# ILookup类的具体用法?C# ILookup怎么用?C# ILookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILookup类属于命名空间,在下文中一共展示了ILookup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SelectAction
public string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
{
if (odataPath.PathTemplate != "~/entityset/key/property")
{
return null;
}
var entitySetPathSegment = odataPath.Segments.OfType<EntitySetPathSegment>().Single();
var keyValuePathSegment = odataPath.Segments.OfType<KeyValuePathSegment>().Single();
var propertyAccessPathSegment = odataPath.Segments.OfType<PropertyAccessPathSegment>().Single();
var actionName = string.Format(CultureInfo.InvariantCulture, "GetPropertyFrom{0}", entitySetPathSegment.EntitySetName);
if (actionMap.Contains(actionName) && actionMap[actionName].Any(desc => MatchHttpMethod(desc, controllerContext.Request.Method)))
{
controllerContext.RouteData.Values.Add("propertyName", propertyAccessPathSegment.PropertyName);
if (!CompositeODataKeyHelper.TryEnrichRouteValues(keyValuePathSegment.Value, controllerContext.RouteData.Values))
{
controllerContext.RouteData.Values.Add("key", keyValuePathSegment.Value);
}
return actionName;
}
return null;
}
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:27,代码来源:EntitySetPropertyRoutingConvention.cs
示例2: ShouldReplicateBlob
public static bool ShouldReplicateBlob(ILookup<string, string> headers, string container, string blob)
{
bool retval = false;
if (DashConfiguration.IsBlobReplicationEnabled)
{
bool evaluated = false;
string replicaMetadata = DashConfiguration.ReplicationMetadataName;
if (headers != null && !String.IsNullOrWhiteSpace(replicaMetadata))
{
string replicateHeader = "x-ms-meta-" + replicaMetadata;
if (headers.Contains(replicateHeader))
{
retval = String.Equals(DashConfiguration.ReplicationMetadataValue, headers[replicateHeader].First(), StringComparison.OrdinalIgnoreCase);
evaluated = true;
}
}
if (!evaluated)
{
if (_replicationPathExpression != null)
{
retval = _replicationPathExpression.IsMatch(PathUtils.CombineContainerAndBlob(container, blob));
}
}
}
return retval;
}
开发者ID:CedarLogic,项目名称:Dash,代码行数:27,代码来源:BlobReplicationHandler.cs
示例3: GetChildItem
private static ExplorerItem GetChildItem(ILookup<Type, ExplorerItem> elementTypeLookup, PropertyInfo childProp) {
// If the property's type is in our list of entities, then it's a Many:1 (or 1:1) reference.
// We'll assume it's a Many:1 (we can't reliably identify 1:1s purely from reflection).
if (elementTypeLookup.Contains(childProp.PropertyType))
return new ExplorerItem(childProp.Name, ExplorerItemKind.ReferenceLink, ExplorerIcon.ManyToOne) {
HyperlinkTarget = elementTypeLookup[childProp.PropertyType].First(),
// FormatTypeName is a helper method that returns a nicely formatted type name.
ToolTipText = DataContextDriver.FormatTypeName(childProp.PropertyType, true)
};
// Is the property's type a collection of entities?
Type ienumerableOfT = childProp.PropertyType.GetInterface("System.Collections.Generic.IEnumerable`1");
if (ienumerableOfT != null) {
Type elementType = ienumerableOfT.GetGenericArguments()[0];
if (elementTypeLookup.Contains(elementType))
return new ExplorerItem(childProp.Name, ExplorerItemKind.CollectionLink, ExplorerIcon.OneToMany) {
HyperlinkTarget = elementTypeLookup[elementType].First(),
ToolTipText = DataContextDriver.FormatTypeName(elementType, true)
};
}
// Ordinary property:
var isKey = childProp.GetCustomAttributes(false).Any(a => a.GetType().Name == "KeyAttribute");
return new ExplorerItem(childProp.Name + " (" + DataContextDriver.FormatTypeName(childProp.PropertyType, false) + ")",
ExplorerItemKind.Property, isKey ? ExplorerIcon.Key : ExplorerIcon.Column) { DragText = childProp.Name };
}
开发者ID:IdeaBlade,项目名称:DevForce.Utilities,代码行数:26,代码来源:SchemaHelper.cs
示例4: SelectAction
/// <summary>
/// Selects the action for OData requests.
/// </summary>
/// <param name="odataPath">The OData path.</param>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionMap">The action map.</param>
/// <returns>
/// <c>null</c> if the request isn't handled by this convention; otherwise, the name of the selected action
/// </returns>
public string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
{
if (odataPath == null)
{
throw Error.ArgumentNull("odataPath");
}
if (controllerContext == null)
{
throw Error.ArgumentNull("controllerContext");
}
if (actionMap == null)
{
throw Error.ArgumentNull("actionMap");
}
if (odataPath.PathTemplate == "~")
{
return "GetServiceDocument";
}
if (odataPath.PathTemplate == "~/$metadata")
{
return "GetMetadata";
}
return null;
}
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:38,代码来源:MetadataRoutingConvention.cs
示例5: Select
private static ViewComponentDescriptor Select(
ILookup<string, ViewComponentDescriptor> candidates,
string name)
{
var matches = candidates[name];
var count = matches.Count();
if (count == 0)
{
return null;
}
else if (count == 1)
{
return matches.Single();
}
else
{
var matchedTypes = new List<string>();
foreach (var candidate in matches)
{
matchedTypes.Add(Resources.FormatViewComponent_AmbiguousTypeMatch_Item(
candidate.Type.FullName,
candidate.FullName));
}
var typeNames = string.Join(Environment.NewLine, matchedTypes);
throw new InvalidOperationException(
Resources.FormatViewComponent_AmbiguousTypeMatch(name, Environment.NewLine, typeNames));
}
}
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:30,代码来源:DefaultViewComponentSelector.cs
示例6: AddDescendantNodes
protected virtual void AddDescendantNodes(
ISiteMap siteMap,
ISiteMapNode currentNode,
IList<ISiteMapNodeToParentRelation> sourceNodes,
ILookup<string, ISiteMapNodeToParentRelation> sourceNodesByParent,
HashSet<string> nodesAlreadyAdded)
{
if (sourceNodes.Count == 0)
{
return;
}
var children = sourceNodesByParent[currentNode.Key].OrderBy(x => x.Node.Order).ToArray();
if (children.Count() == 0)
{
return;
}
foreach (var child in children)
{
if (sourceNodes.Count == 0)
{
return;
}
this.AddAndTrackNode(siteMap, child, currentNode, sourceNodes, nodesAlreadyAdded);
if (sourceNodes.Count == 0)
{
return;
}
this.AddDescendantNodes(siteMap, child.Node, sourceNodes, sourceNodesByParent, nodesAlreadyAdded);
}
}
开发者ID:Guymestef,项目名称:MvcSiteMapProvider,代码行数:35,代码来源:SiteMapHierarchyBuilder.cs
示例7: AssertDescriptorMatches
void AssertDescriptorMatches(ILookup<string, SecurityAttributeDescriptor> descriptors, string signature, ICustomAttributeProvider element)
{
if (descriptors.Contains(signature))
AssertContainsAttribute(element, descriptors[signature].Single().AttributeTypeName);
else
AssertContainsNoAttribute(element);
}
开发者ID:tigerhu67,项目名称:monobuildtools,代码行数:7,代码来源:AssemblySecurityVerifier.cs
示例8: SelectAction
public override string SelectAction(ODataPath odataPath, HttpControllerContext context,
ILookup<string, HttpActionDescriptor> actionMap)
{
if (context.Request.Method == HttpMethod.Get &&
odataPath.PathTemplate == "~/entityset/key/navigation/key")
{
NavigationPathSegment navigationSegment = odataPath.Segments[2] as NavigationPathSegment;
IEdmNavigationProperty navigationProperty = navigationSegment.NavigationProperty.Partner;
IEdmEntityType declaringType = navigationProperty.DeclaringType as IEdmEntityType;
string actionName = "Get" + declaringType.Name;
if (actionMap.Contains(actionName))
{
// Add keys to route data, so they will bind to action parameters.
KeyValuePathSegment keyValueSegment = odataPath.Segments[1] as KeyValuePathSegment;
context.RouteData.Values[ODataRouteConstants.Key] = keyValueSegment.Value;
KeyValuePathSegment relatedKeySegment = odataPath.Segments[3] as KeyValuePathSegment;
context.RouteData.Values[ODataRouteConstants.RelatedKey] = relatedKeySegment.Value;
return actionName;
}
}
// Not a match.
return null;
}
开发者ID:webdev2,项目名称:NajranService,代码行数:26,代码来源:ODataConventions.cs
示例9: SelectAction
public string SelectAction(
ODataPath odataPath,
HttpControllerContext controllerContext,
ILookup<string, HttpActionDescriptor> actionMap)
{
return null;
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:7,代码来源:MatchAllRoutingConvention.cs
示例10: SelectAction
/// <summary>
/// Selects the appropriate action based on the parsed OData URI.
/// </summary>
/// <param name="odataPath">Parsed OData URI</param>
/// <param name="controllerContext">Context for HttpController</param>
/// <param name="actionMap">Mapping from action names to HttpActions</param>
/// <returns>String corresponding to controller action name</returns>
public string SelectAction(
ODataPath odataPath,
HttpControllerContext controllerContext,
ILookup<string, HttpActionDescriptor> actionMap)
{
// TODO GitHubIssue#44 : implement action selection for $ref, navigation scenarios, etc.
Ensure.NotNull(odataPath, "odataPath");
Ensure.NotNull(controllerContext, "controllerContext");
Ensure.NotNull(actionMap, "actionMap");
if (!(controllerContext.Controller is RestierController))
{
// RESTier cannot select action on controller which is not RestierController.
return null;
}
HttpMethod method = controllerContext.Request.Method;
if (method == HttpMethod.Get && !IsMetadataPath(odataPath))
{
return MethodNameOfGet;
}
ODataPathSegment lastSegment = odataPath.Segments.LastOrDefault();
if (lastSegment != null && lastSegment.SegmentKind == ODataSegmentKinds.UnboundAction)
{
return MethodNameOfPostAction;
}
// Let WebAPI select default action
return null;
}
开发者ID:kosinsky,项目名称:RESTier,代码行数:39,代码来源:RestierRoutingConvention.cs
示例11: SelectAction
public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
{
var controllerType = controllerContext.ControllerDescriptor.ControllerType;
if (typeof(CustomersController) == controllerType)
{
if (odataPath.PathTemplate.Equals("~/entityset/key/navigation")) //POST OR GET
{
controllerContext.RouteData.Values["orderID"] = ((KeySegment)odataPath.Segments[1]).Keys.Single().Value;
return controllerContext.Request.Method.ToString();
}
}
else if (typeof(OrdersController) == controllerType)
{
if (odataPath.PathTemplate.Equals("~/entityset/key/navigation")) //POST OR GET
{
controllerContext.RouteData.Values["customerID"] = ((KeySegment)odataPath.Segments[1]).Keys.Single().Value;
return controllerContext.Request.Method.ToString();
}
if (odataPath.PathTemplate.Equals("~/entityset/key/navigation/key")) //PATCH OR DELETE
{
controllerContext.RouteData.Values["customerID"] = ((KeySegment)odataPath.Segments[1]).Keys.Single().Value;
controllerContext.RouteData.Values["key"] = ((KeySegment)odataPath.Segments[3]).Keys.Single().Value;
return controllerContext.Request.Method.ToString();
}
}
return base.SelectAction(odataPath, controllerContext, actionMap);
}
开发者ID:rbeauchamp,项目名称:Swashbuckle.OData,代码行数:30,代码来源:CustomNavigationPropertyRoutingConvention.cs
示例12: Select
private static WidgetDescriptor Select(ILookup<string, WidgetDescriptor> candidates, string name)
{
var matches = candidates[name];
var count = matches.Count();
if (count == 0)
{
return null;
}
else if (count == 1)
{
return matches.Single();
}
else
{
var matchedTypes = new List<string>();
foreach (var candidate in matches)
{
matchedTypes.Add($"Type: {candidate.Type.FullName}, Name: {candidate.FullName}");
}
var typeNames = string.Join(Environment.NewLine, matchedTypes);
throw new InvalidOperationException($"The widget name matched multiple types:{Environment.NewLine}{typeNames}");
}
}
开发者ID:Antaris,项目名称:AspNetCore.Mvc.Widgets,代码行数:25,代码来源:DefaultWidgetSelector.cs
示例13: getPostAndGetGateWay
//计算各URI通过网关的成功率和时延,也可以指定uri
public void getPostAndGetGateWay(Itemset hs, ILookup<string, string> m_dicTransactions)
{
var gn = from p in sqlserver_gn_table
where p.Event_Type == 4
where p.SynDirection == 0
//where p.my_URI_Main=="qq.com" || p.my_URI_Main==string.Empty
//group p by new { ABC = p.DEST_IP == 2885681162 } into ttt
//group p by p.my_DEST_IP into ttt
//where detail == true ? p.my_URI_Main == "10086.cn" : p.my_URI_Main != null
where hs.Contains(p.Prefix_IMEI)
group p by p.Prefix_IMEI into ttt
select new
{
//abc = ttt.Key.ABC.ToString(),
abc = ttt.Key.ToString(),
type = m_dicTransactions[ttt.Key.ToString()].Where(e => e.IndexOf("iphone") != -1|e.IndexOf("iPhone") != -1).FirstOrDefault(),
cnt = ttt.Count(),
suc = ttt.Where(e => e.Resp != null).Count(),
percent = 1.0 * ttt.Where(e => e.Resp != null).Count() / ttt.Count(),
uri_size = ttt.Average(e => e.my_URI_Len),
size = ttt.Average(e => e.IP_LEN_DL), //这里只去下行
rate = ttt.Average(e => e.Duration) == null ? 0 :
1.0 * ttt.Average(e => e.IP_LEN_DL) / ttt.Average(e => (double)e.Duration),
delay = ttt.Average(e => e.Duration) //这里不取第1个包
};
MicroObjectDumper.Write(gn.OrderByDescending(e => e.cnt));
}
开发者ID:sridhar19091986,项目名称:pcapsctpspliter,代码行数:28,代码来源:ComputeKeyPerformance1.cs
示例14: SelectAction
public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
{
var action = base.SelectAction(odataPath, controllerContext, actionMap);
if (action != null)
{
var routeValues = controllerContext.RouteData.Values;
if (routeValues.ContainsKey(ODataRouteConstants.Key))
{
var keyRaw = routeValues[ODataRouteConstants.Key] as string;
IEnumerable<string> compoundKeyPairs = keyRaw.Split(',');
if (compoundKeyPairs == null || !compoundKeyPairs.Any())
{
return action;
}
foreach (var compoundKeyPair in compoundKeyPairs)
{
string[] pair = compoundKeyPair.Split('=');
if (pair == null || pair.Length != 2)
{
continue;
}
var keyName = pair[0].Trim();
var keyValue = pair[1].Trim();
routeValues.Add(keyName, keyValue);
}
}
}
return action;
}
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:32,代码来源:CompositeKeyRoutingConvention.cs
示例15: SelectAction
/// <summary>
/// Selects the action for OData requests.
/// </summary>
/// <param name="odataPath">The OData path.</param>
/// <param name="controllerContext">The controller context.</param>
/// <param name="actionMap">The action map.</param>
/// <returns>
/// <c>null</c> if the request isn't handled by this convention; otherwise, the name of the selected action
/// </returns>
public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
{
if (odataPath == null)
{
throw Error.ArgumentNull("odataPath");
}
if (controllerContext == null)
{
throw Error.ArgumentNull("controllerContext");
}
if (actionMap == null)
{
throw Error.ArgumentNull("actionMap");
}
if (odataPath.PathTemplate == "~/entityset/key" ||
odataPath.PathTemplate == "~/entityset/key/cast")
{
HttpMethod httpMethod = controllerContext.Request.Method;
string httpMethodName;
switch (httpMethod.ToString().ToUpperInvariant())
{
case "GET":
httpMethodName = "Get";
break;
case "PUT":
httpMethodName = "Put";
break;
case "PATCH":
case "MERGE":
httpMethodName = "Patch";
break;
case "DELETE":
httpMethodName = "Delete";
break;
default:
return null;
}
Contract.Assert(httpMethodName != null);
IEdmEntityType entityType = odataPath.EdmType as IEdmEntityType;
// e.g. Try GetCustomer first, then fallback on Get action name
string actionName = actionMap.FindMatchingAction(
httpMethodName + entityType.Name,
httpMethodName);
if (actionName != null)
{
KeyValuePathSegment keyValueSegment = odataPath.Segments[1] as KeyValuePathSegment;
controllerContext.RouteData.Values[ODataRouteConstants.Key] = keyValueSegment.Value;
return actionName;
}
}
return null;
}
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:69,代码来源:EntityRoutingConvention.cs
示例16: ContentTypeDetector
public ContentTypeDetector(IEnumerable<ContentType> contentTypes)
{
if (null == contentTypes)
throw new ArgumentNullException(nameof(contentTypes));
ContentTypes = contentTypes.ToArray();
ExtensionLookup = ContentTypes
.SelectMany(ct => ct.FileExts, (ct, ext) => new
{
ext,
ContentType = ct
})
.ToLookup(arg => arg.ext, x => x.ContentType, StringComparer.OrdinalIgnoreCase);
var mimeTypes = ContentTypes
.Select(ct => new
{
ct.MimeType,
ContentType = ct
});
var alternateMimeTypes = ContentTypes
.Where(ct => null != ct.AlternateMimeTypes)
.SelectMany(ct => ct.AlternateMimeTypes, (ct, mime) => new
{
MimeType = mime,
ContentType = ct
});
MimeLookup = alternateMimeTypes
.Union(mimeTypes)
.ToLookup(arg => arg.MimeType, x => x.ContentType, StringComparer.OrdinalIgnoreCase);
}
开发者ID:henricj,项目名称:phonesm,代码行数:34,代码来源:ContentTypeDetector.cs
示例17: Hierarchy
/// <summary>
/// Where Tuple<int,int> represents a child_id|parent_id relationship
/// </summary>
/// <param name="relations"></param>
public Hierarchy(List<Relation> relations)
{
if (relations == null)
relations = new List<Relation>();
for (int i = 0; i < relations.Count; i++)
{
var item = relations[i];
if (item.Child == item.Parent)
continue;
// the child is a relation of itself; the parent is a relation of itself, too
this.Add(relations, new Relation { Child = item.Child, Parent = item.Child });
this.Add(relations, new Relation{ Child = item.Parent, Parent = item.Parent});
// if this 'parent' is the child of another item G, then this 'child' is also a child of G.
var grandparents = relations.Where(r => item.Parent == r.Child);
var grandchildren = relations.Where(r => r.Parent == item.Child).Select(r => r.Child);
var list = grandparents.Select(g => new Relation { Child = g.Child, Parent = item.Parent }).ToList();
foreach (var g in list)
this.Add(relations, g);
}
//parents = relations.GroupBy(i => i.Item1, i => i.Item2).ToLookup(g => g.Key, g => g.ToList());
parents = relations.ToLookup(i => i.Child, i => i.Parent);
children = relations.ToLookup(i => i.Parent, i => i.Child);
this.relationHash = new HashSet<int>(relations.Select(r => r.GetHashCode()));
}
开发者ID:hfortegcmlp,项目名称:CalculatorTest,代码行数:34,代码来源:Hierarchy.cs
示例18: InitCaches
public void InitCaches()
{
var db = new FacesDBDataContext(_connectionString);
_faceUKeyLookup = db.Faces.ToDictionary(x => x.FaceUKey, x => (api.Face) new FaceImpl(x, _m, null));
var query = (from f in db.Faces join p in db.Persons on f.PersonID equals p.PersonID select new { f, p });
_Faces = new Dictionary<api.Face,api.Person>();
Dictionary<int, api.Person> persons = new Dictionary<int,api.Person>();
foreach (var x in query) {
// todo; build pers dic at same time...
api.Person person = null;
if (!persons.TryGetValue(x.p.PersonID, out person))
{
person = (api.Person)new PersonImpl(x.p.FirstName, x.p.LastName, x.p.PersonID);
persons.Add(person.Id, person);
}
api.Face thisFace = _faceUKeyLookup[x.f.FaceUKey];
thisFace.Person = person;
_Faces.Add(thisFace, person);
}
_Persons = _Faces.GroupBy(x => x.Value).ToDictionary(x => x.Key, x => x.Select(y=>y.Key).ToList());
_allPersonsLookup = persons;
foreach (var pers in db.Persons) // add in other persons that don't have faces.
{
if (!_allPersonsLookup.ContainsKey(pers.PersonID))
_allPersonsLookup.Add(pers.PersonID, (api.Person)new PersonImpl(pers.FirstName, pers.LastName, pers.PersonID));
}
_PicturesToFaces = db.Faces
.ToLookup(x => x.PictureID, x => _faceUKeyLookup[x.FaceUKey]);
}
开发者ID:rwoodley,项目名称:FaceToys,代码行数:29,代码来源:DBManager.cs
示例19: CommitDiffModel
public CommitDiffModel(string[] lines, IEnumerable<CommitCommentModel> comments, int fontSize)
{
Lines = lines;
FontSize = fontSize;
Comments = comments.ToList();
CommentsLookup = Comments.ToLookup(x => x.Line);
}
开发者ID:runt18,项目名称:CodeHub,代码行数:7,代码来源:CommitDiffModel.cs
示例20: MenuService
public MenuService([NotNull] IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException("serviceProvider");
var menuProviders = new ExtensionsCache<MenuProviderInfo, IMenuProvider>(serviceProvider);
_menuProvidersLookup =
menuProviders
.GetAllExtensions()
.ToLookup(
menuProvider => menuProvider.MenuName,
StringComparer.OrdinalIgnoreCase);
// WTF?
menuProviders
.GetAllExtensions()
.OfType<IDynamicMenuProvider>()
.Select(
dynamicMenuProvider =>
{
_menuCache.Drop(dynamicMenuProvider.MenuName);
return
dynamicMenuProvider.MenuChanged.Subscribe(
arg => _menuChanged.OnNext(dynamicMenuProvider.MenuName));
});
_menuCache = new ElementsCache<string, IMenuRoot>(CreateMenu);
}
开发者ID:permyakov,项目名称:janus,代码行数:29,代码来源:MenuService.cs
注:本文中的ILookup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论