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


C# IDictionary类代码示例

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


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

示例1: GetTestableChat

        public static TestableChat GetTestableChat(string connectionId, StateChangeTracker clientState, ChatUser user, IDictionary<string, Cookie> cookies)
        {
            // setup things needed for chat
            var repository = new InMemoryRepository();
            var resourceProcessor = new Mock<IResourceProcessor>();
            var chatService = new Mock<IChatService>();
            var connection = new Mock<IConnection>();
            var settings = new Mock<IApplicationSettings>();
            var mockPipeline = new Mock<IHubPipelineInvoker>();

            // add user to repository
            repository.Add(user);

            // create testable chat
            var chat = new TestableChat(settings, resourceProcessor, chatService, repository, connection);
            var mockedConnectionObject = chat.MockedConnection.Object;

            chat.Clients = new HubConnectionContext(mockPipeline.Object, mockedConnectionObject, "Chat", connectionId, clientState);

            var prinicipal = new Mock<IPrincipal>();

            var request = new Mock<IRequest>();
            request.Setup(m => m.Cookies).Returns(cookies);
            request.Setup(m => m.User).Returns(prinicipal.Object);

            // setup context
            chat.Context = new HubCallerContext(request.Object, connectionId);

            return chat;
        }
开发者ID:ucdavis,项目名称:JabbR,代码行数:30,代码来源:ChatFacts.cs

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

示例3: CallAction

 private static void CallAction(Key key, IDictionary<Key, Action> delegates)
 {
     if (delegates.ContainsKey(key) && delegates[key] != null)
     {
         delegates[key]();
     }
 }
开发者ID:DannyGB,项目名称:OxTail,代码行数:7,代码来源:KeyboardHelper.cs

示例4: ClientPermissionsActionResult

 public ClientPermissionsActionResult(IViewService viewSvc, IDictionary<string, object> env, ClientPermissionsViewModel model)
     : base(async () => await viewSvc.ClientPermissions(model))
 {
     if (viewSvc == null) throw new ArgumentNullException("viewSvc");
     if (env == null) throw new ArgumentNullException("env");
     if (model == null) throw new ArgumentNullException("model");
 }
开发者ID:ridopark,项目名称:IdentityServer3,代码行数:7,代码来源:ClientPermissionsActionResult.cs

