public void Store () { Properties props = new Properties(); props.Add ("foo", "this"); props.Add ("bar", "is"); props.Add ("baz", "it"); FileInfo file = new FileInfo ("properties.test"); try { // write 'em out with the specified header... using (Stream cout = file.OpenWrite ()) { props.Store (cout, "My Properties"); } } finally { try { file.Delete (); } catch (IOException) { } } }
public void GetPropertyWithDefault () { Properties props = new Properties(); props.Add ("foo", "this"); props.Add ("bar", "is"); Assert.AreEqual ("this", props.GetProperty ("foo")); Assert.AreEqual ("is", props.GetProperty ("bar")); Assert.AreEqual ("it", props.GetProperty ("baz", "it")); }
public void Remove () { Properties props = new Properties(); props.Add ("foo", "this"); props.Add ("bar", "is"); Assert.AreEqual (2, props.Count); props.Remove ("foo"); Assert.AreEqual (1, props.Count); Assert.IsFalse (props.ContainsKey ("foo")); }
public void Instantiation () { Properties root = new Properties(); root.Add ("foo", "this"); root.Add ("bar", "is"); Properties props = new Properties(root); props.SetProperty("myPropertyKey", "myPropertyValue"); Assert.AreEqual (3, props.Count); Assert.AreEqual ("this", props.GetProperty ("foo")); Assert.AreEqual ("is", props.GetProperty ("bar")); Assert.AreEqual ("myPropertyValue", props.GetProperty ("myPropertyKey")); }
public Mensaje getFilePropertiesMascara(string directorioReportesDelSistema, DBContextAdapter dbContext) { try { inicializaVariableMensaje(); Spring.Util.Properties properties = obtenerPropertiesMascara(directorioReportesDelSistema, dbContext); // ResXResourceSet resxr = obtenerPropertiesMascara(directorioReportesDelSistema, ""); byte[] serelizedPrint; string code = ""; if (properties != null) { // var resources = new List<string>(); /* Dictionary<string, string> dic = new Dictionary<string, string>(); * foreach (System.Collections.DictionaryEntry entry in resxr) * { * dic.Add(entry.Key.ToString(), entry.Value.ToString()); * // dic.Add(entry.Key.ToString()); * //resources.Add(entry.Value); * } */ code = SerializationHelper.SerializeToJson(properties); serelizedPrint = SerializationHelper.StringToUTF8ByteArray(code); // code2 = SerializationHelper.UTF8ByteArrayToString(serelizedPrint); // properties = SerializationHelper.DeserializeFromJson<Properties>(code2); if (mensajeResultado.noError == 0) { mensajeResultado.resultado = serelizedPrint; } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(concatena.Remove(0, concatena.Length).Append(msgError).Append("FilePropertiesMascara()1_Error: ").Append(ex)); mensajeResultado.noError = ControlErroresEntity.buscaNoErrorPorExcepcion(ex); mensajeResultado.error = ex.GetBaseException().ToString(); mensajeResultado.resultado = null; getSession().Database.CurrentTransaction.Rollback(); } return(mensajeResultado); }
private Spring.Util.Properties obtenerPropertiesMascara(String directorioReportesDelSistema, DBContextAdapter dbContext) //private ResXResourceSet obtenerPropertiesMascara(String directorioReportesDelSistema, DBContextAdapter dbContext) { concatena = new StringBuilder(); concatena.Append(directorioReportesDelSistema); Spring.Util.Properties properties = null; // ResXResourceSet resxSet = null; if (!directorioReportesDelSistema.Substring(directorioReportesDelSistema.Length - 2).Contains(Path.DirectorySeparatorChar)) { concatena.Append(Path.DirectorySeparatorChar); } concatena.Append(getNameFileConfigurationMask(null)); string ubicacionFile = concatena.ToString(); if (File.Exists(ubicacionFile)) { properties = abrirPropiedad(ubicacionFile); } else { concatena = new StringBuilder(); Assembly assembly = Assembly.GetExecutingAssembly(); StreamReader inputStream = new StreamReader(assembly.GetManifestResourceStream(concatena.Append("Exitosw.Payroll.Core.util.").Append(DEFAULT_FILE).Append(".properties").ToString())); try { properties = new Spring.Util.Properties(); properties.Load(inputStream); //resxSet = new ResXResourceSet(ubicacion); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(concatena.Remove(0, concatena.Length).Append(msgError).Append("obtenerPropertiesMascara()1_Error: ").Append(ex)); mensajeResultado.noError = ControlErroresEntity.buscaNoErrorPorExcepcion(ex); mensajeResultado.error = ex.GetBaseException().ToString(); mensajeResultado.resultado = null; } } //return resourcemanager; return(properties); }
private Spring.Util.Properties abrirPropiedad(String file) { Spring.Util.Properties properties = null; try { var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(file); writer.Flush(); stream.Position = 0; properties = new Spring.Util.Properties(); properties.Load(new StreamReader(stream)); } catch (IOException ex) { mensajeResultado.noError = ControlErroresEntity.buscaNoErrorPorExcepcion(ex); mensajeResultado.error = ex.GetBaseException().ToString(); mensajeResultado.resultado = null; } return(properties); }
public Properties PropertiesMethod(Properties properties) { return properties; }
/// <summary> /// Load object definitions from the specified properties file. /// </summary> /// <param name="resource"> /// The resource descriptor for the properties file. /// </param> /// <param name="prefix"> /// The match or filter for object definition names, e.g. 'objects.' /// </param> /// <exception cref="Spring.Objects.ObjectsException">in case of loading or parsing errors</exception> /// <returns>the number of object definitions found</returns> public int LoadObjectDefinitions(IResource resource, string prefix) { Properties props = new Properties(); try { Stream str = resource.InputStream; try { props.Load(str); } finally { str.Close(); } return RegisterObjectDefinitions(props, prefix, resource.Description); } catch (IOException ex) { throw new ObjectDefinitionStoreException("IOException parsing properties from " + resource, ex); } }
/// <summary> /// Resolves variable value for the specified variable name. /// </summary> /// <param name="name"> /// The name of the variable to resolve. /// </param> /// <returns> /// The variable value if able to resolve, <c>null</c> otherwise. /// </returns> public string ResolveVariable(string name) { lock (objectMonitor) { if (properties == null) { properties = new Properties(); InitProperties(); } return properties.GetProperty(name); } }
public void Continuation() { string input = "continued = this is a long value element \\\r\nthat uses continuation \\\r\n xxx"; Stream s = new MemoryStream(Encoding.ASCII.GetBytes(input)); Properties props = new Properties(); props.Load(s); Assert.IsTrue("this is a long value element that uses continuation xxx".Equals(props["continued"])); }
public void WhitespaceProperties() { string input = "key1 =\t\nkey2:\nkey3"; Stream s = new MemoryStream(Encoding.ASCII.GetBytes(input)); Properties props = new Properties(); props.Load(s); Assert.AreEqual(string.Empty, props["key1"], "key1 should have empty value"); Assert.AreEqual(string.Empty, props["key2"], "key2 should have empty value"); Assert.IsTrue(props.ContainsKey("key3")); Assert.IsNull(props["key3"]); }
public void SimpleProperties() { string input = "key1=value1\r\nkey2:value2\r\n\r\n# a comment line\r\n leadingspace : true"; Stream s = new MemoryStream(Encoding.ASCII.GetBytes(input)); Properties props = new Properties(); props.Load(s); Assert.IsTrue("value1".Equals(props["key1"])); Assert.IsTrue("value2".Equals(props["key2"])); Assert.IsTrue("true".Equals(props["leadingspace"])); }
public void ListAndLoad() { Properties props = new Properties(); props.Add ("foo", "this"); props.Add ("bar", "is"); props.Add ("baz", "it"); FileInfo file = new FileInfo ("properties.test"); try { // write 'em out... using (Stream cout = file.OpenWrite ()) { props.List (cout); } // read 'em back in... using (Stream cin = file.OpenRead ()) { props = new Properties (); props.Load (cin); Assert.AreEqual (3, props.Count); Assert.AreEqual ("this", props.GetProperty ("foo")); Assert.AreEqual ("is", props.GetProperty ("bar")); Assert.AreEqual ("it", props.GetProperty ("baz", "it")); } } finally { try { file.Delete (); } catch (IOException) { } } }
public void FromMessageWithPropertiesMethodAndPropertiesPayload() { MethodInfo method = typeof (TestService).GetMethod("PropertiesPayload"); MethodParameterMessageMapper mapper = new MethodParameterMessageMapper(method); Properties payload = new Properties(); payload.SetProperty("prop1", "foo"); payload.SetProperty("prop2", "bar"); IMessage message = MessageBuilder.WithPayload(payload).SetHeader("prop1", "not").SetHeader("prop2", "these").Build(); object[] args = (object[]) mapper.FromMessage(message); Properties result = (Properties) args[0]; Assert.That(result.Count, Is.EqualTo(2)); Assert.That(result.GetProperty("prop1"), Is.EqualTo("foo")); Assert.That(result.GetProperty("prop2"), Is.EqualTo("bar")); }
public Properties PropertiesPayload(Properties properties) { return properties; }
public void SeperatorEscapedWithinKey() { string input = "\\" + ":key:newvalue"; Stream s = new MemoryStream(Encoding.ASCII.GetBytes(input)); Properties props = new Properties(); props.Load(s); Assert.IsTrue("newvalue".Equals(props[":key"])); }
/// <summary> /// Before requesting a variable resolution, a client should /// ask, whether the source can resolve a particular variable name. /// </summary> /// <param name="name">the name of the variable to resolve</param> /// <returns><c>true</c> if the variable can be resolved, <c>false</c> otherwise</returns> public bool CanResolveVariable(string name) { lock (objectMonitor) { if (properties == null) { properties = new Properties(); InitProperties(); } return properties.Contains(name); } }
public void EscapedCharactersInValue() { string input = "escaped=test\\ttest"; Stream s = new MemoryStream(Encoding.ASCII.GetBytes(input)); Properties props = new Properties(); props.Load(s); Assert.IsTrue("test\ttest".Equals(props["escaped"])); }
/// <summary> /// Creates a property list with the specified initial properties. /// </summary> /// <param name="p">The initial properties.</param> public Properties(Properties p) : base(p) { }
/// <summary> /// Initializes properties based on the specified /// property file locations. /// </summary> private void InitProperties() { properties = new Properties(); foreach (IResource location in locations) { using (Stream input = location.InputStream) { properties.Load(input); } } }