Changeset 11907 for stable/HeuristicLab.Scripting
- Timestamp:
- 02/05/15 10:51:29 (10 years ago)
- Location:
- stable
- Files:
-
- 2 deleted
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Scripting/3.3/HeuristicLab.Scripting-3.3.csproj
r11129 r11907 85 85 </ItemGroup> 86 86 <ItemGroup> 87 <Compile Include="CSharpScript.cs" /> 87 <Compile Include="Scripts\CSharp\CSharpScript.cs" /> 88 <Compile Include="Scripts\Templates\CSharpScriptTemplate.cs" /> 89 <Compile Include="Scripts\Templates\ScriptTemplates.Designer.cs"> 90 <AutoGen>True</AutoGen> 91 <DesignTime>True</DesignTime> 92 <DependentUpon>ScriptTemplates.resx</DependentUpon> 93 </Compile> 88 94 <Compile Include="Variables.cs" /> 89 95 <Compile Include="VariableStore.cs" /> 90 96 <None Include="Plugin.cs.frame" /> 91 97 <Compile Include="Script.cs" /> 92 <Compile Include=" CSharpScriptBase.cs" />98 <Compile Include="Scripts\CSharp\CSharpScriptBase.cs" /> 93 99 <Compile Include="Plugin.cs" /> 94 100 <Compile Include="Properties\AssemblyInfo.cs" /> … … 130 136 </ProjectReference> 131 137 </ItemGroup> 138 <ItemGroup> 139 <EmbeddedResource Include="Scripts\Templates\ScriptTemplates.resx"> 140 <Generator>ResXFileCodeGenerator</Generator> 141 <LastGenOutput>ScriptTemplates.Designer.cs</LastGenOutput> 142 <CustomToolNamespace>HeuristicLab.Scripting</CustomToolNamespace> 143 </EmbeddedResource> 144 </ItemGroup> 132 145 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 133 146 <PropertyGroup> -
stable/HeuristicLab.Scripting/3.3/Script.cs
r10892 r11907 79 79 public Script() 80 80 : base("Script", "An empty script.") { 81 code = string.Empty;81 code = CodeTemplate; 82 82 } 83 83 public Script(string code) … … 108 108 WarningLevel = 4 109 109 }; 110 110 111 parameters.ReferencedAssemblies.AddRange( 111 112 GetAssemblies() 112 113 .Select(a => a.Location) 113 114 .ToArray()); 114 var unit = CreateCompilationUnit(); 115 var writer = new StringWriter(); 116 CodeProvider.GenerateCodeFromCompileUnit( 117 unit, 118 writer, 119 new CodeGeneratorOptions { 120 ElseOnClosing = true, 121 IndentString = " ", 122 }); 123 return CodeProvider.CompileAssemblyFromDom(parameters, unit); 115 116 return CodeProvider.CompileAssemblyFromSource(parameters, code); 124 117 } 125 118 … … 134 127 .AppendLine(error.ErrorText); 135 128 } 136 throw new Exception(string.Format("Compilation of \"{0}\" failed:{1}{2}",129 throw new InvalidOperationException(string.Format("Compilation of \"{0}\" failed:{1}{2}", 137 130 Name, Environment.NewLine, sb.ToString())); 138 131 } else { … … 142 135 143 136 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 } 137 var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => !a.IsDynamic && File.Exists(a.Location)).ToList(); 155 138 assemblies.Add(typeof(Microsoft.CSharp.RuntimeBinder.Binder).Assembly); // for dlr functionality 156 139 return assemblies; -
stable/HeuristicLab.Scripting/3.3/VariableStore.cs
r11090 r11907 21 21 22 22 using System; 23 using System.Drawing; 23 24 using System.IO; 24 25 using HeuristicLab.Collections; 25 26 using HeuristicLab.Common; 27 using HeuristicLab.Common.Resources; 26 28 using HeuristicLab.Core; 27 29 using HeuristicLab.Persistence.Core; … … 32 34 [Item("VariableStore", "Represents a variable store.")] 33 35 [StorableClass] 34 public class VariableStore : ObservableDictionary<string, object>, IContent, IDeepCloneable { 36 public class VariableStore : ObservableDictionary<string, object>, IItem { 37 #region Properties 38 public virtual string ItemName { 39 get { return ItemAttribute.GetName(GetType()); } 40 } 41 public virtual string ItemDescription { 42 get { return ItemAttribute.GetDescription(GetType()); } 43 } 44 public Version ItemVersion { 45 get { return ItemAttribute.GetVersion(GetType()); } 46 } 47 public static Image StaticItemImage { 48 get { return VSImageLibrary.Class; } 49 } 50 public virtual Image ItemImage { 51 get { return ItemAttribute.GetImage(GetType()); } 52 } 53 #endregion 54 55 #region Constructors & Cloning 35 56 [StorableConstructor] 36 57 protected VariableStore(bool deserializing) : base(deserializing) { } … … 68 89 } 69 90 } 91 #endregion 92 93 #region Overrides 94 public override string ToString() { 95 return ItemName; 96 } 97 #endregion 98 99 #region Events 100 public event EventHandler ItemImageChanged; 101 protected virtual void OnItemImageChanged() { 102 var handler = ItemImageChanged; 103 if (handler != null) handler(this, EventArgs.Empty); 104 } 105 public event EventHandler ToStringChanged; 106 protected virtual void OnToStringChanged() { 107 var handler = ToStringChanged; 108 if (handler != null) handler(this, EventArgs.Empty); 109 } 110 #endregion 70 111 } 71 112 }
Note: See TracChangeset
for help on using the changeset viewer.