示例5: GetInt32

		public static int GetInt32(string property, IDictionary<string, string> properties, int defaultValue)
		{
			string toParse;
			properties.TryGetValue(property, out toParse);
			int result;
			return int.TryParse(toParse, out result) ? result : defaultValue;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:7,代码来源:PropertiesHelper.cs

示例6: BuildCacheStatic

		public static ICache BuildCacheStatic(string regionName, IDictionary<string,string> properties)
		{
			if (regionName != null && caches[regionName] != null)
			{
				return caches[regionName] as ICache;
			}

			if (regionName == null)
			{
				regionName = "";
			}
			if (properties == null)
			{
				properties = new Dictionary<string,string>();
			}
			if (log.IsDebugEnabled)
			{
				StringBuilder sb = new StringBuilder();
				foreach (KeyValuePair<string, string> de in properties)
				{
					sb.Append("name=");
					sb.Append(de.Key);
					sb.Append("&value=");
					sb.Append(de.Value);
					sb.Append(";");
				}
				log.Debug("building cache with region: " + regionName + ", properties: " + sb.ToString());
			}
			FooCache cache = new FooCache(regionName, properties);
			caches.Add(regionName, cache);
			return cache;
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:32,代码来源:Domain.cs

示例7: Invoke

        public async Task Invoke(IDictionary<string, object> environment)
        {
            int maxRedirects = _maxRedirects;

            while (maxRedirects >= 0)
            {
                await _next(environment);

                var response = new OwinResponse(environment);

                if (response.StatusCode == 302 || response.StatusCode == 301)
                {
                    string url = BuildRedirectUrl(response);

                    // Clear the env so we can make a new request
                    environment.Clear();

                    // Populate the env with new request data
                    RequestBuilder.BuildGet(environment, url);
                }
                else
                {
                    break;
                }

                maxRedirects--;
            }
        }
开发者ID:jango2015,项目名称:OwinHttpClient,代码行数:28,代码来源:RedirectMiddleware.cs

示例8: FormatRichTextPersistedDataForEditor

	    /// <summary>
	    /// This formats the persisted string to something useful for the rte so that the macro renders properly since we 
	    /// persist all macro formats like {?UMBRACO_MACRO macroAlias=\"myMacro\" /}
	    /// </summary>
	    /// <param name="persistedContent"></param>
	    /// <param name="htmlAttributes">The html attributes to be added to the div</param>
	    /// <returns></returns>
	    /// <remarks>
	    /// This converts the persisted macro format to this:
	    /// 
	    ///     {div class='umb-macro-holder'}
	    ///         <!-- <?UMBRACO_MACRO macroAlias=\"myMacro\" /> -->
	    ///         {ins}Macro alias: {strong}My Macro{/strong}{/ins}
	    ///     {/div}
	    /// 
	    /// </remarks>
	    internal static string FormatRichTextPersistedDataForEditor(string persistedContent, IDictionary<string ,string> htmlAttributes)
        {
            return MacroPersistedFormat.Replace(persistedContent, match =>
            {
                if (match.Groups.Count >= 3)
                {
                    //<div class="umb-macro-holder myMacro mceNonEditable">
                    var alias = match.Groups[2].Value;
                    var sb = new StringBuilder("<div class=\"umb-macro-holder ");
                    sb.Append(alias);
                    sb.Append(" mceNonEditable\"");
                    foreach (var htmlAttribute in htmlAttributes)
                    {
                        sb.Append(" ");
                        sb.Append(htmlAttribute.Key);
                        sb.Append("=\"");
                        sb.Append(htmlAttribute.Value);
                        sb.Append("\"");
                    }
                    sb.AppendLine(">");
                    sb.Append("<!-- ");
                    sb.Append(match.Groups[1].Value.Trim());
                    sb.Append(" />");
                    sb.AppendLine(" -->");
                    sb.Append("<ins>");
                    sb.Append("Macro alias: ");
                    sb.Append("<strong>");
                    sb.Append(alias);
                    sb.Append("</strong></ins></div>");
                    return sb.ToString();
                }
                //replace with nothing if we couldn't find the syntax for whatever reason
                return "";
            });
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:51,代码来源:MacroTagParser.cs

示例9: ParseAsync

        /// <summary>
        /// Tries to find a secret on the environment that can be used for authentication
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <returns>
        /// A parsed secret
        /// </returns>
        public async Task<ParsedSecret> ParseAsync(IDictionary<string, object> environment)
        {
            Logger.Debug("Start parsing for secret in post body");

            var context = new OwinContext(environment);
            var body = await context.ReadRequestFormAsync();

            if (body != null)
            {
                var id = body.Get("client_id");
                var secret = body.Get("client_secret");

                if (id.IsPresent() && secret.IsPresent())
                {
                    var parsedSecret = new ParsedSecret
                    {
                        Id = id,
                        Credential = secret,
                        Type = Constants.ParsedSecretTypes.SharedSecret
                    };

                    return parsedSecret;
                }
            }

            Logger.Debug("No secet in post body found");
            return null;
        }
开发者ID:nheijminkccv,项目名称:IdentityServer3,代码行数:35,代码来源:PostBodySecretParser.cs

示例10: Rectangle

 public Rectangle(IDictionary<ParamKeys, object> parameter)
     : base(parameter)
 {
     _edge1 = (double) parameter[ParamKeys.Edge1];
     _edge2 = (double) parameter[ParamKeys.Edge2];
     ShapeName = "Rectangle";
 }
开发者ID:VadymBratskyi,项目名称:Kottans-Homework,代码行数:7,代码来源:Rectangle.cs

示例11: SendEvent

 public async Task<HttpResponseMessage> SendEvent(string eventType, IDictionary<string, string> options) 
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, endpointUrl);
     request.Content = GetRequestContent(eventType, options);
     var response = await HttpClient.SendAsync(request).ConfigureAwait(false);
     return response;
 }
开发者ID:phw,项目名称:kryd-dotnet,代码行数:7,代码来源:Client.cs

示例12: DELETE

        public static string DELETE(string uri, IDictionary<string, string> args)
        {
            try {
                WebClient client = new WebClient();

                client.Encoding = Encoding.UTF8;

                client.Headers["Connection"] = "Keep-Alive";
                StringBuilder formattedParams = new StringBuilder();

                IDictionary<string, string> parameters = new Dictionary<string, string>();

                foreach (var arg in args)
                {
                    parameters.Add(arg.Key, arg.Value);
                    formattedParams.AppendFormat("{0}={{{1}}}", arg.Key, arg.Key);
                }

                //Formatted URI
                Uri baseUri = new Uri(uri);

                client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompletedDelete);

                client.UploadStringAsync(baseUri, "DELETE", string.Empty);
                allDone.Reset();
                allDone.WaitOne();

                return requestResult;
            }
            catch (WebException ex) {
                return ReadResponse(ex.Response.GetResponseStream());
            }
        }
