Title: RE: [nant-dev] patch to support resolving properties from environment vars

This would be great and would allow for individual customizations per a developers environment.



-----Original Message-----
From: Ben Lowery [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 3:27 PM
To: [EMAIL PROTECTED]
Subject: [nant-dev] patch to support resolving properties from environment vars

don't know if people consider this worthwhile or not, but i find it very
handy when dealing with projects broken down into multiple buildfiles.  the
patch allows nant to attempt to resolve properties not in the
PropertyDictionary from the Environment.  So, if you have a property called
"build.dir" but it's not set in your project, but is set in your
environment, the property will be pulling in from the environment.

here's the revised indexer, against /src/NAnt.Core/PropertyDictionary.cs

public virtual string this[string name] {
 get {
  string value = (string) Dictionary[(object) name];
  if(null == value) {
   //try to resolve from environment
   value = System.Environment.GetEnvironmentVariable(name);
   if(null!=value)
    value =
ExpandProperties(System.Environment.ExpandEnvironmentVariables(value));
  }
  return value;
 }
 set {
   if (!_readOnlyProperties.Contains(name)) {
     Dictionary[name] = value;
   }
 }
}

--b



-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to