Changeset 11576 for branches/OptimizationNetworks/HeuristicLab.Scripting
- Timestamp:
- 11/25/14 03:26:00 (10 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks
- Property svn:mergeinfo changed
-
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/CSharpScript.cs
r11058 r11576 38 38 get { 39 39 return @"// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5) 40 // use 'vars[string]' to access variables via runtime strings (e.g. vars[""x""] = 5) 40 41 // use 'vars.Contains(string)' to check if a variable exists 41 42 // use 'vars.Clear()' to remove all variables 42 43 // use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables 44 // use 'variables' to work with IEnumerable<T> extension methods on the script's variable store 43 45 44 46 using System; … … 133 135 } 134 136 }); 137 scriptThread.SetApartmentState(ApartmentState.STA); 135 138 scriptThread.Start(); 136 139 } -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/CSharpScriptBase.cs
r10857 r11576 27 27 namespace HeuristicLab.Scripting { 28 28 public abstract class CSharpScriptBase { 29 protected Variables variables; 29 30 protected dynamic vars; 30 31 … … 41 42 42 43 internal void Execute(VariableStore variableStore) { 43 var s = new Variables(variableStore);44 variables = vars = new Variables(variableStore); 44 45 Main(); 45 46 } -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj
r10731 r11576 131 131 </ItemGroup> 132 132 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 133 <PropertyGroup>134 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)133 <PropertyGroup> 134 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 135 135 set ProjectDir=$(ProjectDir) 136 136 set SolutionDir=$(SolutionDir) 137 137 set Outdir=$(Outdir) 138 138 139 call PreBuildEvent.cmd</PreBuildEvent> 139 call PreBuildEvent.cmd 140 </PreBuildEvent> 141 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 142 export ProjectDir=$(ProjectDir) 143 export SolutionDir=$(SolutionDir) 144 145 $SolutionDir/PreBuildEvent.sh 146 </PreBuildEvent> 140 147 </PropertyGroup> 141 148 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/Plugin.cs.frame
r10506 r11576 23 23 24 24 namespace HeuristicLab.Scripting { 25 [Plugin("HeuristicLab.Scripting", "3.3. 9.$WCREV$")]25 [Plugin("HeuristicLab.Scripting", "3.3.10.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Scripting-3.3.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/Properties/AssemblyInfo.cs.frame
r10506 r11576 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 56 [assembly: AssemblyVersion("3.3.0.0")] 57 [assembly: AssemblyFileVersion("3.3. 9.$WCREV$")]57 [assembly: AssemblyFileVersion("3.3.10.$WCREV$")] -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/Script.cs
r10857 r11576 24 24 using System.CodeDom.Compiler; 25 25 using System.Collections.Generic; 26 using System.Diagnostics; 26 27 using System.Drawing; 27 28 using System.IO; … … 142 143 143 144 public virtual IEnumerable<Assembly> GetAssemblies() { 144 var assemblies = new List<Assembly>(); 145 foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { 146 try { 147 if (File.Exists(a.Location)) assemblies.Add(a); 148 } catch (NotSupportedException) { 149 // NotSupportedException is thrown while accessing 150 // the Location property of the anonymously hosted 151 // dynamic methods assembly, which is related to 152 // LINQ queries 153 } 154 } 145 var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList(); 155 146 assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality 156 147 return assemblies; -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/VariableStore.cs
r11058 r11576 45 45 dict[kvp.Key] = CloneByPersistence(kvp.Value); 46 46 } catch (PersistenceException pe) { 47 throw new NotSupportedException( "VariableStore: Variable " + kvp.Key + " could not be cloned.", pe);47 throw new NotSupportedException(string.Format(@"VariableStore: Variable ""{0}"" could not be cloned.", kvp.Key), pe); 48 48 } 49 49 } … … 59 59 } 60 60 61 protected object CloneByPersistence(objectvalue) {61 protected T CloneByPersistence<T>(T value) { 62 62 using (var serializerStream = new MemoryStream()) { 63 63 XmlGenerator.Serialize(value, serializerStream); 64 64 var bytes = serializerStream.GetBuffer(); 65 65 using (var deserializerStream = new MemoryStream(bytes)) { 66 return XmlParser.Deserialize< VariableStore>(deserializerStream);66 return XmlParser.Deserialize<T>(deserializerStream); 67 67 } 68 68 } -
branches/OptimizationNetworks/HeuristicLab.Scripting/3.3/Variables.cs
r10727 r11576 20 20 } 21 21 22 public object this[string key] { 23 get { return variableStore[key]; } 24 set { variableStore[key] = value; } 25 } 26 22 27 public bool Contains(string variableName) { 23 28 return variableStore.ContainsKey(variableName);
Note: See TracChangeset
for help on using the changeset viewer.