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


C# IDictionary.Single方法代码示例

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


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

示例1: Document

 public Document(DocumentTable table, string document, IDictionary<string, object> projections)
 {
     Table = table;
     DocumentAsString = document;
     idColumn = projections.Single(x => x.Key == table.IdColumn.Name);
     documentColumn = projections.Single(x => x.Key == table.DocumentColumn.Name);
     etagColumn = projections.Single(x => x.Key == table.EtagColumn.Name);
     this.projections = projections.Where(x => !(x.Key is SystemColumn))
                                   .Select(x => new Projection(x.Key, x.Value))
                                   .ToList();
 }
开发者ID:dcga,项目名称:HybridDb,代码行数:11,代码来源:Document.cs

示例2: Invoke

 public async Task Invoke(IDictionary<string, object> environment)
 {
     //IOwinContext owinContext = new OwinContext(environment);
     HttpContextBase httpContext = (HttpContextBase)environment.Single(context => 
         context.Key == "System.Web.HttpContextBase").Value;
     var url = httpContext.Request.Url;
     if (url.AbsoluteUri.Contains("/Contact"))
     {
         httpContext.Response.Redirect("/");
     }
     else
     {
         await this._next.Invoke(environment);
     }
 }
开发者ID:wangchez,项目名称:Learn-Owin-Demo,代码行数:15,代码来源:DoNotContactMe.cs

示例3: CheckForExistingProperty

        private static object CheckForExistingProperty(object item2, PropertyInfo fi, IDictionary<string, object> result)
        {
            var newValue = fi.GetValue(item2, null);
            if (result.All(x => x.Key != fi.Name))
            {
                return newValue;
            }

            var foundProperty = result.Single(x => x.Key == fi.Name);

            if (!foundProperty.Value.Equals(newValue))
            {
                throw new Exception("Merging Property with different values - " + fi.Name);
            }
            return newValue;
        }
开发者ID:brentonmcs,项目名称:DapperContext,代码行数:16,代码来源:DapperContext.cs

示例4: ExecuteAsync

        public override Task<object> ExecuteAsync(HttpControllerContext controllerContext, IDictionary<string, object> arguments, CancellationToken cancellationToken)
        {
            return TaskHelpers.RunSynchronously<object>(() =>
            {
                // create the changeset
                object entity = arguments.Single().Value; // there is only a single parameter - the entity being submitted
                ChangeSetEntry[] changeSetEntries = new ChangeSetEntry[]
                {
                    new ChangeSetEntry
                    {
                        Id = 1,
                        ActionDescriptor = _updateAction,
                        Entity = entity,
                        Operation = _updateAction.ChangeOperation
                    }
                };
                ChangeSet changeSet = new ChangeSet(changeSetEntries);
                changeSet.SetEntityAssociations();

                DataController controller = (DataController)controllerContext.Controller;
                if (!controller.Submit(changeSet) &&
                    controller.ActionContext.Response != null)
                {
                    // If the submit failed due to an authorization failure,
                    // return the authorization response directly
                    return controller.ActionContext.Response;
                }

                // return the entity
                entity = changeSet.ChangeSetEntries[0].Entity;
                // REVIEW does JSON make sense here?
                return new HttpResponseMessage()
                {
                    Content = new ObjectContent(_updateAction.EntityType, entity, new JsonMediaTypeFormatter())
                };
            }, cancellationToken);
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:37,代码来源:SubmitProxyActionDescriptor.cs

示例5: Load

 private ISuiteProvider Load(
 Type suiteType,
 IDictionary<Type, ITypeLoader> loaderDictionary,
 IDictionary<Type, Lazy<IAssemblySetup>> assemblySetups,
 IIdentity assemblyIdentity)
 {
     // TODO: Move selection to AssemblyExplorer
       var suiteTypeLoader = loaderDictionary.Single(x => x.Key == suiteType.GetAttribute<SuiteAttributeBase>().AssertNotNull().GetType()).Value;
       return suiteTypeLoader.Load(suiteType, assemblySetups, assemblyIdentity);
 }
开发者ID:igor-toporet,项目名称:TestFx,代码行数:10,代码来源:AssemblyLoader.cs

示例6: RegisterInParents

        private void RegisterInParents(DeviceInfo device, IDictionary<string, IPeripheral> parents)
        {
            foreach(var parentName in device.Connections.Keys)
            {
                //TODO: nongeneric version
                var parent = parents.Single(x => x.Key == parentName).Value;
                var connections = device.Connections[parentName];
                var ifaces = parent.GetType().GetInterfaces().Where(x => IsSpecializationOfRawGeneric(typeof(IPeripheralRegister<,>), x)).ToList();
                var ifaceCandidates = ifaces.Where(x => x.GetGenericArguments()[0].IsAssignableFrom(device.Peripheral.GetType())).ToList();
                foreach(var connection in connections)
                {
                    IRegistrationPoint regPoint = null;
                    Type formalType = null;
                    if(connection.ContainsKey(TYPE_NODE))
                    {
                        var name = (string)connection[TYPE_NODE];
                        formalType = GetDeviceTypeFromName(name);
                    }

                    Type foundIface = null;
                    foreach(var iface in ifaceCandidates)
                    {
                        var iRegPoint = iface.GetGenericArguments()[1];
                        Type objType; 
                        if(formalType != null && iRegPoint.IsAssignableFrom(formalType))
                        {
                            objType = formalType;
                        }
                        else
                        {
                            objType = iRegPoint;
                        }

                        object regPointObject;
                        if(!TryInitializeCtor(objType, connection, out regPointObject))
                        {
                            if(connection.Keys.Any() || !TryHandleSingleton(objType, out regPointObject))
                            {
                                continue;
                            }
                        }
                        regPoint = (IRegistrationPoint)regPointObject;
                        foundIface = iface;
                        break;
                        //is a construable type 
                    }
                    if(foundIface == null)
                    {
                        // let's try attachment through the AttachTo mechanism
                        FailDevice(device.Name, "connection to " + parentName);
                    }
                    else
                    {
                        Dynamic.InvokeMemberAction(parent, "Register", new object[] {
                            device.Peripheral,
                            regPoint
                        }
                        );                      
                    }
                }
            }
        }
开发者ID:rte-se,项目名称:emul8,代码行数:62,代码来源:DevicesConfig.cs

示例7: BuildResponse

        /// <summary>
        /// Builds the response.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <returns></returns>
        protected IDictionary<string, object> BuildResponse(object serializableObject, IDictionary<string, object> serializedContent)
        {
            // create body of the response
            IDictionary<string, object> response = new Dictionary<string, object>();
            response.Add("timestamp", DateTime.UtcNow);

            // add serialization headers to the response
            foreach (var header in SerializedHeader)
                response.Add(header.Key, header.Value);

            // check for regular collection
            if (serializableObject is ICollection)
                response.Add("count", ((ICollection)serializableObject).Count);

            // check if only one object was returned, if it was then we can rename the root
            if (serializedContent.Count == 1)
            {
                var rootObj = serializedContent.Single();
                var rootName = rootObj.Key;

                if (!String.IsNullOrWhiteSpace(SerializedRootName))
                    rootName = SerializedRootName;

                response.Add(rootName, rootObj.Value);
            }
            else
                foreach (var item in serializedContent)
                    response.Add(item);

            return response;
        }
开发者ID:rdefreitas,项目名称:managedfusion-web,代码行数:36,代码来源:SerializedView.cs


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