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


C# NameValueCollection.Combine方法代码示例

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


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

示例1: Combine

        public void Combine()
        {
            var one = new NameValueCollection
            {
                {"A", "1"}
            };

            var two = new NameValueCollection
            {
                {"A", "2"},
                {"B", "2"}
            };

            var three = new NameValueCollection
            {
                {"A", "3"},
                {"B", "3"},
                {"C", "3"}
            };

            var result = one.Combine(two, three);

            Assert.Equal(3, result.AllKeys.Length);
            Assert.Equal("1", result["A"]);
            Assert.Equal("2", result["B"]);
            Assert.Equal("3", result["C"]);
        }
开发者ID:tdupont750,项目名称:ConfigurationExtensions,代码行数:27,代码来源:NameValueCollectionExtensionsTests.cs

示例2: CreateIssuerViaWeb

        public static int? CreateIssuerViaWeb(List<DeepBlue.Models.Entity.Issuer> dbIssuers, CookieCollection cookies)
        {
            int? issuerId = null;
            ImportErrors = new List<KeyValuePair<Models.Entity.Issuer, Exception>>();
            TotalImportRecords = 0;
            RecordsImportedSuccessfully = 0;
            foreach (DeepBlue.Models.Entity.Issuer issuer in dbIssuers) {
                NameValueCollection formValues = new NameValueCollection();
                TotalImportRecords++;
                try {
                    IssuerDetailModel model = new IssuerDetailModel();
                    model.CountryId = Globals.DefaultCountryID;
                    model.AnnualMeetingDate = DateTime.Now.Date;
                    model.Name = issuer.Name;

                    formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty));

                    // Send the request
                    string url = HttpWebRequestUtil.GetUrl("Deal/CreateIssuer");
                    byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues));
                    HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies);
                    if (response.StatusCode == System.Net.HttpStatusCode.OK) {
                        using (Stream receiveStream = response.GetResponseStream()) {
                            // Pipes the stream to a higher level stream reader with the required encoding format.
                            using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                                string resp = readStream.ReadToEnd();
                                issuerId = HttpWebRequestUtil.GetNewKeyFromResponse(resp);
                                if (issuerId != null) {
                                    RecordsImportedSuccessfully++;
                                } else {
                                    ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Issuer, Exception>(issuer, new Exception(resp)));
                                }
                                response.Close();
                                readStream.Close();
                            }
                        }

                    }
                } catch (Exception ex) {
                    ImportErrors.Add(new KeyValuePair<DeepBlue.Models.Entity.Issuer, Exception>(issuer, ex));
                }
            }
            LogErrors(ImportErrors);
            return issuerId;
        }
开发者ID:jsingh,项目名称:DeepBlue,代码行数:45,代码来源:Issuer.cs

