private void SaveSettings() { FileInfo fi = new FileInfo("config\\" + _filename); DirectoryInfo di = new DirectoryInfo("config\\"); if (!di.Exists) { di.Create(); } StreamWriter sw; /* if (!fi.Exists) * fi.Create();*/ sw = fi.CreateText(); StringBuilder sb = new StringBuilder("<fiscal-settings>"); for (int i = 0; i < nvc.Count; i++) { sb.Append("<" + nvc.GetKey(i) + ">" + nvc[i] + "</" + nvc.GetKey(i) + ">"); } sb.Append("</fiscal-settings>"); sw.Write(sb.ToString()); sw.Close(); }
void Escape(System.IO.TextWriter writer, System.Collections.Specialized.NameValueCollection data, bool isHeader) { for (int i = 0, l = data.Count; i < l; i++) { if (isHeader == false) { writer.Write('&'); } isHeader = false; var value = data.Get(i); var key = data.GetKey(i); if (String.IsNullOrEmpty(key)) { if (String.IsNullOrEmpty(value) == false) { writer.Write(Uri.EscapeDataString(value)); } } else { writer.Write(Uri.EscapeDataString(data.GetKey(i))); if (value != null) { writer.Write('='); writer.Write(Uri.EscapeDataString(value)); } } } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection parameters) { if (string.IsNullOrEmpty((string)parameters["connectionName"])) { parameters.Remove("connectionName"); parameters.Add("connectionName", "PermissionsCenter"); } if (string.IsNullOrEmpty((string)parameters["sourceName"])) { parameters.Remove("sourceName"); parameters.Add("sourceName", "DefaultSource"); } this.connectionName = parameters["connectionName"]; this.sourceName = parameters["sourceName"]; base.Initialize(name, parameters); parameters.Remove("connectionName"); parameters.Remove("sourceName"); if (parameters.Count > 0) { string key = parameters.GetKey(0); if (!string.IsNullOrEmpty(key)) { throw new ProviderException(string.Format("不识别的属性: {0} ", key)); } } }
private void LookupAdapterTypes() { if (Adapter == null || HaveAdapterTypes) { return; } lock (LookupAdapterTypesLock) { if (HaveAdapterTypes) { return; } /* Lookup the types and store them for future use */ if (AdapterControlTypes == null) { AdapterControlTypes = new Type [Adapter.Count]; } if (AdapterTypes == null) { AdapterTypes = new Type [Adapter.Count]; } for (int i = 0; i <= Adapter.Count - 1; i++) { if (AdapterControlTypes [i] == null) { AdapterControlTypes [i] = FindType(Adapter.GetKey(i)); } if (AdapterTypes [i] == null) { AdapterTypes [i] = FindType(Adapter [i]); } } HaveAdapterTypes = true; } }
/// <summary> /// Initializes the provider with the given name and configuration values. /// </summary> public override void Initialize(String name, System.Collections.Specialized.NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = "SqlServerPollingProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SqlServer polling provider"); } base.Initialize(name, config); this.enableCookieVoteTracking = ConfigHelper.GetBooleanValue(config, "enableCookieVoteTracking", true); config.Remove("enableCookieVoteTracking"); this.connectionStringName = config["connectionStringName"]; this.connectionString = ConfigHelper.GetConnectionString(this.connectionStringName, name); config.Remove("connectionStringName"); if (config.Count > 0) { String firstInvalidKey = config.GetKey(0); if (firstInvalidKey != null && firstInvalidKey.Length > 0) { throw new ProviderException(String.Format(CultureInfo.InvariantCulture, Resources.Config_UnknownAttribute, firstInvalidKey)); } } }
/// <summary>Verifies that query parameters are valid.</summary> internal void VerifyQueryParameters() { HashSet <string> namesFound = new HashSet <string>(StringComparer.Ordinal); System.Collections.Specialized.NameValueCollection collection = this.operationContext.IncomingRequest.UriTemplateMatch.QueryParameters; for (int i = 0; i < collection.Count; i++) { string name = collection.GetKey(i); if (name == null) { // These are values of the form a&b&c, without '='. We just make sure they aren't system // values at all. string[] values = collection.GetValues(i); if (values != null) { for (int j = 0; j < values.Length; j++) { string value = values[j].Trim(); if (value.Length > 0 && value[0] == '$') { throw DataServiceException.CreateBadRequestError( Strings.HttpContextServiceHost_QueryParameterMustBeSpecifiedOnce(value)); } } } continue; } name = name.Trim(); if (!namesFound.Add(name)) { throw DataServiceException.CreateBadRequestError( Strings.HttpContextServiceHost_QueryParameterMustBeSpecifiedOnce(name)); } if (name.Length > 0 && name[0] == '$') { if (name != XmlConstants.HttpQueryStringExpand && name != XmlConstants.HttpQueryStringFilter && name != XmlConstants.HttpQueryStringOrderBy && name != XmlConstants.HttpQueryStringSkip && name != XmlConstants.HttpQueryStringSkipToken && name != XmlConstants.HttpQueryStringInlineCount && name != XmlConstants.HttpQueryStringTop && name != XmlConstants.HttpQueryStringSelect) { throw DataServiceException.CreateBadRequestError( Strings.HttpContextServiceHost_UnknownQueryParameter(name)); } string[] values = collection.GetValues(i); if (values == null || values.Length != 1) { throw DataServiceException.CreateBadRequestError( Strings.HttpContextServiceHost_QueryParameterMustBeSpecifiedOnce(name)); } } } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (string.IsNullOrEmpty(name)) { name = "SQLServerStorageProvider"; } // attribute doesn't exist or is empty if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SQLServer Storage provider"); } // Call the base class's Initialize method base.Initialize(name, config); // Initialize _applicationName _applicationName = config["applicationName"]; if (string.IsNullOrEmpty(_applicationName)) { _applicationName = "/"; } if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) { throw new ProviderException("Unrecognized attribute: " + attr); } } }
/// <summary> /// 初始化 /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = "BasicEnglishAutoInputProtectionTextProvider"; } if (string.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Basic English Auto-Input Protection Text Provider"); } base.Initialize(name, config); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) { throw new ProviderException(string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Errors.UnrecognizedAttribute", attr)); } } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (name == null || name.Length == 0) { name = "BusiBlocksFormsProvider"; } base.Initialize(name, config); this.mProviderName = name; //Read the configurations //Connection string string connName = ExtractConfigValue(config, "connectionStringName", null); mConfiguration = ConnectionParameters.Create(connName); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) { throw new System.Configuration.Provider.ProviderException("Unrecognized attribute: " + attr); } } }
"set_dev_coord|set_xml_data|save_app_settings".Split('|'); //白名单的data字段内容可以不参与危险字符检查 protected bool CheckSign(string act) { //白名单 bool white = false; foreach (string item in actWhiteList) { if (item == act) { white = true; break; } } bool safe = CheckUrl(); //检查传参安全性 System.Collections.Specialized.NameValueCollection fm = Request.Form; if (fm.Count > 0 && safe) { List <string> strList = new List <string>(); for (int i = 0; i < fm.Count; i++) { if (white && fm.GetKey(i) == "data") { continue; //跳过白名单data } strList.Add(fm[i].ToLower()); } safe = ProcessSqlStr(strList); } return(safe); }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (String.IsNullOrEmpty(name)) { name = "SenseNetPersonalizationProvider"; } if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "SenseNet Personalization Provider"); } base.Initialize(name, config); if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) { throw new ProviderException("Unrecognized attribute: " + attr); } } }
public void Config_Load(System.Collections.Specialized.NameValueCollection coll) { if (coll.Get("txtExcelTemp") != null && !coll.Get("txtExcelTemp").Equals("")) { //txtExcelTemp.Text = coll.Get("txtExcelTemp"); } //add system various lstVar.Items.Clear(); for (int i = 0; i < nvcSysVar.Count; i++) { lstVar.Items.Add(nvcSysVar.GetKey(i) + VAR_SPLIT_STRING + nvcSysVar[i]); } //restore excel file(template) list if (coll["VarList"] != null) { //if is defined by system and not has values,then replace it string[] slist = coll["VarList"].Replace("\n", "").Split('\r'); for (int i = 0; i < slist.Length; i++) { string line = slist[i]; int npos = line.IndexOf(VAR_SPLIT_STRING); if (npos > 0) { string sName = line.Substring(0, npos); for (int j = 0; j < lstVar.Items.Count; j++) { if (lstVar.Items[j].ToString().StartsWith(sName + VAR_SPLIT_STRING)) { if (lstVar.Items[j].ToString().Equals(sName + VAR_SPLIT_STRING)) { lstVar.Items[j] = line; } line = ""; break; } } if (!line.Equals("")) { lstVar.Items.Add(line); } } } } //restore excel file(table) list if (coll["TypeList"] != null) { lstType.Items.Clear(); string[] slist = coll["TypeList"].Replace("\n", "").Split('\r'); for (int i = 0; i < slist.Length; i++) { string line = slist[i]; int npos = line.IndexOf(VAR_SPLIT_STRING); if (npos > 0) { lstType.Items.Add(line); } } } }
/// <summary> /// Initialize /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { this.m_name = name; if (string.IsNullOrEmpty(config["description"])) { //throw new System.Configuration.Provider.ProviderException("You must specify a description attribute."); } else { this.m_description = config["description"]; config.Remove("description"); } if (config.Count > 0) { string extraAttribute = config.GetKey(0); if (!String.IsNullOrEmpty(extraAttribute)) { throw new System.Configuration.Provider.ProviderException( "The following unrecognized attribute was found in " + Name + "'s configuration: '" + extraAttribute + "'"); } else { throw new System.Configuration.Provider.ProviderException( "An unrecognized attribute was found in the provider's configuration."); } } }
/// <summary> /// POSTDATA字符串处理 /// </summary> /// <param name="postData">post字符串</param> /// <param name="delkey">需要去除的键值对</param> /// <param name="nvc">键值对集合</param> /// <returns> </returns> public static string UrlFilter(string postData, string delkey, out System.Collections.Specialized.NameValueCollection nvc) { int questionMarkIndex = postData.IndexOf('?'); if (questionMarkIndex == -1) { postData = "?" + postData; } ParseUrl(postData, out postData, out nvc); if (delkey != "" && nvc[delkey] != null) { nvc.Remove(delkey); } string result = ""; for (int i = 0; i < nvc.Count; i++) { result += nvc.GetKey(i) + "=" + nvc.Get(i) + "&"; } if (result.Length > 0) { result = result.Substring(0, result.Length - 1); } return(result); }
public virtual string ToXML() { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //doc.Name = "pays"; System.Xml.XmlElement pay = doc.CreateElement("pay"); pay.SetAttribute("prv_id", Prv_id.ToString()); pay.SetAttribute("amount", From_amount.ToString()); pay.SetAttribute("to-amount", To_amount.ToString()); pay.SetAttribute("txn_id", Txn_id); pay.SetAttribute("receipt", Recept.ToString()); pay.SetAttribute("txn_date", Txn_date.ToString("yyyyMMdd HH:mm:ss")); /* * foreach (string line in Ipaybox.curPay.Options.Split('|')) * { * if (line != "") * { * string[] param = line.Split('-'); * if (param[0] != null) * { * XmlElement extra = Ipaybox.pays.CreateElement("extra"); * if (param[1] == "account") * Ipaybox.curPay.account = param[2]; * extra.SetAttribute("name", param[1]); * extra.SetAttribute("value", param[2]); * extra.SetAttribute("CRC", Ipaybox.getMd5Hash("n" + param[1] + "v" + param[2])); * pay.AppendChild(extra); * } * } * } */ for (int i = 0; i < Extra.Count; i++) { if (!string.IsNullOrEmpty(Extra.GetKey(i))) { System.Xml.XmlElement extra = doc.CreateElement("extra"); extra.SetAttribute("name", Extra.GetKey(i)); extra.SetAttribute("value", Extra[i]); extra.SetAttribute("CRC", Ipaybox.getMd5Hash("n" + Extra.GetKey(i) + "v" + Extra[i])); pay.AppendChild(extra); } } doc.AppendChild(pay); return(doc.ChildNodes[0].ToString()); }
protected void Page_Load(object sender, EventArgs e) { string type = ""; string Re = ""; Re += "数据传送方式:"; if (Request.RequestType.ToUpper() == "POST") { type = "POST"; Re += type + "<br/>参数分别是:<br/>"; SortedList table = Param(); if (table != null) { foreach (DictionaryEntry De in table) { Re += "参数[:" + De.Key + " :" + De.Value + "]<br/>"; DoSaveFile(De.Key.ToString(), De.Value.ToString()); } } else { Re = "你没有传递任何参数过来!"; } } else if (Request.RequestType.ToUpper() == "GET") { type = "GET"; Re += type + "<br/>参数分别是:<br/>"; System.Collections.Specialized.NameValueCollection nvc = GETInput(); if (nvc.Count != 0) { for (int i = 0; i < nvc.Count; i++) { Re += "参数:[" + nvc.GetKey(i) + " :" + nvc.GetValues(i)[0] + "]<br/>"; DoSaveFile(nvc.GetKey(i), nvc.GetValues(i)[0]); } } else { Re = "你没有传递任何参数过来!"; } } Response.Write(Re); }
public static string ToQueryString(this System.Collections.Specialized.NameValueCollection values) { if (values == null && values.Count == 0) { return(string.Empty); } var sb = new StringBuilder(); for (int i = 0; i < values.Count; i++) { string text = values.GetKey(i); { text = System.Web.HttpUtility.UrlEncode(text); string key = (!string.IsNullOrEmpty(text)) ? (text + "=") : string.Empty; string[] vals = values.GetValues(i); if (sb.Length > 0) { sb.Append('&'); } if (vals == null || vals.Length == 0) { sb.Append(key); } else { if (vals.Length == 1) { sb.Append(key); sb.Append(System.Web.HttpUtility.UrlEncode(vals[0])); } else { for (int j = 0; j < vals.Length; j++) { if (j > 0) { sb.Append('&'); } sb.Append(key); sb.Append(System.Web.HttpUtility.UrlEncode(vals[j])); } } } } } if (sb.Length > 0) { sb.Insert(0, "?"); } return(sb.ToString()); }
///// <summary> ///// SetWebServiceAddress ///// </summary> ///// <param name="serverIp"></param> ///// <param name="serverPort"></param> //public void SetWebServiceAddress(string serverIp, short serverPort) //{ // string serviceAddress = m_webServiceAddress; // string httpName = "http://"; // if (m_webServiceAddress.StartsWith(httpName)) // { // int idx = serviceAddress.IndexOf('/', httpName.Length); // serviceAddress = serviceAddress.Substring(idx); // } // m_manager = new WebServiceManager("http://" + serverIp + ":" + serverPort + serviceAddress); //} /// <summary> /// Initialize /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if ((config == null) || (config.Count == 0)) { throw new ArgumentNullException("You must supply a valid configuration parameters.", "config"); } this.m_name = name; if (string.IsNullOrEmpty(config["description"])) { //throw new System.Configuration.Provider.ProviderException("You must specify a description attribute."); } else { this.m_description = config["description"]; config.Remove("description"); } string webServiceAddress; if (string.IsNullOrEmpty(config["webServiceAddress"])) { webServiceAddress = string.Format("{0}/{1}/WebLogin.asmx", SystemConfiguration.Server, SystemConfiguration.ApplicationName); //throw new System.Configuration.Provider.ProviderException("The webServiceAddress is invalid."); } else { webServiceAddress = config["webServiceAddress"]; } config.Remove("webServiceAddress"); if (config.Count > 0) { string extraAttribute = config.GetKey(0); if (!String.IsNullOrEmpty(extraAttribute)) { throw new System.Configuration.Provider.ProviderException( "The following unrecognized attribute was found in " + Name + "'s configuration: '" + extraAttribute + "'"); } else { throw new System.Configuration.Provider.ProviderException( "An unrecognized attribute was found in the provider's configuration."); } } //ConnectionStringsSection cs = // (ConnectionStringsSection)ConfigurationManager.GetSection("connectionStrings"); //if (cs == null) // throw new ProviderException("An error occurred retrieving the connection strings section."); //if (cs.ConnectionStrings[connectionString] == null) // throw new ProviderException("The connection string could not be found in the connection strings section."); //else // ConnectionString = cs.ConnectionStrings[connectionString].ConnectionString; m_manager = new WebServiceManager(webServiceAddress); }
private string Key2String(System.Collections.Specialized.NameValueCollection k) { string keystring = ","; for (int i = 0; k != null && i < k.Count; i++) { keystring += k.GetKey(i) + ','; } return(keystring); }
/// <summary> /// 把传参参数转成路由参数 /// </summary> /// <param name="nvc"></param> /// <returns></returns> public static System.Web.Routing.RouteValueDictionary ToRouteValueDictionary(this System.Collections.Specialized.NameValueCollection nvc) { var dict = new System.Web.Routing.RouteValueDictionary(); for (var i = 0; i < nvc.Count; i++) { var key = nvc.GetKey(i); dict[key] = nvc[i]; } return(dict); }
public static TivoTree FromNameValueCollection(System.Collections.Specialized.NameValueCollection collection) { TivoTree tree = new TivoTree(); int count = collection.Count; for (int i = 0; i < count; ++i) { tree.AddRange(collection.GetKey(i), collection.GetValues(i)); } return(tree); }
private List <string> collToList(System.Collections.Specialized.NameValueCollection collection) { var result = new List <string>(); for (var i = 0; i < collection.Count; i++) { result.Add("{0} = {1}".Args(collection.GetKey(i), collection[i])); } return(result); }
protected void ZapiszAktywnePytanieDoCookie(int numer) { HttpCookie myCookie = new HttpCookie("DaneAnkiety"); if (Request.Cookies["DaneAnkiety"] != null)//.HasKeys) { System.Collections.Specialized.NameValueCollection pary = Request.Cookies["DaneAnkiety"].Values; for (int i = 0; i < pary.Count; i++) { myCookie[pary.GetKey(i)] = pary[pary.GetKey(i)]; } } Request.Cookies.Clear(); myCookie["ap"] = Convert.ToString(numer); myCookie.Expires = DateTime.Now.AddDays(1d);//ile? 30 min? Response.Cookies.Add(myCookie); }
/// <summary> /// 通过健/值,来取配设置对应属性值 /// </summary> /// <param name="obj"></param> /// <param name="nv"></param> public static void SetProperty(object obj, System.Collections.Specialized.NameValueCollection nv) { if (obj == null) { throw new ArgumentNullException("obj"); } if (nv == null) { throw new ArgumentNullException("nv"); } Hashtable table = new Hashtable(); for (int i = 0; i < nv.Count; i++) { if (!String.IsNullOrEmpty(nv.GetKey(i))) { table[nv.GetKey(i)] = nv[i]; } } SetProperty(obj, table); }
byte[] PackageValueNameValueCollection(KeyEntry keyEntry, Entry entry, Type type) { TreePackage package = new TreePackage(); System.Collections.Specialized.NameValueCollection col = (System.Collections.Specialized.NameValueCollection)entry.Value; for (int i = 0; i < col.Count; i++) { package.Add(i.ToString(), col.GetValues(i)); package.Entries[i.ToString()].Attributes.Add("Key", col.GetKey(i)); } return(package.Save()); }
private System.Xml.XmlElement GetNode(System.Xml.XmlDocument xmlDoc, string strName, System.Collections.Specialized.NameValueCollection xmlAttributes, string xmlInnerText) { System.Xml.XmlElement xmlEle; xmlEle = xmlDoc.CreateElement(strName); xmlEle.InnerText = xmlInnerText; if (xmlAttributes != null) { for (int i = 0; i < xmlAttributes.Count; i++) { xmlEle.SetAttribute(xmlAttributes.GetKey(i), null, xmlAttributes[i]); } } return(xmlEle); }
public void SetEditions(System.Collections.Specialized.NameValueCollection editions) { lbEditions.Items.Clear(); for (int index = 0; index < editions.Count; index++) { global::Controls.ListBoxExItem lbItem = new global::Controls.ListBoxExItem(editions[index]); lbItem.Tag = editions.GetKey(index); lbEditions.Items.Add(lbItem); } lbEditions.SelectedIndex = 0; }
/// <summary> /// Returns query string based on provided parameter (in form A=B&C=D&E=F) /// </summary> /// <param name="nameValueCollection"></param> /// <returns></returns> private static string BuildQueryString(System.Collections.Specialized.NameValueCollection nameValueCollection) { string queryString = ""; for (int i = 0; i < nameValueCollection.Count; i++) { if (i > 0) { queryString += "&"; } queryString += nameValueCollection.GetKey(i) + "=" + nameValueCollection[i]; } return(queryString); }
private static XmlElement CreateNode(System.Xml.XmlDocument oRoot, string strName, System.Collections.Specialized.NameValueCollection oAttributes, string sInnerText) { System.Xml.XmlElement oElement; oElement = oRoot.CreateElement(strName); oElement.InnerText = sInnerText; if (oAttributes != null) { for (int i = 0; i < oAttributes.Count; i++) { oElement.SetAttribute(oAttributes.GetKey(i), null, oAttributes[i]); } } return(oElement); }
public Result Pay3D(Request request, System.Collections.Specialized.NameValueCollection collection) { for (int i = 0; i < collection.Count; i++) { request.Accounts.Add(collection.GetKey(i), collection[i]); } Post prepaire = new Post(); prepaire.Request = request; prepaire.ConfigName = "YKB_Pay_3DEnd.xml"; prepaire.ContentType = "application/x-www-form-urlencoded"; prepaire.RequestFormat = RestSharp.DataFormat.Xml; prepaire.PreTag = "xmldata="; return(HTTPClient.SingleInstance.Post(prepaire, Handler)); }
private static void Member(JsonTextWriter writer, string name, NameValueCollection collection) { Debug.Assert(writer != null); Debug.AssertStringNotEmpty(name); // // Bail out early if the collection is null or empty. // if (collection == null || collection.Count == 0) return; // // Save the depth, which we'll use to lazily emit the collection. // That is, if we find that there is nothing useful in it, then // we could simply avoid emitting anything. // var depth = writer.Depth; // // For each key, we get all associated values and loop through // twice. The first time round, we count strings that are // neither null nor empty. If none are found then the key is // skipped. Otherwise, second time round, we encode // strings that are neither null nor empty. If only such string // exists for a key then it is written directly, otherwise // multiple strings are naturally wrapped in an array. // var items = from i in Enumerable.Range(0, collection.Count) let values = collection.GetValues(i) where values != null && values.Length > 0 let some = // Neither null nor empty from v in values where !string.IsNullOrEmpty(v) select v let nom = some.Take(2).Count() where nom > 0 select new { Key = collection.GetKey(i), IsArray = nom > 1, Values = some, }; foreach (var item in items) { // // There is at least one value so now we emit the key. // Before doing that, we check if the collection member // was ever started. If not, this would be a good time. // if (depth == writer.Depth) { writer.Member(name); writer.Object(); } writer.Member(item.Key ?? string.Empty); if (item.IsArray) writer.Array(); // Wrap multiples in an array foreach (var value in item.Values) writer.String(value); if (item.IsArray) writer.Pop(); // Close multiples array } // // If we are deeper than when we began then the collection was // started so we terminate it here. // if (writer.Depth > depth) writer.Pop(); }
/// <summary> /// load collection with saved options from the xml config file /// </summary> private void InitSavedOptionsCollection(ref string ErrorMessage) { IEnumerable<System.Xml.Linq.XElement> SavedOptions; m_SaveOptionCollection = new System.Collections.Specialized.NameValueCollection(); m_SaveOptionCollection.Add("RememberLastSurveyID", ""); m_SaveOptionCollection.Add("TransectTotal", ""); m_SaveOptionCollection.Add("StartX", ""); m_SaveOptionCollection.Add("StartY", ""); m_SaveOptionCollection.Add("MaxTransLineLength", ""); m_SaveOptionCollection.Add("BlindAreaBuffer", ""); m_SaveOptionCollection.Add("BufferDistance", ""); m_SaveOptionCollection.Add("BufferFCName", ""); m_SaveOptionCollection.Add("MinTransLineLength", ""); m_SaveOptionCollection.Add("MaxElevation", ""); m_SaveOptionCollection.Add("MaxSlope", ""); m_SaveOptionCollection.Add("MinSlope", ""); m_SaveOptionCollection.Add("ImportDataPath", ""); m_SaveOptionCollection.Add("ExportDataPath", ""); m_SaveOptionCollection.Add("GridPointSpacing", ""); m_SaveOptionCollection.Add("TotalRandomPoints", ""); m_SaveOptionCollection.Add("SurveyID", ""); m_SaveOptionCollection.Add("DemFileLocation", ""); SavedOptions = m_XMLConfig.Descendants("NPSConfig"); foreach (System.Xml.Linq.XElement ThisOption in SavedOptions) { for (int Index = 0; Index < m_SaveOptionCollection.Keys.Count; Index++) { if (m_SaveOptionCollection.GetKey(Index).ToLower() == ThisOption.Name.LocalName.ToLower()) m_SaveOptionCollection[m_SaveOptionCollection.GetKey(Index)] = ThisOption.Value; } } SavedOptions = m_XMLConfig.Descendants("StoredOptions"); foreach (System.Xml.Linq.XElement ThisOption in SavedOptions) { for (int Index = 0; Index < m_SaveOptionCollection.Keys.Count; Index++) { if (m_SaveOptionCollection.GetKey(Index).ToLower() == ThisOption.Name.LocalName.ToLower()) m_SaveOptionCollection[m_SaveOptionCollection.GetKey(Index)] = ThisOption.Value; } } }