/// <summary> /// Initialize Velocity properties, if the default /// properties have not been laid down first then /// do so. Then proceed to process any overriding /// properties. Laying down the default properties /// gives a much greater chance of having a /// working system. /// </summary> private void initializeProperties() { // Always lay down the default properties first as // to provide a solid base. if (configuration.IsInitialized() == false) { setDefaultProperties(); } if (overridingProperties != null) { configuration.Combine(overridingProperties); } }
public void Test_ExtendedProperties() { FileInfo file = new FileInfo("test1.properties"); StreamWriter sw = file.CreateText(); sw.WriteLine("# lines starting with # are comments. Blank lines are ignored"); sw.WriteLine(string.Empty); sw.WriteLine("# This is the simplest property"); sw.WriteLine("prefix.key = value"); sw.WriteLine(string.Empty); sw.WriteLine("# A long property may be separated on multiple lines"); sw.WriteLine("prefix.longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\"); sw.WriteLine(" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); sw.WriteLine(string.Empty); sw.WriteLine("# This is a property with many tokens"); sw.WriteLine("prefix.tokens_on_a_line = first token, second token"); sw.WriteLine(string.Empty); sw.WriteLine("# This sequence generates exactly the same result"); sw.WriteLine("prefix.tokens_on_multiple_lines = first token"); sw.WriteLine("prefix.tokens_on_multiple_lines = second token"); sw.WriteLine(string.Empty); sw.WriteLine("# commas may be escaped in tokens"); sw.WriteLine("prefix.commas.excaped = Hi\\, what'up?"); sw.Flush(); sw.Close(); StreamReader sr = file.OpenText(); String s = sr.ReadToEnd(); sr.Close(); ExtendedProperties props = new ExtendedProperties(file.FullName); VerifyProperties(props, "prefix."); StringWriter writer = new StringWriter(); props.Save(writer, "header"); // make sure that combine does not change types ExtendedProperties p = new ExtendedProperties(); p.Combine(props); VerifyProperties(p, "prefix."); // make sure that subset does not change property types ExtendedProperties p2 = p.Subset("prefix"); VerifyProperties(p2, string.Empty); }
public void Test_ExtendedProperties() { FileInfo file = new FileInfo("test1.properties"); StreamWriter sw = file.CreateText(); sw.WriteLine("# lines starting with # are comments. Blank lines are ignored"); sw.WriteLine(string.Empty); sw.WriteLine("# This is the simplest property"); sw.WriteLine("prefix.key = value"); sw.WriteLine(string.Empty); sw.WriteLine("# A long property may be separated on multiple lines"); sw.WriteLine("prefix.longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \\"); sw.WriteLine(" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); sw.WriteLine(string.Empty); sw.WriteLine("# This is a property with many tokens"); sw.WriteLine("prefix.tokens_on_a_line = first token, second token"); sw.WriteLine(string.Empty); sw.WriteLine("# This sequence generates exactly the same result"); sw.WriteLine("prefix.tokens_on_multiple_lines = first token"); sw.WriteLine("prefix.tokens_on_multiple_lines = second token"); sw.WriteLine(string.Empty); sw.WriteLine("# commas may be escaped in tokens"); sw.WriteLine("prefix.commas.excaped = Hi\\, what'up?"); sw.Flush(); sw.Close(); StreamReader sr = file.OpenText(); String s = sr.ReadToEnd(); sr.Close(); ExtendedProperties props = new ExtendedProperties(file.FullName); VerifyProperties(props, "prefix."); StringWriter writer = new StringWriter(); props.Save(writer, "header"); // make sure that combine does not change types ExtendedProperties p = new ExtendedProperties(); p.Combine(props); VerifyProperties(p, "prefix."); // make sure that subset does not change property types ExtendedProperties p2 = p.Subset("prefix"); VerifyProperties(p2, string.Empty); }