You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.175
Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
parent
4bdbaf4a88
commit
966bba02bb
@@ -1,217 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler.CodeCompiler.cs
|
||||
//
|
||||
// Authors:
|
||||
// Jackson Harper (Jackson@LatitudeGeo.com)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2002 Jackson Harper, All rights reserved
|
||||
// (C) 2003 Andreas Nahr
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
public abstract class CodeCompiler : CodeGenerator, ICodeCompiler
|
||||
{
|
||||
|
||||
protected CodeCompiler ()
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract string CompilerName {
|
||||
get;
|
||||
}
|
||||
|
||||
protected abstract string FileExtension {
|
||||
get;
|
||||
}
|
||||
|
||||
protected abstract string CmdArgsFromParameters (CompilerParameters options);
|
||||
|
||||
protected virtual CompilerResults FromDom (CompilerParameters options, CodeCompileUnit e)
|
||||
{
|
||||
return FromDomBatch (options, new CodeCompileUnit[]{e});
|
||||
}
|
||||
|
||||
protected virtual CompilerResults FromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
string[] fileNames = new string[ea.Length];
|
||||
int i = 0;
|
||||
if (options == null)
|
||||
options = new CompilerParameters ();
|
||||
|
||||
StringCollection assemblies = options.ReferencedAssemblies;
|
||||
|
||||
foreach (CodeCompileUnit e in ea) {
|
||||
fileNames[i] = Path.ChangeExtension (Path.GetTempFileName(), FileExtension);
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
StreamWriter s = new StreamWriter (f);
|
||||
if (e.ReferencedAssemblies != null) {
|
||||
foreach (string str in e.ReferencedAssemblies) {
|
||||
if (!assemblies.Contains (str))
|
||||
assemblies.Add (str);
|
||||
}
|
||||
}
|
||||
|
||||
((ICodeGenerator)this).GenerateCodeFromCompileUnit (e, s, new CodeGeneratorOptions());
|
||||
s.Close();
|
||||
f.Close();
|
||||
i++;
|
||||
}
|
||||
return Compile (options, fileNames, false);
|
||||
}
|
||||
|
||||
protected virtual CompilerResults FromFile (CompilerParameters options, string fileName)
|
||||
{
|
||||
return FromFileBatch (options, new string[] {fileName});
|
||||
}
|
||||
|
||||
protected virtual CompilerResults FromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
return Compile (options, fileNames, true);
|
||||
}
|
||||
|
||||
protected virtual CompilerResults FromSource (CompilerParameters options, string source)
|
||||
{
|
||||
return FromSourceBatch(options, new string[]{source});
|
||||
}
|
||||
|
||||
protected virtual CompilerResults FromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
string[] fileNames = new string[sources.Length];
|
||||
int i = 0;
|
||||
foreach (string source in sources) {
|
||||
fileNames[i] = Path.ChangeExtension (Path.GetTempFileName(), FileExtension);
|
||||
FileStream f = new FileStream (fileNames[i], FileMode.OpenOrCreate);
|
||||
StreamWriter s = new StreamWriter (f);
|
||||
s.Write (source);
|
||||
s.Close ();
|
||||
f.Close ();
|
||||
i++;
|
||||
}
|
||||
return Compile (options, fileNames, false);
|
||||
}
|
||||
|
||||
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
|
||||
private CompilerResults Compile (CompilerParameters options, string[] fileNames, bool keepFiles)
|
||||
{
|
||||
if (null == options)
|
||||
throw new ArgumentNullException ("options");
|
||||
if (null == fileNames)
|
||||
throw new ArgumentNullException ("fileNames");
|
||||
|
||||
options.TempFiles = new TempFileCollection ();
|
||||
foreach (string file in fileNames) {
|
||||
options.TempFiles.AddFile (file, keepFiles);
|
||||
}
|
||||
options.TempFiles.KeepFiles = keepFiles;
|
||||
|
||||
string std_output = String.Empty;
|
||||
string err_output = String.Empty;
|
||||
string cmd = String.Concat (CompilerName, " ", CmdArgsFromParameters (options));
|
||||
|
||||
CompilerResults results = new CompilerResults (new TempFileCollection ());
|
||||
results.NativeCompilerReturnValue = Executor.ExecWaitWithCapture (cmd,
|
||||
options.TempFiles, ref std_output, ref err_output);
|
||||
|
||||
string[] compiler_output_lines = std_output.Split (Environment.NewLine.ToCharArray ());
|
||||
foreach (string error_line in compiler_output_lines)
|
||||
ProcessCompilerOutputLine (results, error_line);
|
||||
|
||||
if (results.Errors.Count == 0)
|
||||
results.PathToAssembly = options.OutputAssembly;
|
||||
return results;
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected virtual string GetResponseFileCmdArgs (CompilerParameters options, string cmdArgs)
|
||||
{
|
||||
// FIXME I'm not sure what this function should do...
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromDom (CompilerParameters options, CodeCompileUnit e)
|
||||
{
|
||||
return FromDom (options, e);
|
||||
}
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
|
||||
{
|
||||
return FromDomBatch (options, ea);
|
||||
}
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromFile (CompilerParameters options, string fileName)
|
||||
{
|
||||
return FromFile (options, fileName);
|
||||
}
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromFileBatch (CompilerParameters options, string[] fileNames)
|
||||
{
|
||||
return FromFileBatch (options, fileNames);
|
||||
}
|
||||
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromSource (CompilerParameters options, string source)
|
||||
{
|
||||
return FromSource (options, source);
|
||||
}
|
||||
|
||||
|
||||
CompilerResults ICodeCompiler.CompileAssemblyFromSourceBatch (CompilerParameters options, string[] sources)
|
||||
{
|
||||
return FromSourceBatch (options, sources);
|
||||
}
|
||||
|
||||
protected static string JoinStringArray (string[] sa, string separator)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
int length = sa.Length;
|
||||
if (length > 1) {
|
||||
for (int i=0; i < length - 1; i++) {
|
||||
sb.Append ("\"");
|
||||
sb.Append (sa [i]);
|
||||
sb.Append ("\"");
|
||||
sb.Append (separator);
|
||||
}
|
||||
}
|
||||
if (length > 0) {
|
||||
sb.Append ("\"");
|
||||
sb.Append (sa [length - 1]);
|
||||
sb.Append ("\"");
|
||||
}
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
protected abstract void ProcessCompilerOutputLine (CompilerResults results, string line);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,94 +0,0 @@
|
||||
//
|
||||
// System.Configuration.CodeDomConfigurationHandler
|
||||
//
|
||||
// Authors:
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
//
|
||||
// Copyright (c) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
internal sealed class CodeDomConfigurationHandler: ConfigurationSection
|
||||
{
|
||||
static ConfigurationPropertyCollection properties;
|
||||
static ConfigurationProperty compilersProp;
|
||||
static CompilerCollection default_compilers;
|
||||
|
||||
static CodeDomConfigurationHandler ()
|
||||
{
|
||||
default_compilers = new CompilerCollection ();
|
||||
compilersProp = new ConfigurationProperty ("compilers", typeof (CompilerCollection), default_compilers);
|
||||
properties = new ConfigurationPropertyCollection ();
|
||||
properties.Add (compilersProp);
|
||||
}
|
||||
|
||||
public CodeDomConfigurationHandler ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitializeDefault ()
|
||||
{
|
||||
compilersProp = new ConfigurationProperty ("compilers", typeof (CompilerCollection), default_compilers);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
protected override void PostDeserialize ()
|
||||
{
|
||||
base.PostDeserialize ();
|
||||
}
|
||||
|
||||
protected override object GetRuntimeObject ()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("compilers")]
|
||||
public CompilerCollection Compilers {
|
||||
get { return (CompilerCollection) base [compilersProp]; }
|
||||
}
|
||||
|
||||
public CompilerInfo[] CompilerInfos {
|
||||
get {
|
||||
CompilerCollection cc = (CompilerCollection)base [compilersProp];
|
||||
if (cc == null)
|
||||
return null;
|
||||
return cc.CompilerInfos;
|
||||
}
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,320 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler.CodeDomProvider.cs
|
||||
//
|
||||
// Authors:
|
||||
// Daniel Stodden (stodden@in.tum.de)
|
||||
// Marek Safar (marek.safar@seznam.cz)
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
// Sebastien Pouliot <sebastien@ximian.com>
|
||||
//
|
||||
// Copyright (C) 2002,2003,2004,2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
|
||||
#pragma warning disable 618
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
[ComVisible (true)]
|
||||
[ToolboxItem (false)]
|
||||
public abstract class CodeDomProvider : Component
|
||||
{
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
protected CodeDomProvider()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public virtual string FileExtension {
|
||||
get {
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual LanguageOptions LanguageOptions {
|
||||
get {
|
||||
return LanguageOptions.None;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
[Obsolete ("ICodeCompiler is obsolete")]
|
||||
public abstract ICodeCompiler CreateCompiler();
|
||||
|
||||
[Obsolete ("ICodeGenerator is obsolete")]
|
||||
public abstract ICodeGenerator CreateGenerator();
|
||||
|
||||
public virtual ICodeGenerator CreateGenerator (string fileName)
|
||||
{
|
||||
return CreateGenerator();
|
||||
}
|
||||
|
||||
public virtual ICodeGenerator CreateGenerator (TextWriter output)
|
||||
{
|
||||
return CreateGenerator();
|
||||
}
|
||||
|
||||
[Obsolete ("ICodeParser is obsolete")]
|
||||
public virtual ICodeParser CreateParser()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual TypeConverter GetConverter (Type type)
|
||||
{
|
||||
return TypeDescriptor.GetConverter (type);
|
||||
}
|
||||
|
||||
public virtual CompilerResults CompileAssemblyFromDom (CompilerParameters options, params CodeCompileUnit[] compilationUnits)
|
||||
{
|
||||
ICodeCompiler cc = CreateCompiler ();
|
||||
if (cc == null)
|
||||
throw GetNotImplemented ();
|
||||
return cc.CompileAssemblyFromDomBatch (options, compilationUnits);
|
||||
}
|
||||
|
||||
public virtual CompilerResults CompileAssemblyFromFile (CompilerParameters options, params string[] fileNames)
|
||||
{
|
||||
ICodeCompiler cc = CreateCompiler ();
|
||||
if (cc == null)
|
||||
throw GetNotImplemented ();
|
||||
return cc.CompileAssemblyFromFileBatch (options, fileNames);
|
||||
}
|
||||
|
||||
public virtual CompilerResults CompileAssemblyFromSource (CompilerParameters options, params string[] sources)
|
||||
{
|
||||
ICodeCompiler cc = CreateCompiler ();
|
||||
if (cc == null)
|
||||
throw GetNotImplemented ();
|
||||
return cc.CompileAssemblyFromSourceBatch (options, sources);
|
||||
}
|
||||
|
||||
public virtual string CreateEscapedIdentifier (string value)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
return cg.CreateEscapedIdentifier (value);
|
||||
}
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static CodeDomProvider CreateProvider (string language)
|
||||
{
|
||||
CompilerInfo ci = GetCompilerInfo (language);
|
||||
return (ci == null) ? null : ci.CreateProvider ();
|
||||
}
|
||||
[ComVisible (false)]
|
||||
public static CodeDomProvider CreateProvider (string language, IDictionary<string, string> providerOptions)
|
||||
{
|
||||
CompilerInfo ci = GetCompilerInfo (language);
|
||||
return ci == null ? null : ci.CreateProvider (providerOptions);
|
||||
}
|
||||
|
||||
#endif
|
||||
public virtual string CreateValidIdentifier (string value)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
return cg.CreateValidIdentifier (value);
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromCompileUnit (CodeCompileUnit compileUnit,
|
||||
TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
cg.GenerateCodeFromCompileUnit (compileUnit, writer, options);
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromExpression (CodeExpression expression, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
cg.GenerateCodeFromExpression (expression, writer, options);
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromMember (CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
// Documented to always throw an exception (if not overriden)
|
||||
throw GetNotImplemented ();
|
||||
// Note: the pattern is different from other GenerateCodeFrom* because
|
||||
// ICodeGenerator doesn't have a GenerateCodeFromMember member
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromNamespace (CodeNamespace codeNamespace, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
cg.GenerateCodeFromNamespace (codeNamespace, writer, options);
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromStatement (CodeStatement statement, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
cg.GenerateCodeFromStatement (statement, writer, options);
|
||||
}
|
||||
|
||||
public virtual void GenerateCodeFromType (CodeTypeDeclaration codeType, TextWriter writer, CodeGeneratorOptions options)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
cg.GenerateCodeFromType (codeType, writer, options);
|
||||
}
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static CompilerInfo[] GetAllCompilerInfo ()
|
||||
{
|
||||
|
||||
return (Config == null) ? null : Config.CompilerInfos;
|
||||
}
|
||||
|
||||
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static CompilerInfo GetCompilerInfo (string language)
|
||||
{
|
||||
if (language == null)
|
||||
throw new ArgumentNullException ("language");
|
||||
if (Config == null)
|
||||
return null;
|
||||
CompilerCollection cc = Config.Compilers;
|
||||
return cc[language];
|
||||
}
|
||||
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static string GetLanguageFromExtension (string extension)
|
||||
{
|
||||
if (extension == null)
|
||||
throw new ArgumentNullException ("extension");
|
||||
|
||||
if (Config != null)
|
||||
return Config.Compilers.GetLanguageFromExtension (extension);
|
||||
return null;
|
||||
}
|
||||
#else
|
||||
public static CompilerInfo[] GetAllCompilerInfo () { return null; }
|
||||
public static CompilerInfo GetCompilerInfo (string language) { return null; }
|
||||
public static string GetLanguageFromExtension (string extension) { return null; }
|
||||
#endif
|
||||
|
||||
public virtual string GetTypeOutput (CodeTypeReference type)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
return cg.GetTypeOutput (type);
|
||||
}
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static bool IsDefinedExtension (string extension)
|
||||
{
|
||||
if (extension == null)
|
||||
throw new ArgumentNullException ("extension");
|
||||
|
||||
if (Config != null)
|
||||
return (Config.Compilers.GetCompilerInfoForExtension (extension) != null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[ComVisible (false)]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public static bool IsDefinedLanguage (string language)
|
||||
{
|
||||
if (language == null)
|
||||
throw new ArgumentNullException ("language");
|
||||
|
||||
if (Config != null)
|
||||
return (Config.Compilers.GetCompilerInfoForLanguage (language) != null);
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
public virtual bool IsValidIdentifier (string value)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
return cg.IsValidIdentifier (value);
|
||||
}
|
||||
|
||||
public virtual CodeCompileUnit Parse (TextReader codeStream)
|
||||
{
|
||||
ICodeParser cp = CreateParser ();
|
||||
if (cp == null)
|
||||
throw GetNotImplemented ();
|
||||
return cp.Parse (codeStream);
|
||||
}
|
||||
|
||||
public virtual bool Supports (GeneratorSupport supports)
|
||||
{
|
||||
ICodeGenerator cg = CreateGenerator ();
|
||||
if (cg == null)
|
||||
throw GetNotImplemented ();
|
||||
return cg.Supports (supports);
|
||||
}
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
static CodeDomConfigurationHandler Config {
|
||||
get { return ConfigurationManager.GetSection ("system.codedom") as CodeDomConfigurationHandler; }
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// This is used to prevent confusing Moma about methods not implemented.
|
||||
//
|
||||
Exception GetNotImplemented ()
|
||||
{
|
||||
return new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
@@ -1,45 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler.CodeParser.cs
|
||||
//
|
||||
// Author:
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2003 Andreas Nahr
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
|
||||
public abstract class CodeParser : ICodeParser
|
||||
{
|
||||
|
||||
protected CodeParser ()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract CodeCompileUnit Parse (TextReader codeStream);
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
//
|
||||
// System.Web.Configuration.CompilerCollection
|
||||
//
|
||||
// Authors:
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
// (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
internal sealed class Compiler : ConfigurationElement
|
||||
{
|
||||
static ConfigurationProperty compilerOptionsProp;
|
||||
static ConfigurationProperty extensionProp;
|
||||
static ConfigurationProperty languageProp;
|
||||
static ConfigurationProperty typeProp;
|
||||
static ConfigurationProperty warningLevelProp;
|
||||
static ConfigurationProperty providerOptionsProp;
|
||||
|
||||
static ConfigurationPropertyCollection properties;
|
||||
|
||||
static Compiler ()
|
||||
{
|
||||
compilerOptionsProp = new ConfigurationProperty("compilerOptions", typeof (string), "");
|
||||
extensionProp = new ConfigurationProperty("extension", typeof (string), "");
|
||||
languageProp = new ConfigurationProperty("language", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
|
||||
typeProp = new ConfigurationProperty("type", typeof (string), "", ConfigurationPropertyOptions.IsRequired);
|
||||
warningLevelProp = new ConfigurationProperty("warningLevel", typeof (int), 0,
|
||||
TypeDescriptor.GetConverter (typeof (int)),
|
||||
new IntegerValidator (0, 4),
|
||||
ConfigurationPropertyOptions.None);
|
||||
providerOptionsProp = new ConfigurationProperty ("", typeof (CompilerProviderOptionsCollection), null, null, null,
|
||||
ConfigurationPropertyOptions.IsDefaultCollection);
|
||||
|
||||
properties = new ConfigurationPropertyCollection ();
|
||||
properties.Add (compilerOptionsProp);
|
||||
properties.Add (extensionProp);
|
||||
properties.Add (languageProp);
|
||||
properties.Add (typeProp);
|
||||
properties.Add (warningLevelProp);
|
||||
properties.Add (providerOptionsProp);
|
||||
}
|
||||
|
||||
internal Compiler ()
|
||||
{
|
||||
}
|
||||
|
||||
public Compiler (string compilerOptions, string extension, string language, string type, int warningLevel)
|
||||
{
|
||||
this.CompilerOptions = compilerOptions;
|
||||
this.Extension = extension;
|
||||
this.Language = language;
|
||||
this.Type = type;
|
||||
this.WarningLevel = warningLevel;
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("compilerOptions", DefaultValue = "")]
|
||||
public string CompilerOptions {
|
||||
get { return (string) base[compilerOptionsProp]; }
|
||||
internal set { base[compilerOptionsProp] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("extension", DefaultValue = "")]
|
||||
public string Extension {
|
||||
get { return (string) base[extensionProp]; }
|
||||
internal set { base[extensionProp] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("language", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
|
||||
public string Language {
|
||||
get { return (string) base[languageProp]; }
|
||||
internal set { base[languageProp] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("type", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
|
||||
public string Type {
|
||||
get { return (string) base[typeProp]; }
|
||||
internal set { base[typeProp] = value; }
|
||||
}
|
||||
|
||||
[IntegerValidator (MinValue = 0, MaxValue = 4)]
|
||||
[ConfigurationProperty ("warningLevel", DefaultValue = "0")]
|
||||
public int WarningLevel {
|
||||
get { return (int) base[warningLevelProp]; }
|
||||
internal set { base[warningLevelProp] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
|
||||
public CompilerProviderOptionsCollection ProviderOptions {
|
||||
get { return (CompilerProviderOptionsCollection) base [providerOptionsProp]; }
|
||||
internal set { base [providerOptionsProp] = value; }
|
||||
}
|
||||
|
||||
public Dictionary <string, string> ProviderOptionsDictionary {
|
||||
get { return ProviderOptions.ProviderOptions; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,238 +0,0 @@
|
||||
//
|
||||
// System.Web.Configuration.CompilerCollection
|
||||
//
|
||||
// Authors:
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
// (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
[ConfigurationCollection (typeof (Compiler), AddItemName = "compiler", CollectionType = ConfigurationElementCollectionType.BasicMap)]
|
||||
internal sealed class CompilerCollection : ConfigurationElementCollection
|
||||
{
|
||||
static readonly string defaultCompilerVersion = "3.5";
|
||||
static ConfigurationPropertyCollection properties;
|
||||
static List <CompilerInfo> compiler_infos;
|
||||
static Dictionary <string, CompilerInfo> compiler_languages;
|
||||
static Dictionary <string, CompilerInfo> compiler_extensions;
|
||||
|
||||
static CompilerCollection ()
|
||||
{
|
||||
properties = new ConfigurationPropertyCollection ();
|
||||
compiler_infos = new List <CompilerInfo> ();
|
||||
compiler_languages = new Dictionary <string, CompilerInfo> (16, StringComparer.OrdinalIgnoreCase);
|
||||
compiler_extensions = new Dictionary <string, CompilerInfo> (6, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
CompilerInfo compiler = new CompilerInfo ();
|
||||
compiler.Languages = "c#;cs;csharp";
|
||||
compiler.Extensions = ".cs";
|
||||
compiler.TypeName = "Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
compiler.ProviderOptions = new Dictionary <string, string> (1);
|
||||
compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
|
||||
AddCompilerInfo (compiler);
|
||||
|
||||
compiler = new CompilerInfo ();
|
||||
compiler.Languages = "vb;vbs;visualbasic;vbscript";
|
||||
compiler.Extensions = ".vb";
|
||||
compiler.TypeName = "Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
|
||||
compiler.ProviderOptions = new Dictionary <string, string> (1);
|
||||
compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
|
||||
AddCompilerInfo (compiler);
|
||||
|
||||
compiler = new CompilerInfo ();
|
||||
compiler.Languages = "js;jscript;javascript";
|
||||
compiler.Extensions = ".js";
|
||||
compiler.TypeName = "Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.1100.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
compiler.ProviderOptions = new Dictionary <string, string> (1);
|
||||
compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
|
||||
AddCompilerInfo (compiler);
|
||||
|
||||
compiler = new CompilerInfo ();
|
||||
compiler.Languages = "vj#;vjs;vjsharp";
|
||||
compiler.Extensions = ".jsl;.java";
|
||||
compiler.TypeName = "Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
compiler.ProviderOptions = new Dictionary <string, string> (1);
|
||||
compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
|
||||
AddCompilerInfo (compiler);
|
||||
|
||||
compiler = new CompilerInfo ();
|
||||
compiler.Languages = "c++;mc;cpp";
|
||||
compiler.Extensions = ".h";
|
||||
compiler.TypeName = "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
|
||||
compiler.ProviderOptions = new Dictionary <string, string> (1);
|
||||
compiler.ProviderOptions ["CompilerVersion"] = defaultCompilerVersion;
|
||||
AddCompilerInfo (compiler);
|
||||
}
|
||||
|
||||
public CompilerCollection ()
|
||||
{
|
||||
}
|
||||
|
||||
static void AddCompilerInfo (CompilerInfo ci)
|
||||
{
|
||||
ci.Init ();
|
||||
compiler_infos.Add (ci);
|
||||
|
||||
string[] languages = ci.GetLanguages ();
|
||||
if (languages != null)
|
||||
foreach (string language in languages)
|
||||
compiler_languages [language] = ci;
|
||||
|
||||
string[] extensions = ci.GetExtensions ();
|
||||
if (extensions != null)
|
||||
foreach (string extension in extensions)
|
||||
compiler_extensions [extension] = ci;
|
||||
}
|
||||
|
||||
static void AddCompilerInfo (Compiler compiler)
|
||||
{
|
||||
CompilerInfo ci = new CompilerInfo ();
|
||||
ci.Languages = compiler.Language;
|
||||
ci.Extensions = compiler.Extension;
|
||||
ci.TypeName = compiler.Type;
|
||||
ci.ProviderOptions = compiler.ProviderOptionsDictionary;
|
||||
ci.CompilerOptions = compiler.CompilerOptions;
|
||||
ci.WarningLevel = compiler.WarningLevel;
|
||||
AddCompilerInfo (ci);
|
||||
}
|
||||
|
||||
protected override void BaseAdd (ConfigurationElement element)
|
||||
{
|
||||
Compiler compiler = element as Compiler;
|
||||
if (compiler != null)
|
||||
AddCompilerInfo (compiler);
|
||||
base.BaseAdd (element);
|
||||
}
|
||||
|
||||
protected override bool ThrowOnDuplicate {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new Compiler ();
|
||||
}
|
||||
|
||||
public CompilerInfo GetCompilerInfoForLanguage (string language)
|
||||
{
|
||||
if (compiler_languages.Count == 0)
|
||||
return null;
|
||||
|
||||
CompilerInfo ci;
|
||||
if (compiler_languages.TryGetValue (language, out ci))
|
||||
return ci;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CompilerInfo GetCompilerInfoForExtension (string extension)
|
||||
{
|
||||
if (compiler_extensions.Count == 0)
|
||||
return null;
|
||||
|
||||
CompilerInfo ci;
|
||||
if (compiler_extensions.TryGetValue (extension, out ci))
|
||||
return ci;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetLanguageFromExtension (string extension)
|
||||
{
|
||||
CompilerInfo ci = GetCompilerInfoForExtension (extension);
|
||||
if (ci == null)
|
||||
return null;
|
||||
string[] languages = ci.GetLanguages ();
|
||||
if (languages != null && languages.Length > 0)
|
||||
return languages [0];
|
||||
return null;
|
||||
}
|
||||
|
||||
public Compiler Get (int index)
|
||||
{
|
||||
return (Compiler) BaseGet (index);
|
||||
}
|
||||
|
||||
public Compiler Get (string language)
|
||||
{
|
||||
return (Compiler) BaseGet (language);
|
||||
}
|
||||
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((Compiler)element).Language;
|
||||
}
|
||||
|
||||
public string GetKey (int index)
|
||||
{
|
||||
return (string)BaseGetKey (index);
|
||||
}
|
||||
|
||||
public string[ ] AllKeys {
|
||||
get {
|
||||
string[] keys = new string[compiler_infos.Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
keys[i] = compiler_infos[i].Languages;
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType {
|
||||
get { return ConfigurationElementCollectionType.BasicMap; }
|
||||
}
|
||||
|
||||
protected override string ElementName {
|
||||
get { return "compiler"; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
|
||||
public Compiler this[int index] {
|
||||
get { return (Compiler) BaseGet (index); }
|
||||
}
|
||||
|
||||
public new CompilerInfo this[string language] {
|
||||
get {
|
||||
return GetCompilerInfoForLanguage (language);
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerInfo[] CompilerInfos {
|
||||
get {
|
||||
return compiler_infos.ToArray ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,144 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler CompilerInfo class
|
||||
//
|
||||
// Author:
|
||||
// Marek Safar (marek.safar@seznam.cz)
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
//
|
||||
// Copyright (c) 2004,2005 Novell, Inc. (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public sealed class CompilerInfo
|
||||
{
|
||||
internal string Languages;
|
||||
internal string Extensions;
|
||||
internal string TypeName;
|
||||
internal int WarningLevel;
|
||||
internal string CompilerOptions;
|
||||
internal Dictionary <string, string> ProviderOptions;
|
||||
|
||||
bool inited;
|
||||
Type type;
|
||||
|
||||
internal CompilerInfo ()
|
||||
{
|
||||
}
|
||||
|
||||
internal void Init ()
|
||||
{
|
||||
if (inited)
|
||||
return;
|
||||
|
||||
inited = true;
|
||||
type = Type.GetType (TypeName);
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
if (!typeof (CodeDomProvider).IsAssignableFrom (type))
|
||||
type = null;
|
||||
}
|
||||
|
||||
public Type CodeDomProviderType {
|
||||
get {
|
||||
if (type == null) {
|
||||
type = Type.GetType (TypeName, false);
|
||||
#if CONFIGURATION_DEP
|
||||
if (type == null)
|
||||
throw new ConfigurationErrorsException ("Unable to locate compiler type '" + TypeName + "'");
|
||||
#endif
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsCodeDomProviderTypeValid {
|
||||
get { return type != null; }
|
||||
}
|
||||
|
||||
public CompilerParameters CreateDefaultCompilerParameters ()
|
||||
{
|
||||
CompilerParameters cparams = new CompilerParameters ();
|
||||
if (CompilerOptions == null)
|
||||
cparams.CompilerOptions = String.Empty;
|
||||
else
|
||||
cparams.CompilerOptions = CompilerOptions;
|
||||
cparams.WarningLevel = WarningLevel;
|
||||
|
||||
return cparams;
|
||||
}
|
||||
|
||||
public CodeDomProvider CreateProvider ()
|
||||
{
|
||||
return CreateProvider (ProviderOptions);
|
||||
}
|
||||
|
||||
public
|
||||
CodeDomProvider CreateProvider (IDictionary<string, string> providerOptions)
|
||||
{
|
||||
Type providerType = CodeDomProviderType;
|
||||
if (providerOptions != null && providerOptions.Count > 0) {
|
||||
ConstructorInfo ctor = providerType.GetConstructor (new [] { typeof (IDictionary <string, string>) });
|
||||
if (ctor != null)
|
||||
return (CodeDomProvider) ctor.Invoke (new object[] { providerOptions });
|
||||
}
|
||||
|
||||
return (CodeDomProvider) Activator.CreateInstance (providerType);
|
||||
}
|
||||
|
||||
public override bool Equals (object o)
|
||||
{
|
||||
if (!(o is CompilerInfo))
|
||||
return false;
|
||||
|
||||
CompilerInfo c = (CompilerInfo) o;
|
||||
return c.TypeName == TypeName;
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return TypeName.GetHashCode ();
|
||||
}
|
||||
|
||||
public string [] GetExtensions ()
|
||||
{
|
||||
return Extensions.Split (';');
|
||||
}
|
||||
|
||||
public string [] GetLanguages ()
|
||||
{
|
||||
return Languages.Split (';');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,71 +0,0 @@
|
||||
// System.Web.Configuration.CompilerProviderOptionsCollection.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack (mhabersack@novell.com)
|
||||
//
|
||||
// (C) 2007 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
internal sealed class CompilerProviderOption : ConfigurationElement
|
||||
{
|
||||
static ConfigurationProperty nameProp;
|
||||
static ConfigurationProperty valueProp;
|
||||
static ConfigurationPropertyCollection properties;
|
||||
|
||||
static CompilerProviderOption ()
|
||||
{
|
||||
nameProp = new ConfigurationProperty ("name", typeof (string), "",
|
||||
ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
|
||||
valueProp = new ConfigurationProperty ("value", typeof (string), "",
|
||||
ConfigurationPropertyOptions.IsRequired);
|
||||
|
||||
properties = new ConfigurationPropertyCollection ();
|
||||
properties.Add (nameProp);
|
||||
properties.Add (valueProp);
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
|
||||
public string Name {
|
||||
get { return (string) base [nameProp]; }
|
||||
set { base [nameProp] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty ("value", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired)]
|
||||
public string Value {
|
||||
get { return (string) base [valueProp]; }
|
||||
set { base [valueProp] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,131 +0,0 @@
|
||||
//
|
||||
// System.Web.Configuration.CompilerProviderOptionsCollection.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Habersack (mhabersack@novell.com)
|
||||
//
|
||||
// (C) 2007 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if CONFIGURATION_DEP
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.CodeDom.Compiler
|
||||
{
|
||||
[ConfigurationCollection (typeof (CompilerProviderOption), CollectionType = ConfigurationElementCollectionType.BasicMap, AddItemName = "providerOption")]
|
||||
internal sealed class CompilerProviderOptionsCollection : ConfigurationElementCollection
|
||||
{
|
||||
static ConfigurationPropertyCollection properties;
|
||||
|
||||
static CompilerProviderOptionsCollection ()
|
||||
{
|
||||
properties = new ConfigurationPropertyCollection ();
|
||||
}
|
||||
|
||||
public CompilerProviderOptionsCollection ()
|
||||
{
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new CompilerProviderOption ();
|
||||
}
|
||||
|
||||
public CompilerProviderOption Get (int index)
|
||||
{
|
||||
return (CompilerProviderOption) BaseGet (index);
|
||||
}
|
||||
|
||||
public CompilerProviderOption Get (string name)
|
||||
{
|
||||
return (CompilerProviderOption) BaseGet (name);
|
||||
}
|
||||
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((CompilerProviderOption) element).Name;
|
||||
}
|
||||
|
||||
public string GetKey (int index)
|
||||
{
|
||||
return (string) BaseGetKey (index);
|
||||
}
|
||||
|
||||
public string[] AllKeys {
|
||||
get {
|
||||
int count = Count;
|
||||
string[] keys = new string [count];
|
||||
for (int i = 0; i < count; i++)
|
||||
keys [i] = this [i].Name;
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string ElementName {
|
||||
get { return "providerOption"; }
|
||||
}
|
||||
|
||||
protected override ConfigurationPropertyCollection Properties {
|
||||
get { return properties; }
|
||||
}
|
||||
|
||||
public Dictionary <string, string> ProviderOptions {
|
||||
get {
|
||||
int count = Count;
|
||||
|
||||
if (count == 0)
|
||||
return null;
|
||||
|
||||
Dictionary <string, string> ret = new Dictionary <string, string> (count);
|
||||
CompilerProviderOption opt;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
opt = this [i];
|
||||
ret.Add (opt.Name, opt.Value);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerProviderOption this [int index] {
|
||||
get { return (CompilerProviderOption) BaseGet (index); }
|
||||
}
|
||||
|
||||
public new CompilerProviderOption this [string name] {
|
||||
get {
|
||||
foreach (CompilerProviderOption c in this) {
|
||||
if (c.Name == name)
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -1,126 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler.CompilerResults.cs
|
||||
//
|
||||
// Authors:
|
||||
// Daniel Stodden (stodden@in.tum.de)
|
||||
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
|
||||
//
|
||||
// (C) 2002 Ximian, Inc.
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Reflection;
|
||||
using System.Security.Permissions;
|
||||
using System.Security.Policy;
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
[Serializable]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
[PermissionSet (SecurityAction.InheritanceDemand, Unrestricted = true)]
|
||||
public class CompilerResults {
|
||||
|
||||
private Assembly compiledAssembly;
|
||||
private CompilerErrorCollection errors = new CompilerErrorCollection ();
|
||||
private Evidence evidence;
|
||||
private int nativeCompilerReturnValue = 0;
|
||||
private StringCollection output = new StringCollection ();
|
||||
private string pathToAssembly;
|
||||
private TempFileCollection tempFiles;
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
public CompilerResults (TempFileCollection tempFiles)
|
||||
{
|
||||
this.tempFiles = tempFiles;
|
||||
}
|
||||
|
||||
//
|
||||
// Properties
|
||||
//
|
||||
public Assembly CompiledAssembly {
|
||||
get {
|
||||
if ((compiledAssembly == null) && (pathToAssembly != null))
|
||||
compiledAssembly = Assembly.LoadFrom (pathToAssembly);
|
||||
return compiledAssembly;
|
||||
}
|
||||
set {
|
||||
compiledAssembly = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CompilerErrorCollection Errors {
|
||||
get {
|
||||
if (errors == null)
|
||||
errors = new CompilerErrorCollection();
|
||||
return errors;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public Evidence Evidence {
|
||||
get { return evidence; }
|
||||
[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
|
||||
set { evidence = value; }
|
||||
}
|
||||
|
||||
public int NativeCompilerReturnValue {
|
||||
get {
|
||||
return nativeCompilerReturnValue;
|
||||
}
|
||||
set {
|
||||
nativeCompilerReturnValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public StringCollection Output {
|
||||
get {
|
||||
if (output == null)
|
||||
output = new StringCollection();
|
||||
return output;
|
||||
}
|
||||
internal set {
|
||||
output = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PathToAssembly {
|
||||
get {
|
||||
return pathToAssembly;
|
||||
}
|
||||
set {
|
||||
pathToAssembly = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TempFileCollection TempFiles {
|
||||
get {
|
||||
return tempFiles;
|
||||
}
|
||||
set {
|
||||
tempFiles = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,280 +0,0 @@
|
||||
//
|
||||
// System.CodeDom.Compiler TempFileCollection Class implementation
|
||||
//
|
||||
// Author:
|
||||
// Dick Porter (dick@ximian.com)
|
||||
//
|
||||
// (C) Copyright 2003 Ximian, Inc.
|
||||
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System.CodeDom.Compiler {
|
||||
|
||||
[Serializable]
|
||||
[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
public class TempFileCollection:ICollection, IEnumerable, IDisposable
|
||||
{
|
||||
Hashtable filehash;
|
||||
string tempdir;
|
||||
bool keepfiles;
|
||||
string basepath;
|
||||
Random rnd;
|
||||
string ownTempDir;
|
||||
|
||||
public TempFileCollection ()
|
||||
: this (String.Empty, false)
|
||||
{
|
||||
}
|
||||
|
||||
public TempFileCollection(string tempDir)
|
||||
: this (tempDir, false)
|
||||
{
|
||||
}
|
||||
|
||||
public TempFileCollection(string tempDir, bool keepFiles)
|
||||
{
|
||||
filehash=new Hashtable();
|
||||
tempdir = (tempDir == null) ? String.Empty : tempDir;
|
||||
keepfiles=keepFiles;
|
||||
}
|
||||
|
||||
public string BasePath
|
||||
{
|
||||
get {
|
||||
if(basepath==null) {
|
||||
|
||||
if (rnd == null)
|
||||
rnd = new Random ();
|
||||
|
||||
// note: this property *cannot* change TempDir property
|
||||
string temp = tempdir;
|
||||
if (temp.Length == 0) {
|
||||
if (ownTempDir != null) {
|
||||
temp = ownTempDir;
|
||||
Directory.CreateDirectory (temp);
|
||||
} else {
|
||||
temp = CreateOwnTempDir ();
|
||||
}
|
||||
}
|
||||
|
||||
// Create a temporary file at the target directory. This ensures
|
||||
// that the generated file name is unique.
|
||||
int test_counter = 1000;
|
||||
while (true) {
|
||||
int num = rnd.Next ();
|
||||
num++;
|
||||
basepath = Path.Combine (temp, num.ToString("x"));
|
||||
string path = basepath + ".tmp";
|
||||
|
||||
try {
|
||||
using (var f = new FileStream (path, FileMode.CreateNew)) {
|
||||
break;
|
||||
}
|
||||
} catch (IOException) {
|
||||
if (test_counter-- > 0)
|
||||
continue;
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO_FEATURE_CAS
|
||||
// and you must have discovery access to the combined path
|
||||
// note: the cache behaviour is tested in the CAS tests
|
||||
if (SecurityManager.SecurityEnabled) {
|
||||
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, basepath).Demand ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return(basepath);
|
||||
}
|
||||
}
|
||||
|
||||
string CreateOwnTempDir ()
|
||||
{
|
||||
// this call ensure the Environment permissions check
|
||||
string basedir = Path.GetTempPath ();
|
||||
|
||||
// Create a subdirectory with the correct user permissions
|
||||
int res = -1;
|
||||
bool win32 = false;
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Win32S:
|
||||
case PlatformID.Win32Windows:
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.WinCE:
|
||||
win32 = true;
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
int num = rnd.Next ();
|
||||
num++;
|
||||
ownTempDir = Path.Combine (basedir, num.ToString("x"));
|
||||
if (Directory.Exists (ownTempDir))
|
||||
continue;
|
||||
if (win32)
|
||||
Directory.CreateDirectory (ownTempDir);
|
||||
else
|
||||
res = mkdir (ownTempDir, 0x1c0);
|
||||
if (res != 0) {
|
||||
if (!Directory.Exists (ownTempDir))
|
||||
throw new IOException ();
|
||||
// Somebody already created the dir, keep trying
|
||||
}
|
||||
} while (res != 0);
|
||||
return ownTempDir;
|
||||
}
|
||||
|
||||
int ICollection.Count {
|
||||
get {
|
||||
return filehash.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get {
|
||||
return(filehash.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public bool KeepFiles
|
||||
{
|
||||
get {
|
||||
return(keepfiles);
|
||||
}
|
||||
set {
|
||||
keepfiles=value;
|
||||
}
|
||||
}
|
||||
|
||||
public string TempDir
|
||||
{
|
||||
get {
|
||||
// note: we only return what we were supplied so there
|
||||
// is no permission protecting this information
|
||||
return tempdir;
|
||||
}
|
||||
}
|
||||
|
||||
public string AddExtension(string fileExtension)
|
||||
{
|
||||
return(AddExtension(fileExtension, keepfiles));
|
||||
}
|
||||
|
||||
public string AddExtension(string fileExtension, bool keepFile)
|
||||
{
|
||||
string filename=BasePath+"."+fileExtension;
|
||||
AddFile(filename, keepFile);
|
||||
return(filename);
|
||||
}
|
||||
|
||||
public void AddFile(string fileName, bool keepFile)
|
||||
{
|
||||
filehash.Add(fileName, keepFile);
|
||||
}
|
||||
|
||||
public void CopyTo(string[] fileNames, int start)
|
||||
{
|
||||
filehash.Keys.CopyTo(fileNames, start);
|
||||
}
|
||||
|
||||
void ICollection.CopyTo(Array array, int start)
|
||||
{
|
||||
filehash.Keys.CopyTo(array, start);
|
||||
}
|
||||
|
||||
object ICollection.SyncRoot {
|
||||
get {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
bool ICollection.IsSynchronized {
|
||||
get {
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
bool allDeleted = true;
|
||||
string[] filenames = new string[filehash.Count];
|
||||
filehash.Keys.CopyTo (filenames, 0);
|
||||
|
||||
foreach(string file in filenames) {
|
||||
if((bool)filehash[file]==false) {
|
||||
File.Delete(file);
|
||||
filehash.Remove(file);
|
||||
} else
|
||||
allDeleted = false;
|
||||
}
|
||||
if (basepath != null) {
|
||||
string tmpFile = basepath + ".tmp";
|
||||
File.Delete (tmpFile);
|
||||
basepath = null;
|
||||
}
|
||||
if (allDeleted && ownTempDir != null && filenames.Length > 0) {
|
||||
Directory.Delete (ownTempDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return(filehash.Keys.GetEnumerator());
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
return(filehash.Keys.GetEnumerator());
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
Delete();
|
||||
if (disposing) {
|
||||
GC.SuppressFinalize (true);
|
||||
}
|
||||
}
|
||||
|
||||
~TempFileCollection()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
[DllImport ("libc")] private static extern int mkdir (string olpath, uint mode);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user