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


C# ILookup.Contains方法代码示例

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


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

示例1: 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

示例2: SelectAction

        public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
        {
            if (odataPath == null)
            {
                throw new ArgumentNullException("odataPath");
            }
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }
            if (actionMap == null)
            {
                throw new ArgumentNullException("actionMap");
            }
            HttpMethod requestMethod = controllerContext.Request.Method;
            if (odataPath.PathTemplate == "~/entityset/key/navigation/$ref"
                || odataPath.PathTemplate == "~/entityset/key/cast/navigation/$ref"
                || odataPath.PathTemplate == "~/entityset/key/navigation/key/$ref"
                || odataPath.PathTemplate == "~/entityset/key/cast/navigation/key/$ref")
            {
                var actionName = string.Empty;
                if ((requestMethod == HttpMethod.Post) || (requestMethod == HttpMethod.Put))
                {
                    actionName += "CreateRefTo";
                }
                else if (requestMethod == HttpMethod.Delete)
                {
                    actionName += "DeleteRefTo";
                }
                else
                {
                    return null;
                }
                var navigationSegment = odataPath.Segments.OfType<NavigationPathSegment>().Last();
                actionName += navigationSegment.NavigationPropertyName;

                var castSegment = odataPath.Segments[2] as CastPathSegment;
                if (castSegment != null)
                {
                    var actionCastName = string.Format("{0}On{1}", actionName, castSegment.CastType.Name);
                    if (actionMap.Contains(actionCastName))
                    {
                        AddLinkInfoToRouteData(controllerContext.RouteData, odataPath);
                        return actionCastName;
                    }
                }

                if (actionMap.Contains(actionName))
                {
                    AddLinkInfoToRouteData(controllerContext.RouteData, odataPath);
                    return actionName;
                }
            }
            return null;
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:55,代码来源:LinkRoutingConvention2.cs

示例3: SelectAction

        /// <summary>
        /// Selects the action.
        /// </summary>
        /// <param name="odataPath">The odata path.</param>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="actionMap">The action map.</param>
        /// <returns></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");
            }

            HttpMethod requestMethod = controllerContext.Request.Method;
            if (odataPath.PathTemplate == "~/entityset/key/$links/navigation")
            {
                if (requestMethod == HttpMethod.Post || requestMethod == HttpMethod.Put)
                {
                    if (actionMap.Contains(CreateLinkActionName))
                    {
                        AddLinkInfoToRouteData(controllerContext.RouteData, odataPath);
                        return CreateLinkActionName;
                    }
                }
                else if (requestMethod == HttpMethod.Delete)
                {
                    if (actionMap.Contains(DeleteLinkActionName))
                    {
                        AddLinkInfoToRouteData(controllerContext.RouteData, odataPath);
                        return DeleteLinkActionName;
                    }
                }
            }
            else if (odataPath.PathTemplate == "~/entityset/key/$links/navigation/key" && requestMethod == HttpMethod.Delete)
            {
                if (actionMap.Contains(DeleteLinkActionName))
                {
                    AddLinkInfoToRouteData(controllerContext.RouteData, odataPath);
                    KeyValuePathSegment relatedKeySegment = odataPath.Segments[4] as KeyValuePathSegment;
                    controllerContext.RouteData.Values[ODataRouteConstants.RelatedKey] = relatedKeySegment.Value;
                    return DeleteLinkActionName;
                }
            }
            return null;
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:56,代码来源:LinksRoutingConvention.cs

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: SelectAction

        public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
        {
            if (controllerContext.Request.Method != HttpMethod.Get || odataPath.PathTemplate != "~/entityset/$count")
            {
                return null;
            }

            return actionMap.Contains("GetCount") ? "GetCount" : null;
        }
开发者ID:battenworks,项目名称:NuGet.Lucene,代码行数:9,代码来源:EntitySetCountRoutingConvention.cs

