本文整理汇总了C#中System.Collections.Specialized.NameValueCollection类的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection类的具体用法?C# NameValueCollection怎么用?C# NameValueCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NameValueCollection类属于System.Collections.Specialized命名空间,在下文中一共展示了NameValueCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTestableChat
public static TestableChat GetTestableChat(string clientId, TrackingDictionary clientState, ChatUser user, NameValueCollection 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>();
// add user to repository
repository.Add(user);
// create testable chat
var chat = new TestableChat(resourceProcessor, chatService, repository, connection);
var mockedConnectionObject = chat.MockedConnection.Object;
// setup client agent
chat.Agent = new ClientAgent(mockedConnectionObject, "Chat");
var request = new Mock<IRequest>();
request.Setup(m => m.Cookies).Returns(cookies);
// setup signal agent
var prinicipal = new Mock<IPrincipal>();
chat.Caller = new SignalAgent(mockedConnectionObject, clientId, "Chat", clientState);
// setup context
chat.Context = new HubContext(new HostContext(request.Object, null, prinicipal.Object), clientId);
return chat;
}
示例2: GetRecords
private PagedRecords GetRecords(
Entity entity,
NameValueCollection request,
TableInfo tableInfo,
Action<IList<BaseFilter>> filtersMutator)
{
var filterRecord = create_filter_record(entity, request);
var filters = _filterFactory.BuildFilters(filterRecord).ToList();
if (filtersMutator != null)
{
filtersMutator(filters);
}
var pagedRecords = _entitiesSource.GetRecords(
entity,
filters,
tableInfo.SearchQuery,
tableInfo.Order,
tableInfo.OrderDirection,
false,
tableInfo.Page,
tableInfo.PerPage);
pagedRecords.Filters = filters;
return pagedRecords;
}
示例3: CanDeserializeClientState
public void CanDeserializeClientState()
{
var clientState = new TrackingDictionary();
string clientId = "1";
var user = new ChatUser
{
Id = "1234",
Name = "John"
};
var cookies = new NameValueCollection();
cookies["jabbr.state"] = JsonConvert.SerializeObject(new ClientState { UserId = user.Id });
TestableChat chat = GetTestableChat(clientId, clientState, user, cookies);
bool result = chat.Join();
Assert.Equal("1234", clientState["id"]);
Assert.Equal("John", clientState["name"]);
Assert.True(result);
chat.MockedConnection.Verify(m => m.Broadcast("Chat." + clientId, It.IsAny<object>()), Times.Once());
chat.MockedChatService.Verify(c => c.AddClient(user, clientId), Times.Once());
chat.MockedChatService.Verify(c => c.UpdateActivity(user), Times.Once());
}
示例4: TransferujPlResponseFromNameValueCollectionDoesCorrectlySetOKState
void TransferujPlResponseFromNameValueCollectionDoesCorrectlySetOKState()
{
var items = new NameValueCollection { { "id", "123" }, { "tr_status", "TRUE" } };
var response = TransferujPlResponse.FromNameValueCollection(items);
Assert.True(response.Result);
}
示例5: WebPEncoderPlugin
public WebPEncoderPlugin(NameValueCollection args)
: this()
{
Lossless = ExtensionMethods.NameValueCollectionExtensions.Get<bool>(args, "lossless", Lossless);
Quality = ExtensionMethods.NameValueCollectionExtensions.Get<float>(args, "quality", Quality);
NoAlpha = ExtensionMethods.NameValueCollectionExtensions.Get<bool>(args, "noalpha", NoAlpha);
}
示例6: AuthenticateClient
public IAuthenticatedClient AuthenticateClient(IAuthenticationServiceSettings authenticationServiceSettings,
NameValueCollection queryStringParameters)
{
if (authenticationServiceSettings == null)
{
throw new ArgumentNullException("authenticationServiceSettings");
}
if (!string.IsNullOrEmpty(AuthenticateClientExceptionMessage))
{
throw new AuthenticationException(AuthenticateClientExceptionMessage);
}
return new AuthenticatedClient("facebook")
{
AccessToken = "EstSularusOthMithas-MyHonorIsMyLife",
AccessTokenExpiresOn = DateTime.UtcNow.AddDays(30),
UserInformation = UserInformation ?? new UserInformation
{
Gender = GenderType.Male,
Id = "FakeId-" + Guid.NewGuid().ToString(),
Locale = "en-au",
Name = "Sturm Brightblade",
Picture = "http://i.imgur.com/jtoOF.jpg",
UserName = "Sturm.Brightblade"
}
};
}
示例7: ArgumentsDynamic
public ArgumentsDynamic(NameValueCollection nameValueCollection)
{
this.args = nameValueCollection.Keys.OfType<string>()
.ToDictionary(k => k.ToString(),
k => nameValueCollection[(string)k],
StringComparer.InvariantCultureIgnoreCase);
}
示例8: HandleRequest
public override NameValueCollection HandleRequest(NameValueCollection request)
{
var response = new NameValueCollection();
response["redirect"] = GetRedirectUrl(request);
;
return response;
}
示例9: Valid_Code_Request
public async Task Valid_Code_Request()
{
var client = await _clients.FindClientByIdAsync("codeclient");
var store = new InMemoryAuthorizationCodeStore();
var code = new AuthorizationCode
{
Client = client,
RedirectUri = "https://server/cb",
RequestedScopes = new List<Scope>
{
new Scope
{
Name = "openid"
}
}
};
await store.StoreAsync("valid", code);
var validator = Factory.CreateTokenRequestValidator(
authorizationCodeStore: store);
var parameters = new NameValueCollection();
parameters.Add(Constants.TokenRequest.GrantType, Constants.GrantTypes.AuthorizationCode);
parameters.Add(Constants.TokenRequest.Code, "valid");
parameters.Add(Constants.TokenRequest.RedirectUri, "https://server/cb");
var result = await validator.ValidateRequestAsync(parameters, client);
result.IsError.Should().BeFalse();
}
示例10: BuildResult
protected void BuildResult(NameValueCollection formVariables)
{
this.HashDigest = formVariables["HashDigest"];
this.MerchantID = formVariables["MerchantID"];
this.CrossReference = formVariables["CrossReference"];
this.OrderID = formVariables["OrderID"];
}
示例11: API
public ActionResult API()
{
Stream filestream = null;
if (Request.Files.Count > 0)
{
filestream = Request.Files[0].InputStream;
}
var pars = new NameValueCollection();
pars.Add(Request.Params);
if (Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
{
var parsKeys = pars.AllKeys;
foreach (var key in Request.Form.AllKeys)
{
if (!parsKeys.Contains(key))
{
pars.Add(Request.Form);
}
}
}
var res = getRuntime.DesignerAPI(pars, filestream, true);
if (pars["operation"].ToLower() == "downloadscheme")
{
return File(Encoding.UTF8.GetBytes(res), "text/xml", "Scheme.xml");
}
return Content(res);
}
示例12: CallbackResult
public CallbackResult(NameValueCollection formVariables)
{
if (formVariables == null)
throw new ArgumentNullException("formVariables");
BuildResult(formVariables);
}
示例13: Convert
/// <summary>
/// 参数解析
/// </summary>
/// <param name="paramters"></param>
/// <param name="nvs"></param>
/// <returns></returns>
public static object[] Convert(ParameterInfo[] paramters, NameValueCollection nvs)
{
List<object> args = new List<object>();
var obj = ConvertJsonObject(nvs);
foreach (ParameterInfo info in paramters)
{
var type = GetElementType(info.ParameterType);
var property = obj.Properties().SingleOrDefault(p => string.Compare(p.Name, info.Name, true) == 0);
if (property != null)
{
try
{
//获取Json值
var jsonValue = CoreHelper.ConvertJsonValue(type, property.Value.ToString(Formatting.None));
args.Add(jsonValue);
}
catch (Exception ex)
{
throw new RESTfulException((int)HttpStatusCode.BadRequest, string.Format("Parameter [{0}] did not match type [{1}].",
info.Name, CoreHelper.GetTypeName(type)));
}
}
else
{
throw new RESTfulException((int)HttpStatusCode.BadRequest, "Parameter [" + info.Name + "] is not found.");
}
}
return args.ToArray();
}
示例14: GetParametersFromPath
public static MoreLikeThisQuery GetParametersFromPath(string path, NameValueCollection query)
{
var results = new MoreLikeThisQuery
{
IndexName = query.Get("index"),
Fields = query.GetValues("fields"),
Boost = query.Get("boost").ToNullableBool(),
BoostFactor = query.Get("boostFactor").ToNullableFloat(),
MaximumNumberOfTokensParsed = query.Get("maxNumTokens").ToNullableInt(),
MaximumQueryTerms = query.Get("maxQueryTerms").ToNullableInt(),
MaximumWordLength = query.Get("maxWordLen").ToNullableInt(),
MinimumDocumentFrequency = query.Get("minDocFreq").ToNullableInt(),
MaximumDocumentFrequency = query.Get("maxDocFreq").ToNullableInt(),
MaximumDocumentFrequencyPercentage = query.Get("maxDocFreqPct").ToNullableInt(),
MinimumTermFrequency = query.Get("minTermFreq").ToNullableInt(),
MinimumWordLength = query.Get("minWordLen").ToNullableInt(),
StopWordsDocumentId = query.Get("stopWords"),
AdditionalQuery= query.Get("query")
};
var keyValues = query.Get("docid").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var keyValue in keyValues)
{
var split = keyValue.IndexOf('=');
if (split >= 0)
results.MapGroupFields.Add(keyValue.Substring(0, split), keyValue.Substring(split + 1));
else
results.DocumentId = keyValue;
}
return results;
}
示例15: MoreLikeThisGet
public HttpResponseMessage MoreLikeThisGet()
{
var nameValueCollection = new NameValueCollection();
foreach (var queryNameValuePair in InnerRequest.GetQueryNameValuePairs())
{
nameValueCollection.Add(queryNameValuePair.Key, queryNameValuePair.Value);
}
var parameters = GetParametersFromPath(GetRequestUrl(), nameValueCollection);
parameters.TransformerParameters = ExtractTransformerParameters();
parameters.ResultsTransformer = GetQueryStringValue("resultsTransformer");
parameters.Includes = GetQueryStringValues("include");
var index = Database.IndexStorage.GetIndexInstance(parameters.IndexName);
if (index == null)
{
return GetMessageWithObject(new { Error = "The index " + parameters.IndexName + " cannot be found" },
HttpStatusCode.NotFound);
}
var indexEtag = Database.Indexes.GetIndexEtag(parameters.IndexName, null);
if (MatchEtag(indexEtag))
return GetEmptyMessage(HttpStatusCode.NotModified);
var result = Database.ExecuteMoreLikeThisQuery(parameters, GetRequestTransaction(), GetPageSize(Database.Configuration.MaxPageSize));
if (MatchEtag(result.Etag))
return GetEmptyMessage(HttpStatusCode.NotModified);
var msg = GetMessageWithObject(result.Result);
WriteETag(result.Etag, msg);
return msg;
}