示例3: ImportInvestors

        public static NameValueCollection ImportInvestors(CookieCollection cookies)
        {
            NameValueCollection values = new NameValueCollection();
            ImportErrors = new List<KeyValuePair<Models.Entity.Investor, Exception>>();
            TotalImportRecords = 0;
            RecordsImportedSuccessfully = 0;
            List<DeepBlue.Models.Entity.Investor> dbInvestors = ConvertBlueToDeepBlue();
            LogErrors(Errors);
            foreach (DeepBlue.Models.Entity.Investor investor in dbInvestors) {
                // make sure that the investor doesnt already exist
                List<Models.Entity.Investor> existingInvestors = GetInvestors(cookies, null, investor.InvestorName);
                if (existingInvestors.Count > 0) {
                    //make sure the name match exactly
                    Models.Entity.Investor inv = existingInvestors.Where(x => x.InvestorName.Equals(investor.InvestorName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (inv != null) {
                        // investor already exists
                        Util.WriteWarning(string.Format("Investor: {0} already exists. Found investor: Investor Name: {1}, InvestorID: {2}", investor.InvestorName, inv.InvestorName, inv.InvestorID));
                        continue;
                    }
                }

                NameValueCollection formValues = new NameValueCollection();
                TotalImportRecords++;
                try {
                    CreateModel model = new CreateModel();
                    model.Alias = investor.Alias;
                    model.DomesticForeign = investor.IsDomestic;
                    model.EntityType = investor.InvestorEntityTypeID;
                    model.InvestorName = investor.InvestorName;
                    model.Alias = investor.FirstName;
                    model.StateOfResidency = investor.ResidencyState.Value;
                    model.SocialSecurityTaxId = investor.Social;
                    model.Notes = investor.Notes;

                    #region Investor's Address
                    InvestorAddress investorAddress = investor.InvestorAddresses.First();
                    Address address = investorAddress.Address;
                    model.Address1 = address.Address1 ?? "";
                    model.Address2 = address.Address2 ?? "";
                    model.City = address.City ?? "";
                    model.Country = address.Country;
                    model.Zip = address.PostalCode;
                    model.State = address.State.Value;
                    #endregion

                    #region Investor's communication (email, fax etc)
                    List<InvestorCommunication> investorComms = investor.InvestorCommunications.ToList();
                    foreach (InvestorCommunication comm in investorComms) {
                        if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.HomePhone) {
                            model.Phone = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Email) {
                            model.Email = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.WebAddress) {
                            model.WebAddress = comm.Communication.CommunicationValue;
                        } else if (comm.Communication.CommunicationTypeID == (int)Models.Admin.Enums.CommunicationType.Fax) {
                            model.Fax = comm.Communication.CommunicationValue;
                        }
                    }
                    #endregion

                    #region Investor's Accounts
                    int counter = 0;
                    foreach (InvestorAccount investorAccount in investor.InvestorAccounts.ToList()) {
                        // if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "BankIndex"]) <= 0) continue;
                        formValues.Add(++counter + "_BankIndex", counter.ToString());

                        // Only the following form keys have name different from the object properties
                        //investorAccount.Routing = DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ABANumber"]);
                        //investorAccount.FFCNumber = Convert.ToString(collection[(index + 1).ToString() + "_" + "FFCNO"]);
                        //investorAccount.Account = Convert.ToString(collection[(index + 1).ToString() + "_" + "AccountNumber"]);
                        if (investorAccount.Routing != null) {
                            formValues.Add(counter + "_ABANumber", investorAccount.Routing.ToString());
                        }
                        if (!string.IsNullOrEmpty(investorAccount.FFCNumber)) {
                            formValues.Add(counter + "_FFCNO", investorAccount.FFCNumber.ToString());
                        }
                        if (!string.IsNullOrEmpty(investorAccount.Account)) {
                            formValues.Add(counter + "_AccountNumber", investorAccount.Account.ToString());
                        }
                        formValues = formValues.Combine(HttpWebRequestUtil.SetUpForm(investorAccount, counter + "_", string.Empty));
                    }
                    model.AccountLength = counter;
                    #endregion

                    #region Investor's contact
                    counter = 0;
                    foreach (InvestorContact investorContact in investor.InvestorContacts) {
                        counter++;
                        //if (DataTypeHelper.ToInt32(collection[(index + 1).ToString() + "_" + "ContactIndex"]) <= 0) continue;
                        formValues.Add(counter + "_ContactIndex", counter.ToString());
                        Contact contact = investorContact.Contact;
                        // Only the following form keys have name different from the object properties
                        //investorContact.Contact.ContactName = Convert.ToString(collection[(index + 1).ToString() + "_" + "ContactPerson"]);
                        //investorContact.Contact.ReceivesDistributionNotices = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "DistributionNotices"]);
                        //investorContact.Contact.ReceivesFinancials = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "Financials"]);
                        //investorContact.Contact.ReceivesInvestorLetters = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "InvestorLetters"]);
                        //investorContact.Contact.ReceivesK1 = DataTypeHelper.CheckBoolean(collection[(index + 1).ToString() + "_" + "K1"]);
                        if (!string.IsNullOrEmpty(contact.ContactName)) {
                            formValues.Add(counter + "_ContactPerson", contact.ContactName);
                        }
//.........这里部分代码省略.........
开发者ID:jsingh,项目名称:DeepBlue,代码行数:101,代码来源:Investor.cs

示例4: CreateUnderlyingFundAddress

        public static NameValueCollection CreateUnderlyingFundAddress(int underlyingFundId, Address address, CookieCollection cookies, out string resp)
        {
            resp = string.Empty;
            NameValueCollection values = new NameValueCollection();
            UnderlyingFundAddressInformation registeredAddress = new UnderlyingFundAddressInformation();
            registeredAddress.UnderlyingFundId = underlyingFundId;
            registeredAddress.Address1 = address.Address1;
            registeredAddress.Address2 = address.Address2;
            registeredAddress.City = address.City;
            registeredAddress.Country = address.Country;
            registeredAddress.State = address.State;
            registeredAddress.Zip = address.PostalCode;

            NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(registeredAddress, string.Empty, string.Empty);
            // Send the request
            string url = HttpWebRequestUtil.GetUrl("Deal/CreateUnderlyingFundAddress");
            messageLog.AppendLine("Deal/CreateUnderlyingFundAddress");
            string data = HttpWebRequestUtil.ToFormValue(formValues);
            messageLog.AppendLine("Form Data: " + data);
            byte[] postData = System.Text.Encoding.ASCII.GetBytes(data);
            HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies);
            if (response.StatusCode == System.Net.HttpStatusCode.OK) {
                using (Stream receiveStream = response.GetResponseStream()) {
                    // Pipes the stream to a higher level stream reader with the required encoding format.
                    using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                        resp = readStream.ReadToEnd();
                        if (string.IsNullOrEmpty(resp)) {
                           values = values.Combine(formValues);
                        } else {
                        }
                        messageLog.AppendLine("Response: "+resp);
                        response.Close();
                        readStream.Close();
                    }
                }
            }
            return values;
        }
开发者ID:jsingh,项目名称:DeepBlue,代码行数:38,代码来源:UnderlyingFund.cs


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