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


C# IDictionary.Get方法代码示例

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


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

示例1: Invoke

        public Task Invoke(IDictionary<string, object> environment)
        {
            if (!environment.Get<string>(OwinConstants.RequestMethodKey).EqualsIgnoreCase("GET"))
            {
                return _inner(environment);
            }

            var originalOutput = environment.Get<Stream>(OwinConstants.ResponseBodyKey);
            var recordedStream = new MemoryStream();
            environment.Set(OwinConstants.ResponseBodyKey, recordedStream);

            return _inner(environment).ContinueWith(t => {
                recordedStream.Position = 0;
                environment[OwinConstants.ResponseBodyKey] = originalOutput;

                var response = new OwinHttpResponse(environment);

                if (IsGetHtmlRequest(environment) && response.StatusCode < 500)
                {
                    injectContent(environment, recordedStream, response);
                }
                else
                {
                    response.StreamContents(recordedStream);
                }
            });
        }
开发者ID:joemcbride,项目名称:fubumvc,代码行数:27,代码来源:HtmlHeadInjectionMiddleware.cs

示例2: Invoke

        /// <summary>
        /// 
        /// </summary>
        /// <param name="environment">OWIN environment dictionary which stores state information about the request, response and relevant server state.</param>
        /// <returns></returns>
        public Task Invoke(IDictionary<string, object> environment)
        {
            if (environment == null)
            {
                throw new ArgumentNullException("environment");
            }

            // No IPrincipal
            if (environment.Get<IPrincipal>(Constants.ServerUserKey) == null)
            {
                environment[Constants.ResponseStatusCodeKey] = 401;
                return GetCompletedTask();
            }

            // Anonymous IPrincipal
            var winPrincipal = environment.Get<IPrincipal>(Constants.ServerUserKey) as WindowsPrincipal;
            if (winPrincipal != null)
            {
                var winIdentity = winPrincipal.Identity as WindowsIdentity;
                if (winIdentity != null && winIdentity.IsAnonymous)
                {
                    environment[Constants.ResponseStatusCodeKey] = 401;
                    return GetCompletedTask();
                }
            }

            return _nextApp(environment);
        }
开发者ID:Kstal,项目名称:Microsoft.Owin,代码行数:33,代码来源:DenyAnonymousMiddleware.cs

示例3:

 void IConstructable.Construct(IDictionary<string, string> param)
 {
     if (param.Get("source", null) != null)
         Source = param.Get("source", null);
     else
         Source = File.Exists(param["sourceRef"]) ? File.ReadAllText(param["sourceRef"]) : "";
 }
开发者ID:rumkex,项目名称:Game,代码行数:7,代码来源:LuaComponent.cs

示例4: PrivateMessageCommand

        private void PrivateMessageCommand(IDictionary<string, object> command)
        {
            var sender = command.Get(Constants.Arguments.Character);
            if (!CharacterManager.IsOnList(sender, ListKind.Ignored))
            {
                if (ChatModel.CurrentPms.FirstByIdOrNull(sender) == null)
                    channels.AddChannel(ChannelType.PrivateMessage, sender);

                channels.AddMessage(command.Get(Constants.Arguments.Message), sender, sender);

                var temp = ChatModel.CurrentPms.FirstByIdOrNull(sender);
                if (temp == null)
                    return;

                temp.TypingStatus = TypingStatus.Clear; // webclient assumption
            }
            else
            {
                ChatConnection.SendMessage(
                    new Dictionary<string, object>
                    {
                        {Constants.Arguments.Action, Constants.Arguments.ActionNotify},
                        {Constants.Arguments.Character, sender},
                        {Constants.Arguments.Type, Constants.ClientCommands.UserIgnore}
                    });
            }
        }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:27,代码来源:PrivateMessageCommand.cs

