public Arguments(string[] args) { _params = new StringDictionary(); Regex spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled); Regex remover = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled); string parm = null; string[] parts; foreach (var a in args) { parts = spliter.Split(a, 3); switch (parts.Length) { case 1: if (parm != null) { if (!_params.ContainsKey(parm)) { parts[0] = remover.Replace(parts[0], "$1"); _params.Add(parm, parts[0]); } parm = null; } break; case 2: if (parm != null) { if (!_params.ContainsKey(parm)) _params.Add(parm, "true"); } parm = parts[1]; break; case 3: if (parm != null) { if (!_params.ContainsKey(parm)) _params.Add(parm, "true"); } parm = parts[1]; if (!_params.ContainsKey(parm)) { parts[2] = remover.Replace(parts[2], "$1"); _params.Add(parm, parts[2]); } parm = null; break; } } if (parm != null) { if (!_params.ContainsKey(parm)) _params.Add(parm, "true"); } }
// Constructor public Arguments(string[] Args) { Parameters=new StringDictionary(); Regex Spliter=new Regex(@"^-{1,2}|^/|=|:",RegexOptions.IgnoreCase|RegexOptions.Compiled); Regex Remover= new Regex(@"^['""]?(.*?)['""]?$",RegexOptions.IgnoreCase|RegexOptions.Compiled); string Parameter=null; string[] Parts; // Valid parameters forms: // {-,/,--}param{ ,=,:}((",')value(",')) // Examples: -param1 value1 --param2 /param3:"Test-:-work" /param4=happy -param5 '--=nice=--' foreach(string Txt in Args){ // Look for new parameters (-,/ or --) and a possible enclosed value (=,:) Parts=Spliter.Split(Txt,3); switch(Parts.Length){ // Found a value (for the last parameter found (space separator)) case 1: if(Parameter!=null){ if(!Parameters.ContainsKey(Parameter)){ Parts[0]=Remover.Replace(Parts[0],"$1"); Parameters.Add(Parameter,Parts[0]); } Parameter=null; } // else Error: no parameter waiting for a value (skipped) break; // Found just a parameter case 2: // The last parameter is still waiting. With no value, set it to true. if(Parameter!=null){ if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true"); } Parameter=Parts[1]; break; // Parameter with enclosed value case 3: // The last parameter is still waiting. With no value, set it to true. if(Parameter!=null){ if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true"); } Parameter=Parts[1]; // Remove possible enclosing characters (",') if(!Parameters.ContainsKey(Parameter)){ Parts[2]=Remover.Replace(Parts[2],"$1"); Parameters.Add(Parameter,Parts[2]); } Parameter=null; break; } } // In case a parameter is still waiting if(Parameter!=null){ if(!Parameters.ContainsKey(Parameter)) Parameters.Add(Parameter,"true"); } }
public void TestComplexKeepOldJoininUri() { Uri source = new Uri( "http://www.localhost.name/path/page?query=value¶m=values" ); string pathAndQuery = "/otherpath/otherpage?newquery=newvalue¶m=othervalue"; Uri result = new Uri( source, pathAndQuery ); StringDictionary queryParameters = new StringDictionary(); // add the new parameters foreach (string parameter in result.Query.Trim("?&".ToCharArray()).Split("&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) { string name = parameter.Split("=".ToCharArray())[0]; string value = parameter.Substring(name.Length + 1); if (queryParameters.ContainsKey(name)) // do not duplicate a parameter, keep last value { queryParameters[name] = value; } else { queryParameters.Add(name, value); } } // keep the original set foreach ( string parameter in source.Query.Trim( "?&".ToCharArray() ).Split( "&".ToCharArray(), StringSplitOptions.RemoveEmptyEntries ) ) { string name = parameter.Split( "=".ToCharArray() )[0]; string value = parameter.Substring( name.Length + 1 ); if ( queryParameters.ContainsKey( name ) ) // do not duplicate a parameter, keep last original value { queryParameters[name] = value; } else { queryParameters.Add( name, value ); } } // recreate the uri result = new Uri(result.GetLeftPart(UriPartial.Path)); StringBuilder query = new StringBuilder(); foreach (string key in queryParameters.Keys) { if (query.Length > 0) { query.AppendFormat("&{0}={1}", key, queryParameters[key]); } else { query.AppendFormat( "?{0}={1}", key, queryParameters[key] ); } } result = new Uri(result.ToString() + query.ToString()); Debug.WriteLine( "Complex Join Maintain Original " + result ); }
public new void Configure(StringDictionary attributes) { base.Configure(attributes); if (attributes.ContainsKey("XPathNamespace")) { XPathNamespace = attributes["XPathNamespace"]; } if (attributes.ContainsKey("XPath")) { XPath = attributes["XPath"]; } }
public void Configure(StringDictionary attributes) { if (attributes.ContainsKey("SharePointVersions")) { sharePointVersions = attributes["SharePointVersions"]; } if (attributes.ContainsKey("NotSandboxSupported")) { try { notSandboxSupported = Boolean.Parse(attributes["NotSandboxSupported"]); } catch { } } }
/// <summary> /// Replaces one or more placeholders in a string with the specified values. /// </summary> /// <param name="format">The composite format string.</param> /// <param name="args"> /// A string dictionary containing the placeholder names and values that /// they are to be replaced with. /// </param> /// <param name="date"> /// A <see cref="DateTime"/> object to format dates and times with. /// </param> /// <returns> /// A new string with the placeholders replaced by their values. /// </returns> public static string Format(string format, StringDictionary args, DateTime date) { if (format == null) return null; if (args == null) return format; var stringBuilder = new StringBuilder(format.Length); var i = 0; var c = '\0'; while (i < format.Length) { c = format[i]; i++; if (c == PlaceholderStart) { var end = format.IndexOf(PlaceholderEnd, i); if (end <= i) { var message = SR.ExpectedAtPos.With(PlaceholderEnd, i); throw new FormatException(message); } var placeholder = format.Substring(i, end - i); var value = args[placeholder]; if (!args.ContainsKey(placeholder)) { try { value = date.ToString(placeholder); } catch (Exception ex) { var message = SR.InvalidPlaceholder.With(placeholder); throw new FormatException(message, ex); } } stringBuilder.Append(RemoveInvalidFilenameChars(value)); i = end + 1; } else if (c == PlaceholderEscape) { if (i >= format.Length) { var message = SR.EndOfString.With(PlaceholderEscape); throw new FormatException(message); } stringBuilder.Append(format[i]); i++; } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); }
static void Main(string[] args) { System.Collections.Specialized.StringDictionary stringDictionary = new System.Collections.Specialized.StringDictionary(); stringDictionary.Add("Test1", "Test@123"); stringDictionary.Add("Admin", "Admin@123"); stringDictionary.Add("Temp", "Temp@123"); stringDictionary.Add("Demo", "Demo@123"); stringDictionary.Add("Test2", "Test2@123"); stringDictionary.Remove("Admin"); if (stringDictionary.ContainsKey("Admin")) { Console.WriteLine("UserName already Esists"); } else { stringDictionary.Add("Admin", "Admin@123"); Console.WriteLine("User added succesfully."); } // Get a collection of the keys. Console.WriteLine("UserName" + ": " + "Password"); foreach (DictionaryEntry entry in stringDictionary) { Console.WriteLine(entry.Key + ": " + entry.Value); } Console.ReadKey(); }
public override bool OnNext() { if (this._saveCheckBox.Checked) { ICollection connections = this._dataEnvironment.Connections; StringDictionary dictionary = new StringDictionary(); foreach (DesignerDataConnection connection in connections) { if (connection.IsConfigured) { dictionary.Add(connection.Name, null); } } if (dictionary.ContainsKey(this._nameTextBox.Text)) { UIServiceHelper.ShowError(base.ServiceProvider, System.Design.SR.GetString("SqlDataSourceSaveConfiguredConnectionPanel_DuplicateName", new object[] { this._nameTextBox.Text })); this._nameTextBox.Focus(); return false; } } WizardPanel panel = SqlDataSourceConnectionPanel.CreateCommandPanel((SqlDataSourceWizardForm) base.ParentWizard, this._dataConnection, base.NextPanel); if (panel == null) { return false; } base.NextPanel = panel; return true; }
public Args(string[] args) { argDict = new StringDictionary(); Regex regEx = new Regex(@"^-", RegexOptions.IgnoreCase | RegexOptions.Compiled); Regex regTrim = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled); string arg = ""; string[] chunks; foreach (string s in args) { chunks = regEx.Split(s, 3); if (regEx.IsMatch(s)) { arg = chunks[1]; argDict.Add(arg, "true"); } else { if (argDict.ContainsKey(arg)) { chunks[0] = regTrim.Replace(chunks[0], "$1"); argDict.Remove(arg); argDict.Add(arg, chunks[0]); arg = ""; } } } }
private static String GetOrCreateProperty(StringDictionary bag, String key) { if (!bag.ContainsKey(key)) { bag.Add(key, Constants.DefaultVersionMinor); } return bag[key]; }
public void Configure(StringDictionary attributes) { if (!attributes.ContainsKey("Values")) { throw new ArgumentException("Attribute Values is missing in Converter"); } this.values = attributes["Values"]; }
public void This_Empty () { StringDictionary sd = new StringDictionary (); sd[String.Empty] = null; Assert.IsNull (sd[String.Empty], "this[String.Empty]"); Assert.AreEqual (1, sd.Count, "Count-1"); Assert.IsTrue (sd.ContainsKey (String.Empty), "ContainsKey"); Assert.IsTrue (sd.ContainsValue (null), "ContainsValue"); }
public new void Configure(StringDictionary attributes) { base.Configure(attributes); if (attributes.ContainsKey("FeatureScopes")) { FeatureScopes = attributes["FeatureScopes"]; } }
/// <summary> /// 数据存在检查(主键重复) /// </summary> /// <param name="TableName">数据表名称</param> /// <param name="dicItemData">数据内容</param> /// <param name="dicPrimarName">主键列名</param> /// <returns></returns> public bool GetExistDataItem(String TableName, StringDictionary dicItemData, StringDictionary dicPrimarName) { bool IsExist = false; DataTable dt = new DataTable(); int rowIndex = 0; SqlParameter[] cmdParamters = null; SqlParameter SqlParameter = null; string w_strWhere = ""; try { if (dicItemData == null || dicItemData.Count <= 0 || dicPrimarName == null || dicPrimarName.Count <= 0) return false ; string strSql = "SELECT CAST('0' AS Bit) AS SlctValue," + TableName + ".* " + " FROM " + TableName + " WHERE 1=1 "; Common.AdoConnect.Connect.ConnectOpen(); cmdParamters = new SqlParameter[dicPrimarName.Count]; foreach (string strKey in dicPrimarName.Keys) { if (dicItemData.ContainsKey(strKey) == true) { w_strWhere += " AND " + strKey + "=@" + strKey; SqlParameter = new SqlParameter("@" + strKey, DataFiledType.FiledType[strKey]); SqlParameter.Value = dicItemData[strKey]; SqlParameter.Direction = ParameterDirection.Input; cmdParamters[rowIndex] = SqlParameter; rowIndex++; } } strSql += w_strWhere; dt = Common.AdoConnect.Connect.GetDataSet(strSql, cmdParamters); if (dt != null) { if (dt.Rows.Count>0) IsExist = true; } return IsExist; } catch (Exception ex) { throw ex; } }
internal void SetColletion(StringDictionary scol) { foreach (String key in _collection.Keys) { if (scol.ContainsKey(key)) scol[key] = (string)_collection[key]; else scol.Add(key, (string)_collection[key]); } }
public void Configure(StringDictionary attributes) { if (!attributes.ContainsKey("XPath")) { throw new ArgumentException("Attribute XPath is missing in Converter"); } this.xPath = attributes["XPath"]; if (attributes.ContainsKey("AcceptFreeText")) { try { this.acceptFreeText = Boolean.Parse(attributes["AcceptFreeText"]); } catch (Exception) { } } }
/// <summary> /// Adds any errors from the domain to the view model. /// </summary> /// <param name="currentState">The model state dictionary to update.</param> /// <param name="result">The result from the domain validation, which contains any errors that occurred in the domain validation.</param> /// <param name="mappingFromDomainToUi">Provides a set of mappings that map the propeties of a domain object to those of a view model object.</param> public static void UpdateFromDomain(this ModelStateDictionary currentState, ValidationResult result, StringDictionary mappingFromDomainToUi) { foreach (var message in result.Messages) { var propertyName = message.PropertyName; if (mappingFromDomainToUi.ContainsKey(message.PropertyName)) propertyName = mappingFromDomainToUi[message.PropertyName]; currentState.AddModelError(propertyName, message.Message); } }
public void CopyTo(StringDictionary scol) { foreach (string key in Collection.Keys) { if (scol.ContainsKey(key)) scol[key] = Collection[key]; else scol.Add(key, Collection[key]); } }
public OperationModel Parse(string[] args) { var methodName = args[0].Replace("-", ""); var parameters = new StringDictionary(); var spliter = new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled); var remover = new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled); string parameter = null; foreach (string txt in args) { string[] parts = spliter.Split(txt, 3); switch (parts.Length) { case 1: if (parameter != null) { if (!parameters.ContainsKey(parameter)) { parts[0] = remover.Replace(parts[0], "$1"); parameters.Add(parameter, parts[0]); } parameter = null; } break; case 2: if (parameter != null) { if (!parameters.ContainsKey(parameter)) parameters.Add(parameter, "true"); } parameter = parts[1]; break; } } OperationNameEnum operation; Enum.TryParse(methodName, out operation); return MapParameters(parameters, operation); }
public static bool DictTryValue(StringDictionary dict, string key, out string value) { if (dict.ContainsKey (key)) { value = dict[key]; if (value == null) return false; return true; } value = null; return false; }
public AbstractCommand(IEnumerable<FileFilter> filters, StringDictionary destinations) { FileFilters = filters.ToList(); Destinations = new Dictionary<string, DirectoryInfo>(); string sourcePath = destinations[SOURCE_DIRECTORY_TYPE_NAME]; Destinations[SOURCE_DIRECTORY_TYPE_NAME] = new DirectoryInfo(sourcePath); if (destinations.ContainsKey(TARGET_DIRECTORY_TYPE_NAME)) { string targetPath = destinations[TARGET_DIRECTORY_TYPE_NAME]; Destinations[TARGET_DIRECTORY_TYPE_NAME] = new DirectoryInfo(targetPath); } }
private static void EnsureEnvironmentVariableExists(StringDictionary dictionary, string variable, string value, bool resetIfExists = false) { if(resetIfExists) { dictionary[variable] = value; } else { if(!dictionary.ContainsKey(variable)) { dictionary.Add(variable, value); } } }
public static void AssertExistsAndNotEmpty(StringDictionary argsDict, params string[] argNames) { foreach (string argName in argNames) { if (!argsDict.ContainsKey(argName)) { throw new ArgumentException(ArgumentNotExistedError, argName); } else { AssertNotNullOrEmpty(argName, argsDict[argName]); } } }
public static void Main() { // Creates and initializes a new StringDictionary. StringDictionary myCol = new StringDictionary(); myCol.Add("red", "rojo"); myCol.Add("green", "verde"); myCol.Add("blue", "azul"); Console.WriteLine("Count: {0}", myCol.Count); // Display the contents of the collection using foreach. This is the preferred method. Console.WriteLine("Displays the elements using foreach:"); PrintKeysAndValues1(myCol); // Display the contents of the collection using the enumerator. Console.WriteLine("Displays the elements using the IEnumerator:"); PrintKeysAndValues2(myCol); // Display the contents of the collection using the Keys, Values, Count, and Item properties. Console.WriteLine("Displays the elements using the Keys, Values, Count, and Item properties:"); PrintKeysAndValues3(myCol); // Copies the StringDictionary to an array with DictionaryEntry elements. DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count]; myCol.CopyTo(myArr, 0); // Displays the values in the array. Console.WriteLine("Displays the elements in the array:"); Console.WriteLine(" KEY VALUE"); for (int i = 0; i < myArr.Length; i++) Console.WriteLine(" {0,-10} {1}", myArr[i].Key, myArr[i].Value); Console.WriteLine(); // Searches for a value. if (myCol.ContainsValue("amarillo")) Console.WriteLine("The collection contains the value \"amarillo\"."); else Console.WriteLine("The collection does not contain the value \"amarillo\"."); Console.WriteLine(); // Searches for a key and deletes it. if (myCol.ContainsKey("green")) myCol.Remove("green"); Console.WriteLine("The collection contains the following elements after removing \"green\":"); PrintKeysAndValues1(myCol); // Clears the entire collection. myCol.Clear(); Console.WriteLine("The collection contains the following elements after it is cleared:"); PrintKeysAndValues1(myCol); }
/// <summary> /// 检验是否具有指定节点的指定动作的权限。 /// </summary> /// <param name="node">待检查节点。</param> /// <param name="roles">权限字典。</param> /// <param name="actionType">动作的类型。</param> /// <returns>是否具有权限。</returns> public bool CheckNodeRole(NodeEntity node, StringDictionary roles, ActionType actionType) { if (roles.ContainsKey("Administrator")) { return true; } else if (actionType == ActionType.AddInfo) { if (roles.ContainsKey("ContentAdmin") || this.CheckNodeAncestorsRole(node, roles, "Admin") || this.CheckNodeAncestorsRole(node, roles, "Author")) { return true; } } else if (actionType == ActionType.ManageInfo) { if (roles.ContainsKey("ContentAdmin") || this.CheckNodeAncestorsRole(node, roles, "Admin")) { return true; } } else if (actionType == ActionType.ManageRole) { if (roles.ContainsKey("MemberAdmin")) { return true; } } else if (actionType == ActionType.ManageNode) { if (roles.ContainsKey("ContentAdmin") || this.CheckNodeAncestorsRole(node, roles, "Admin")) { return true; } } return false; }
void IAttributesConfigurable.Configure(System.Collections.Specialized.StringDictionary attributes) { if (attributes.ContainsKey(BrowseRootAttribute)) { root = (BrowseRoot)Enum.Parse(typeof(BrowseRoot), attributes[BrowseRootAttribute]); } if (attributes.ContainsKey(BrowseKindAttribute)) { kind = (BrowseKind)Enum.Parse(typeof(BrowseKind), attributes[BrowseKindAttribute]); } if (attributes.ContainsKey(FilterAttribute)) { filterTypeName = attributes[FilterAttribute]; } if (attributes.ContainsKey(RootAttribute)) { customRootEntryName = attributes[RootAttribute]; } if (attributes.ContainsKey(UserCodeAttribute)) { onlyUserCode = Boolean.Parse(attributes[UserCodeAttribute]); } this.attributes = attributes; }
public void Empty () { StringDictionary sd = new StringDictionary (); Assert.AreEqual (0, sd.Count, "Count"); Assert.IsFalse (sd.IsSynchronized, "IsSynchronized"); Assert.AreEqual (0, sd.Keys.Count, "Keys"); Assert.AreEqual (0, sd.Values.Count, "Values"); Assert.IsNotNull (sd.SyncRoot, "SyncRoot"); Assert.IsFalse (sd.ContainsKey ("a"), "ContainsKey"); Assert.IsFalse (sd.ContainsValue ("1"), "ContainsValue"); sd.CopyTo (new DictionaryEntry[0], 0); Assert.IsNotNull (sd.GetEnumerator (), "GetEnumerator"); sd.Remove ("a"); // doesn't exists sd.Clear (); }
public InstallContext (string logFilePath, string [] cmdLine) { parameters = ParseCommandLine(cmdLine); // Log file path specified in command line arguments // has higher priority than the logFilePath argument if (parameters.ContainsKey ("logFile")) { logFilePath = parameters ["logFile"]; parameters.Remove ("logFile"); } if (logFilePath == null) logFilePath = ""; parameters.Add ("logFile", logFilePath); }
//Compares all the text files from two directories setup from app.config static void compareAllTxtFiles() { //Get all the text file names from trunk location string[] trunkTxtFiles = Directory.GetFiles(@ConfigurationManager.AppSettings["trunkLoc"], "*.txt"); //Split the full paths from file names to get actual file names for comparison with branch files string[] separator = { ConfigurationManager.AppSettings["trunkLoc"], ConfigurationManager.AppSettings["branchLoc"] }; //Create dictionary and fill in the file names and marking the value initially as "0" StringDictionary trunkTxtFilesDict = new StringDictionary(); foreach (string trunkTxtFile in trunkTxtFiles) { string[] temp = trunkTxtFile.Split(separator,StringSplitOptions.RemoveEmptyEntries); trunkTxtFilesDict.Add(temp[0],"0"); } //Get all the text file names from branch location string[] branchTxtFiles = Directory.GetFiles(@ConfigurationManager.AppSettings["branchLoc"], "*.txt"); //Compare branch file name with trunk file names available and if present as key mark it as "1" foreach (string branchTxtFile in branchTxtFiles) { string[] branchFileNames = branchTxtFile.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (trunkTxtFilesDict.ContainsKey(branchFileNames[0])) { trunkTxtFilesDict[branchFileNames[0]] = "1"; } } //For each matching files compare the files between two directories foreach (DictionaryEntry trunkTxtFileDict in trunkTxtFilesDict) { if (((String)trunkTxtFileDict.Value).CompareTo("1")==0) { string pathfileA = ConfigurationManager.AppSettings["trunkLoc"] + trunkTxtFileDict.Key; string pathfileB = ConfigurationManager.AppSettings["branchLoc"] + trunkTxtFileDict.Key; FileInfo a = new FileInfo(pathfileA); FileInfo b = new FileInfo(pathfileB); //Compare files and write to location provided from static var diffFileURI FileCompare(a, b, diffFileURI); } } Console.WriteLine("pkxcmp completed finding differences in the given files, Results are available at designated location."); }
/// <summary> /// Сохранить сопоставление плагинов для автоматического режима /// </summary> /// <param name="map"></param> public static void SaveAutoModePluginsMap(StringDictionary map) { StringCollection result = new StringCollection(); #region Заполняем if (map.ContainsKey("PlowHeigth")) result.Add("PlowHeigth:" + map["PlowHeigth"]); if (map.ContainsKey("PlowWidth")) result.Add("PlowWidth:" + map["PlowWidth"]); if (map.ContainsKey("CuttingEfforts".ToLower())) result.Add("CuttingEfforts:" + map["CuttingEfforts"]); if (map.ContainsKey("ActiveLoading")) result.Add("ActiveLoading:" + map["ActiveLoading"]); if (map.ContainsKey("TractiveEffort1")) result.Add("TractiveEffort1:" + map["TractiveEffort1"]); if (map.ContainsKey("TractiveEffort2")) result.Add("TractiveEffort2:" + map["TractiveEffort2"]); if (map.ContainsKey("ElectricDrive")) result.Add("ElectricDrive:" + map["ElectricDrive"]); if (map.ContainsKey("Productivity")) result.Add("Productivity:" + map["Productivity"]); if (map.ContainsKey("CheckingDynamic")) result.Add("CheckingDynamic:" + map["CheckingDynamic"]); #endregion Properties.Settings sett = Properties.Settings.Default; sett.PluginsMapForAutoMode = result; sett.Save(); }
public static bool CheckDigitalObjectDirectory(string itemId, ref string tocString, ref string signatureStr, StringDictionary itemDescriptors ) { bool result = false; if ((tocString.Contains("$$TOC$$=")) && (tocString.Contains("XXXXX_"))) { ImportOptions directories = new UserSettingsService().GetImportOptions(); string objectName = tocString.Substring(tocString.IndexOf("XXXXX_") + "XXXXX_".Length,tocString.IndexOf("/",tocString.IndexOf("XXXXX_")) - tocString.IndexOf("XXXXX_") -"XXXXX_".Length); string objectType = tocString.Contains("ArcMusicMp3") ? "ArcMusicMp3" : "ArcAudioMp3"; Mp3Album digObj = new Mp3Album(directories.AudioProjectDirectory + "\\" + objectName, objectType); digObj.Read(); if (digObj.ElementCount > 0) { bool[] includeElements = new bool[digObj.ElementCount]; string newSigStr = "JB: MyMusic=" + digObj.GenerateAccessLink(itemId) + "; "; string newTocStr = tocString.Replace("XXXXX_", itemId + "_"); for (int i = 0; i < digObj.ElementCount; i++) { string theFileName = digObj.SelectElement(i + 1).DigitalObjectIdentifier(DigitalObject.DOIdentifier.filename); if (includeElements[i] = newTocStr.Contains(theFileName)) newTocStr = newTocStr.Replace(theFileName, "TRACK" + (i+1) + ".m3u"); } if (itemDescriptors.ContainsKey("Abstract")) itemDescriptors["Abstract"] = newTocStr; tocString = newTocStr; signatureStr += signatureStr.Contains(newSigStr) ? "" : " " + newSigStr; try { digObj.GenerateAccessStructure(itemId, includeElements); digObj.ChangeDescriptionElements(itemDescriptors, includeElements); result = true; } catch (Exception ex) { throw new Exception("Directory for digital object could not be created. " + ex.Message, ex.InnerException); } } } return result; }
public override string PutIdentifierIntoBrackets(string identifier) { if (identifier.IndexOf(".") >= 0 || identifier.Length > 32) { if (identDict.ContainsKey(identifier)) { return(identDict[identifier]); } else { string ni = "gi" + Guid.NewGuid().ToString("N").Substring(4) + ""; identDict.Add(identifier, ni); return(ni); } } else { return(TranslitRu(identifier)); } }
protected static StringDictionary ParseHeaders(Stream stream, out string requestLine) { using (var reader = new StreamReader(stream)) { string lastKey = null, line; requestLine = reader.ReadLine(); var headers = new StringDictionary(); //In compliance with [RFC2616], header fields in the handshake may be //sent by the client in any order, so the order in which different //header fields are received is not significant. while ((line = reader.ReadLine()) != null) { if (line.Length == 0) continue; if (line[0] == ' ' || line[0] == '\t') { //HTTP/1.1 header field values can be folded onto multiple lines if the //continuation line begins with a space or horizontal tab. All linear //white space, including folding, has the same semantics as SP. A //recipient MAY replace any linear white space with a single SP before //interpreting the field value or forwarding the message downstream. headers[lastKey] += " " + line.TrimStart(); } else { int i = line.IndexOf(':'); if (i <= 0) throw new InvalidOperationException(); // most HTTP headers are repeatable, so Foo=abc\r\nFoo=def\r\n // is identical to Foo=abc, def\r\n lastKey = line.Substring(0, i); string value = line.Substring(i + 1, line.Length - (i + 1)).Trim(); if(headers.ContainsKey(lastKey)) { value = headers[lastKey] + ", " + value; } headers[lastKey] = value; } } return headers; } }