示例9: 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);

                KeyValuePathSegment keyValueSegment = odataPath.Segments[1] as KeyValuePathSegment;
                controllerContext.RouteData.Values.Add(ODataRouteConstants.Key, keyValueSegment.Value);

                IEdmEntityType entityType = odataPath.EdmType as IEdmEntityType;

                // e.g. Try GetCustomer first, then fallback on Get action name
                string httpMethodAndEntityName = httpMethodName + entityType.Name;
                return actionMap.Contains(httpMethodAndEntityName) ? httpMethodAndEntityName : httpMethodName;
            }
            return null;
        }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:64,代码来源:EntityRoutingConvention.cs

示例10: GetExtentionMethods

		/// <summary>
		/// 
		/// </summary>
		/// <remarks>
		/// Может быть: Method(this T), где T базовый класс, базовый интерфейс. Поэтому может быть несколько одноименных методов.
		/// 
		/// Правила C#:
		/// Сначала собираются все extention мтоды для всех базовых классов и интерфейсов от которых наследуется класс. 
		/// Если попадаются одноименнные для них неоднозначность разрешается так (по типу который они расширяют):
		/// Выбираются более приоритетно расширения для базовых классов, берется наиболее derived
		/// если базовых классов нет то, потом для интерфейсов(независимо где по иерархии интерфейсы добавлены в наследование)
		/// Если выбраны расширения для нескольких интерфейсов, выбирается наиболее derived. 
		/// Если же нет наиболее derived интерфейса(для которого все остальные базовые) - то ошибка.
		/// 
		/// ToDo: Из них надо бы выбирать наиболее derived, но пока собираются все.
		/// Осложняется тем что, для класса может быть неоднозначный вызов. Например если класс наследуется от интерфейсов I1,I2,
		/// и Extention методы определены и для I1 и для I2, вызов для этого класса будет ошибочный, но показывать что они есть, наверно все равно надо.
		/// </remarks>
		/// <param name="type"></param>
		/// <param name="lookup"></param>
		/// <returns></returns>
		static IEnumerable<MethodDom> GetExtentionMethods(Type type, ILookup<Type, MethodDom> lookup)
		{
			var baseTypes =
				Enumerable.Repeat(type, 1)
				.Concat(TypeUtils.GetBaseTypes(type))
				.Concat(type.GetInterfaces());
			var res = new List<MethodDom>();
			foreach (var baseType in baseTypes)
			{
				if (lookup.Contains(baseType))
					res.AddRange(lookup[baseType]);
			}
			return res;
		}
开发者ID:zjxbetter,项目名称:StockSharp,代码行数:35,代码来源:PopulateExtentionMethods.cs

示例11: 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") {
                var navigationSegment = odataPath.Segments[2] as NavigationPathSegment;
                var navigationProperty = navigationSegment.NavigationProperty.Partner;
                var declaringType = navigationProperty.DeclaringType as IEdmEntityType;

                var actionName = new[] { "Get", "Get" + declaringType.Name }.FirstOrDefault(a => actionMap.Contains(a));
                if (actionName == null) return null;

                if (actionMap.Contains(actionName)) {
                    // Add keys to route data, so they will bind to action parameters.
                    var keyValueSegment = odataPath.Segments[1] as KeyValuePathSegment;
                    context.RouteData.Values[ODataRouteConstants.Key] = keyValueSegment.Value;

                    var relatedKeySegment = odataPath.Segments[3] as KeyValuePathSegment;
                    context.RouteData.Values[ODataRouteConstants.RelatedKey] = relatedKeySegment.Value;

                    return actionName;
                }
            }

            return null;
        }
开发者ID:meiometro,项目名称:WebApi-OData,代码行数:24,代码来源:NavigationIndexRoutingConvention.cs