示例5: LeaveChannelCommand

        private void LeaveChannelCommand(IDictionary<string, object> command)
        {
            var channelId = command.Get(Constants.Arguments.Channel);
            var characterName = command.Get(Constants.Arguments.Character);

            var channel = ChatModel.CurrentChannels.FirstByIdOrNull(channelId);
            if (ChatModel.CurrentCharacter.NameEquals(characterName))
            {
                if (channel != null)
                    channels.RemoveChannel(channelId, false, true);

                return;
            }

            if (channel == null)
                return;

            var ignoreUpdate = false;

            if (command.ContainsKey("ignoreUpdate"))
                ignoreUpdate = (bool) command["ignoreUpdate"];

            if (!channel.CharacterManager.SignOff(characterName) || ignoreUpdate) return;

            var updateArgs = new JoinLeaveEventArgs
            {
                Joined = false,
                TargetChannel = channel.Title,
                TargetChannelId = channel.Id
            };

            Events.NewCharacterUpdate(CharacterManager.Find(characterName), updateArgs);
        }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:33,代码来源:LeaveCommand.cs

示例6: Invoke

        public Task Invoke(IDictionary<string, object> env)
        {
            var opaqueUpgrade = env.Get<OpaqueUpgrade>("opaque.Upgrade");
            var webSocketAccept = env.Get<WebSocketAccept>(Constants.WebSocketAcceptKey);

            if (opaqueUpgrade != null
                && webSocketAccept == null
                && IsWebSocketRequest(env))
            {
                // Add websocket support
                env[Constants.WebSocketAcceptKey] = new WebSocketAccept(
                    (options, callback) =>
                    {
                        if (callback == null)
                        {
                            throw new ArgumentNullException("callback");
                        }

                        env[Constants.ResponseStatusCodeKey] = 101;

                        SetWebSocketResponseHeaders(env, options);

                        opaqueUpgrade(options,
                            opaqueEnv =>
                            {
                                var webSocket = new WebSocketLayer(opaqueEnv);
                                return callback(webSocket.Environment)
                                    .Then(() => webSocket.CleanupAsync());
                            });
                    });
            }

            return _next(env);
        }
开发者ID:tkggand,项目名称:katana,代码行数:34,代码来源:WebSocketMiddleware.cs

示例7: OnPivateMessageSendRequested

 private void OnPivateMessageSendRequested(IDictionary<string, object> command)
 {
     channels.AddMessage(
         command.Get(Constants.Arguments.Message),
         command.Get("recipient"),
         Constants.Arguments.ThisCharacter);
     connection.SendMessage(command);
 }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:8,代码来源:PrivateMessageCommand.cs

示例8: Map

 public void Map(IDictionary<string, object> document, Emitter emitter)
 {
     bool vacant = (bool)document.Get("vacant");
     string name = (string)document.Get("name");
     if (vacant && name != null)
     {
         emitter.Emit(name, vacant);
     }
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:9,代码来源:Test12_IndexView.cs

示例9: RedisLiveConnection

 public RedisLiveConnection(IDictionary<string, string> settings)
 {
     if (!settings.TryGet("host", out _Host))
     {
         throw new Exception("Redis host is required");
     }
     _Port = settings.Get("port", 6379);
     _Timeout = settings.Get("timeout", 2000);
 }
开发者ID:BlogTalkRadio,项目名称:Roque,代码行数:9,代码来源:RedisLiveConnection.cs

示例10: OwinRequestData

        public OwinRequestData(RouteData routeData, IDictionary<string, object> environment, ICurrentHttpRequest currentRequest)
        {
            AddValues(new RouteDataValues(routeData));
            AddValues(Querystring, new NamedKeyValues(HttpUtility.ParseQueryString(environment.Get<string>(OwinConstants.RequestQueryStringKey))));
            AddValues(FormPost, new NamedKeyValues(environment.Get<NameValueCollection>(OwinConstants.RequestFormKey)));

            AddValues(new CookieValueSource(new Cookies(currentRequest)));
            AddValues(new HeaderValueSource(currentRequest));
        }
开发者ID:NeilSorensen,项目名称:fubumvc,代码行数:9,代码来源:OwinRequestData.cs

示例11: OnLrpRequested

 private void OnLrpRequested(IDictionary<string, object> command)
 {
     channels.AddMessage(
         command.Get(Constants.Arguments.Message),
         command.Get(Constants.Arguments.Channel),
         Constants.Arguments.ThisCharacter,
         MessageType.Ad);
     connection.SendMessage(command);
 }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:9,代码来源:AdCommand.cs

示例12: InviteCommand

        private void InviteCommand(IDictionary<string, object> command)
        {
            var sender = command.Get(Constants.Arguments.Sender);
            var id = command.Get(Constants.Arguments.Name);
            var title = command.Get(Constants.Arguments.Title);

            var args = new ChannelInviteEventArgs {Inviter = sender};
            Events.NewChannelUpdate(ChatModel.FindChannel(id, title), args);
        }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:9,代码来源:InviteCommand.cs

示例13: Create

        public static IDisposable Create(Func<IDictionary<string, object>, Task> app, IDictionary<string, object> properties)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }

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

            var capabilities = properties.Get<IDictionary<string, object>>(OwinKeys.ServerCapabilitiesKey)
                               ?? new Dictionary<string, object>();

            var addresses = properties.Get<IList<IDictionary<string, object>>>("host.Addresses")
                            ?? new List<IDictionary<string, object>>();

            var servers = new List<INowinServer>();
            var endpoints = new List<IPEndPoint>();
            foreach (var address in addresses)
            {
                var builder = ServerBuilder.New().SetOwinApp(app);
                int port;
                if (!int.TryParse(address.Get<string>("port"), out port)) throw new ArgumentException("port must be number from 0 to 65535");
                builder.SetPort(port);
                builder.SetOwinCapabilities(capabilities);
                var certificate = address.Get<X509Certificate>("certificate");
                if (certificate != null)
                    builder.SetCertificate(certificate);
                servers.Add(builder.Build());
                endpoints.Add(new IPEndPoint(IPAddress.Loopback,port));
            }

            var disposer = new Disposer(servers.Cast<IDisposable>().ToArray());
            try
            {
                foreach (var nowinServer in servers)
                {
                    nowinServer.Start();
                }
                // This is workaround to Windows Server 2012 issue by calling ReadLine after AcceptAsync, by making one bogus connection this problem goes away
                foreach (var ipEndPoint in endpoints)
                {
                    var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
                    socket.Connect(ipEndPoint);
                    socket.Close();
                }
            }
            catch (Exception)
            {
                disposer.Dispose();
                throw;
            }
            return disposer;
        }