开发者ID:Injac,项目名称:InstaSharp-for-Windows-Phone-,代码行数:33,代码来源:HttpClient.cs

示例13: GetInt64

		public static long GetInt64(string property, IDictionary<string, string> properties, long defaultValue)
		{
			string toParse;
			properties.TryGetValue(property, out toParse);
			long result;
			return long.TryParse(toParse, out result) ? result : defaultValue;
		}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:7,代码来源:PropertiesHelper.cs

示例14: GetValue

 public IItem GetValue(IDictionary<string, IItem> variables) {
   var stack = new Stack<object>();
   int i = 0;
   try {
     for (; i < tokens.Count; i++) {
       var token = tokens[i];
       double d;
       if (TryParse(token, out d)) {
         stack.Push(d);
       } else if (token.StartsWith("\"")) {
         stack.Push(GetVariableValue(variables, token.Substring(1, token.Length - 2).Replace("\\\"", "\"")));
       } else if (token.StartsWith("'")) {
         stack.Push(token.Substring(1, token.Length - 2).Replace("\\'", "'"));
       } else {
         Apply(token, stack, variables);
       }
     }
   } catch (Exception x) {
     throw new Exception(string.Format(
       "Calculation of '{1}'{0}failed at token #{2}: {3} {0}current stack is: {0}{4}", Environment.NewLine,
       Formula, i, TokenWithContext(tokens, i, 3),
       string.Join(Environment.NewLine, stack.Select(AsString))),
       x);
   }
   if (stack.Count != 1)
     throw new Exception(
       string.Format("Invalid final evaluation stack size {0} (should be 1) in formula '{1}'",
       stack.Count, Formula));
   var result = stack.Pop();
   if (result is string) return new StringValue((string)result);
   if (result is int) return new IntValue((int)result);
   if (result is double) return new DoubleValue((double)result);
   if (result is bool) return new BoolValue((bool)result);
   return null;
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:35,代码来源:Calculator.cs

示例15: ToSqlString

        public override SqlString ToSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery, IDictionary<string, IFilter> enabledFilters)
        {
            var sqlBuilder = new SqlStringBuilder();
            SqlString[] columnNames = null;

            if (_propertyName != "*")
            {
                columnNames = CriterionUtil.GetColumnNames(_propertyName, _projection, criteriaQuery, criteria, enabledFilters);

                if (columnNames.Length != 1)
                {
                    throw new HibernateException("Contains may only be used with single-column properties");
                }
            } else
            {
                columnNames = new SqlString[]
                                  {
                                      new SqlString("*")
                                  };
            }

            sqlBuilder.Add("contains(")
              .Add(columnNames[0])
              .Add(",");

            sqlBuilder.Add(criteriaQuery.NewQueryParameter(GetParameterTypedValue(criteria, criteriaQuery)).Single());
            sqlBuilder.Add(")");

            return sqlBuilder.ToSqlString();
        }
开发者ID:theriddlebrothers,项目名称:Honeypot,代码行数:30,代码来源:ContainsExpression.cs


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