Ejemplo n.º 1
0
        public static void RetrieveSchemaFromUrlToFile(String url, String path)
        {
			Util.Log("MetaData.RetrieveSchemaFromUrlToFile "+url+" file "+path);									
            RetrieveSchemaFromUrlToStream(url, File.Create(path));
        }
Ejemplo n.º 2
0
        public static void ConvertCodeSourceStreamToAssemblyFile(ArrayList outCodeStreamList, String assemblyPath, String strongNameFilename)
        {
#if FEATURE_PAL
            throw new NotImplementedException("Not Implemented in Rotor");
#else
            Util.Log("MetaData.ConvertCodeSourceStreamToAssemblyFile "+assemblyPath);												
            CompilerResults results = null;


            String stfilename = "__Sn.cs";
            try
            {
                if (strongNameFilename != null)
                {
                    // Create strong name file with assembly attribute
                    if (assemblyPath != null)
                    {
                        int index = assemblyPath.LastIndexOf("\\");
                        if (index > 0)
                        {
                            stfilename = assemblyPath.Substring(0,index+1)+stfilename;
                        }
                    }
                    FileStream fs = new FileStream(stfilename, FileMode.Create, FileAccess.ReadWrite);
                    StreamWriter fsWriter = new StreamWriter(fs, new UTF8Encoding(false, true));
                    fsWriter.WriteLine("// CLR Remoting Autogenerated Key file (to create a key file use: sn -k tmp.key)");
                    fsWriter.WriteLine("using System;");
                    fsWriter.WriteLine("using System.Reflection;");
                    fsWriter.WriteLine("[assembly: AssemblyKeyFile(@\""+strongNameFilename+"\")]");
                    fsWriter.WriteLine("[assembly: AssemblyVersion(@\"1.0.0.1\")]");
                    fsWriter.Flush();
                    fsWriter.Close();
                    fs.Close();
                    outCodeStreamList.Add(stfilename);
                    Util.Log("MetaData.ConvertCodeSourceStreamToAssemblyFile key file "+stfilename);												
                }

                String[] sourceTexts = new String[outCodeStreamList.Count];
                String[] sourceTextNames = new String[outCodeStreamList.Count];

                int streamCount = 0; // used for naming sourceTexts streams

                for(int item=0;item<outCodeStreamList.Count;item++)
                {
                  Stream inputStream;
                  bool close=false;

                  if (outCodeStreamList[item] is String)
                  {
                    // it's a file
                    String filename = (String)outCodeStreamList[item];
                    sourceTextNames[item] = (String)filename;
					Util.Log("MetaData.ConvertCodeSourceStreamToAssemblyFile  filename "+filename);																	
                    inputStream = File.OpenRead(filename);
                    close = true;
                  }
                  else if (outCodeStreamList[item] is Stream)
                  {
                    // it's a stream
                    inputStream = (Stream)outCodeStreamList[item];
                    sourceTextNames[item] = "Stream" + (streamCount++);
                  }
                  else
                  {
                     throw new RemotingException(CoreChannel.GetResourceString("Remoting_UnknownObjectInCodeStreamList"));
                  }

				  StreamReader streamReader = new StreamReader(inputStream);
                  sourceTexts[item] = streamReader.ReadToEnd();

                  if (true == close)
                    inputStream.Close();
                }

                String target = assemblyPath;

                String[] imports = new String[5];
                imports[0] = "System.dll";
                imports[1] = "System.Runtime.Remoting.dll";
                imports[2] = "System.Data.dll";
                imports[3] = "System.Xml.dll";
                imports[4] = "System.Web.Services.dll";
 
				if (sourceTexts.Length > 0)
				{
                          CodeDomProvider csharpCompiler = new CSharpCodeProvider();
		        	     CompilerParameters compileParams = new CompilerParameters(imports, target, true);
	            	     compileParams.GenerateExecutable = false; // target:library
                          results = csharpCompiler.CompileAssemblyFromSource(compileParams, sourceTexts);
				}
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally {
                File.Delete(stfilename);                
            }

            if (results.Errors.HasErrors)
            {
                CompilerErrorCollection errors = results.Errors;
                if (errors.Count > 0)
                {
                    foreach (CompilerError error in errors)
                    {
                        Console.WriteLine(error.ToString());  
                    }
                }
            }
#endif //!FEATURE_PAL
        }
Ejemplo n.º 3
0
        } // ConvertTypesToSchemaToStream


        public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, String path)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToFile 3 "+path);
            ConvertTypesToSchemaToStream(types, sdlType, File.Create(path));
        } // ConvertTypesToSchemaToFile
Ejemplo n.º 4
0
        public static void ConvertSchemaStreamToCodeSourceStream(bool clientProxy, String outputDirectory, Stream inputStream, ArrayList outCodeStreamList)
        {
			Util.Log("MetaData.ConvertSchemaStreamToCodeSourceStream 2 "+outputDirectory);									
          ConvertSchemaStreamToCodeSourceStream(clientProxy, outputDirectory, inputStream, outCodeStreamList, "", "");
        }