开发者ID:JuergenGutsch,项目名称:Nowin,代码行数:56,代码来源:OwinServerFactory.cs

示例14: OnTemporaryInterestedRequested

        private void OnTemporaryInterestedRequested(IDictionary<string, object> command)
        {
            var character = command.Get(Constants.Arguments.Character).ToLower().Trim();
            var add = command.Get(Constants.Arguments.Type) == "tempinteresting";

            characterManager.Add(
                character,
                add ? ListKind.Interested : ListKind.NotInterested,
                true);
        }
开发者ID:ZornTaov,项目名称:slimCat,代码行数:10,代码来源:InterestingCommand.cs

示例15: Invoke

        public Task Invoke(IDictionary<string, object> env)
        {
            IList<string> warnings = new List<string>();
            if (!TryValidateCall(env, warnings))
            {
                return TaskHelpers.Completed();
            }

            Stream originalStream = env.Get<Stream>("owin.ResponseBody");
            TriggerStream triggerStream = new TriggerStream(originalStream);
            env["owin.ResponseBody"] = triggerStream;

            // Validate response headers and values on first write.
            bool responseValidated = false;
            Action responseValidation = () =>
            {
                if (responseValidated)
                {
                    return;
                }

                responseValidated = true;

                if (!TryValidateResult(env, warnings))
                {
                    return;
                }

                if (warnings.Count > 0)
                {
                    var headers = env.Get<IDictionary<string, string[]>>(OwinConstants.ResponseHeaders);
                    headers["X-OwinValidatorWarning"] = warnings.ToArray();
                }
            };
            triggerStream.OnFirstWrite = responseValidation;

            try
            {
                return nextApp(env)
                    // Run response validation explicitly in case there was no response data written.
                    .Then(responseValidation)
                    .Catch(errorInfo =>
                    {
                        SetFatalResult(env, "6.1", "An asynchronous exception was thrown from the AppFunc: <br>"
                            + errorInfo.Exception.ToString().Replace(Environment.NewLine, "<br>"));
                        return errorInfo.Handled();
                    });
            }
            catch (Exception ex)
            {
                SetFatalResult(env, "6.1", "A synchronous exception was thrown from the AppFunc: <br>"
                            + ex.ToString().Replace(Environment.NewLine, "<br>"));
                return TaskHelpers.Completed();
            }
        }
开发者ID:majimenezp,项目名称:gate,代码行数:55,代码来源:PassiveValidator.cs


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