示例12: SelectAction

        public override string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
        {
            //if (controllerContext.Request.Method == System.Net.Http.HttpMethod.Put) controllerContext.Request.Content.ReadAsStreamAsync().ContinueWith((t) => A(t.Result));
            
            if (odataPath == null)
            {
                throw new ArgumentNullException("odataPath");
            }

            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (actionMap == null)
            {
                throw new ArgumentNullException("actionMap");
            }

            string prefix = GetHttpPrefix(controllerContext.Request.Method.ToString());
            if (string.IsNullOrEmpty(prefix))
            {
                return null;
            }

            //~/entityset/key/$links/navigation
            if ((odataPath.PathTemplate == "~/entityset/key/navigation") 
                || (odataPath.PathTemplate == "~/entityset/key/cast/navigation")
                    || (odataPath.PathTemplate == "~/entityset/key/$links/navigation"))
            {
                NavigationPathSegment segment = odataPath.Segments.Last() as NavigationPathSegment;
                IEdmNavigationProperty navigationProperty = segment.NavigationProperty;
                IEdmEntityType declaringType = navigationProperty.DeclaringType as IEdmEntityType;

                if (declaringType != null)
                {
                    KeyValuePathSegment keySegment = odataPath.Segments[1] as KeyValuePathSegment;
                    controllerContext.RouteData.Values[ODataRouteConstants.Key] = keySegment.Value;
                    string actionName = prefix + navigationProperty.Name + "From" + declaringType.Name;
                    return (actionMap.Contains(actionName) ? actionName : (prefix + navigationProperty.Name));
                }
            }

            return null;
        }
开发者ID:koder05,项目名称:fogel-ba,代码行数:45,代码来源:CustomNavigationRoutingConvention.cs

示例13: SelectAction

        // Route the action to a method with the same name as the action.
        public string SelectAction(ODataPath odataPath, HttpControllerContext controllerContext, ILookup<string, HttpActionDescriptor> actionMap)
        {
            // OData actions must be invoked with HTTP POST.
            if (controllerContext.Request.Method == HttpMethod.Post)
            {
                if (odataPath.PathTemplate == "~/action")
                {
                    ActionPathSegment actionSegment = odataPath.Segments.First() as ActionPathSegment;
                    IEdmFunctionImport action = actionSegment.Action;

                    if (!action.IsBindable && actionMap.Contains(action.Name))
                    {
                        return action.Name;
                    }
                }
            }
            return null;
        }
开发者ID:ErikWitkowski,项目名称:Simple.OData.Client,代码行数:19,代码来源:NonBindableActionRoutingConvention.cs

示例14: SelectAction

        public override string SelectAction(ODataPath odataPath, HttpControllerContext context, ILookup<string, HttpActionDescriptor> actionMap)
        {
            if (context.Request.Method != HttpMethod.Get || odataPath.PathTemplate != "~/entityset/cast") return null;

            var actionName = new[] { "GetType" }.FirstOrDefault(a => actionMap.Contains(a));
            if (actionName == null) return null;

            var castSegment = odataPath.Segments[1] as CastPathSegment;

            switch (castSegment.CastType.TypeKind) {
                case EdmTypeKind.Entity: {
                        context.RouteData.Values[CastTypeParameterName] = castSegment.CastType.FullTypeName();
                        break;
                    }

                default: return null;
            }

            return actionName;
        }
开发者ID:meiometro,项目名称:WebApi-OData,代码行数:20,代码来源:CastRoutingConvention.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 virtual 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")
            {
                EntitySetPathSegment entitySetSegment = odataPath.Segments[0] as EntitySetPathSegment;
                IEdmEntitySet entitySet = entitySetSegment.EntitySet;
                HttpMethod httpMethod = controllerContext.Request.Method;

                if (httpMethod == HttpMethod.Get)
                {
                    // e.g. Try GetCustomers first, then fallback on Get action name
                    string httpMethodName = "Get";
                    string httpMethodAndEntitySetName = httpMethodName + entitySet.Name;
                    return actionMap.Contains(httpMethodAndEntitySetName) ? httpMethodAndEntitySetName : httpMethodName;
                }
                else if (httpMethod == HttpMethod.Post)
                {
                    // e.g. Try PostCustomer first, then fallback on Post action name
                    string httpMethodName = "Post";
                    string httpMethodAndEntityTypeName = httpMethodName + entitySet.ElementType.Name;
                    return actionMap.Contains(httpMethodAndEntityTypeName) ? httpMethodAndEntityTypeName : httpMethodName;
                }
            }
            return null;
        }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:49,代码来源:EntitySetRoutingConvention.cs


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