Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / ManagedLibraries / Remoting / MetaData / MetaData.cs / 1305376 / MetaData.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //============================================================ // // File: MetaDataServices //// Author: Gopal Kakivaya (GopalK) // // Purpose: Defines APIs for Metadata // // Date: April 01, 2000 // //=========================================================== namespace System.Runtime.Remoting.MetadataServices { using System; using System.Threading; using System.Collections; using System.Reflection; using System.Xml; using System.Diagnostics; using System.IO; using System.Net; using System.Text; using System.Runtime.InteropServices; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Metadata; using Microsoft.CSharp; using System.CodeDom.Compiler; using System.Globalization; public class MetaData { public static void ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, String path) { Util.Log("MetaData.ConvertTypesToSchemaToFile 1 "+path); ConvertTypesToSchemaToStream(types, sdlType, File.Create(path)); } // ConvertTypesToSchemaToFile public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream) { Util.Log("MetaData.ConvertTypesToSchemaToFile 2 "); // < ServiceType[] serviceTypes = new ServiceType[types.Length]; for (int i=0; i0) { 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 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 } /* /target:module -> Name="target", Value="module" /target:library -> Name="target", Value="library" /main:MyClass -> Name="m", Value="MyClass" /debug+ -> Name="debug", Value=true // The dictionary of options takes almost ALL of the normal command-line options, but only using their 'short form' and without the preceding slash or dash. */ public static void ConvertCodeSourceFileToAssemblyFile(String codePath, String assemblyPath, String strongNameFilename) { Util.Log("MetaData.ConvertCodeSourceFileToAssemblyFile codePath "+codePath+" assemblyPath "+assemblyPath); ArrayList arrayList = new ArrayList(); arrayList.Add(codePath); ConvertCodeSourceStreamToAssemblyFile(arrayList, assemblyPath, strongNameFilename); } // Helpers public static void SaveStreamToFile(Stream inputStream, String path) { Util.Log("MetaData.SaveStreamToFile "+path); Stream outputStream = File.Create(path); TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true)); StreamReader sr = new StreamReader(inputStream); tw.Write(sr.ReadToEnd()); tw.Flush(); tw.Close(); outputStream.Close(); } } // class MetaData public class ServiceType { private Type _type; // Type of object being exported. private String _url; // This may be null if no address is available. public ServiceType(Type type) { _type = type; _url = null; } // ServiceType public ServiceType(Type type, String url) { _type = type; _url = url; } // ServiceType public Type ObjectType { get { return _type; } } public String Url { get { return _url; } } } // ServiceType } // namespace System.Runtime.Remoting.MetadataServices // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== //============================================================ // // File: MetaDataServices // // Author: Gopal Kakivaya (GopalK) // // Purpose: Defines APIs for Metadata // // Date: April 01, 2000 // //=========================================================== namespace System.Runtime.Remoting.MetadataServices { using System; using System.Threading; using System.Collections; using System.Reflection; using System.Xml; using System.Diagnostics; using System.IO; using System.Net; using System.Text; using System.Runtime.InteropServices; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Metadata; using Microsoft.CSharp; using System.CodeDom.Compiler; using System.Globalization; public class MetaData { public static void ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, String path) { Util.Log("MetaData.ConvertTypesToSchemaToFile 1 "+path); ConvertTypesToSchemaToStream(types, sdlType, File.Create(path)); } // ConvertTypesToSchemaToFile public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream) { Util.Log("MetaData.ConvertTypesToSchemaToFile 2 "); // < ServiceType[] serviceTypes = new ServiceType[types.Length]; for (int i=0; i0) { 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 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 } /* /target:module -> Name="target", Value="module" /target:library -> Name="target", Value="library" /main:MyClass -> Name="m", Value="MyClass" /debug+ -> Name="debug", Value=true // The dictionary of options takes almost ALL of the normal command-line options, but only using their 'short form' and without the preceding slash or dash. */ public static void ConvertCodeSourceFileToAssemblyFile(String codePath, String assemblyPath, String strongNameFilename) { Util.Log("MetaData.ConvertCodeSourceFileToAssemblyFile codePath "+codePath+" assemblyPath "+assemblyPath); ArrayList arrayList = new ArrayList(); arrayList.Add(codePath); ConvertCodeSourceStreamToAssemblyFile(arrayList, assemblyPath, strongNameFilename); } // Helpers public static void SaveStreamToFile(Stream inputStream, String path) { Util.Log("MetaData.SaveStreamToFile "+path); Stream outputStream = File.Create(path); TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true)); StreamReader sr = new StreamReader(inputStream); tw.Write(sr.ReadToEnd()); tw.Flush(); tw.Close(); outputStream.Close(); } } // class MetaData public class ServiceType { private Type _type; // Type of object being exported. private String _url; // This may be null if no address is available. public ServiceType(Type type) { _type = type; _url = null; } // ServiceType public ServiceType(Type type, String url) { _type = type; _url = url; } // ServiceType public Type ObjectType { get { return _type; } } public String Url { get { return _url; } } } // ServiceType } // namespace System.Runtime.Remoting.MetadataServices // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InternalsVisibleToAttribute.cs
- DataGridViewCheckBoxCell.cs
- ClientBuildManagerCallback.cs
- ExpandCollapsePattern.cs
- LinkLabelLinkClickedEvent.cs
- Span.cs
- VectorCollection.cs
- ImageDrawing.cs
- CharacterMetricsDictionary.cs
- _SecureChannel.cs
- OledbConnectionStringbuilder.cs
- HierarchicalDataBoundControlAdapter.cs
- TextBreakpoint.cs
- QilUnary.cs
- InvalidCardException.cs
- localization.cs
- RemoteWebConfigurationHostServer.cs
- HierarchicalDataTemplate.cs
- ZipIOFileItemStream.cs
- HttpContext.cs
- XamlReader.cs
- WebControl.cs
- BindingSource.cs
- Rfc2898DeriveBytes.cs
- NavigationExpr.cs
- CreateUserWizardDesigner.cs
- WebPartConnectionsEventArgs.cs
- BindingOperations.cs
- DataSourceSelectArguments.cs
- DescendentsWalker.cs
- WaitingCursor.cs
- PrivilegeNotHeldException.cs
- ClientScriptManager.cs
- GroupQuery.cs
- OptimizedTemplateContentHelper.cs
- DashStyle.cs
- ResourceDescriptionAttribute.cs
- RealizationContext.cs
- BrushConverter.cs
- HtmlEmptyTagControlBuilder.cs
- CultureMapper.cs
- HandlerMappingMemo.cs
- CompoundFileIOPermission.cs
- PriorityBinding.cs
- StateChangeEvent.cs
- PopupRootAutomationPeer.cs
- WebHostUnsafeNativeMethods.cs
- ContextMenuStrip.cs
- RequestBringIntoViewEventArgs.cs
- TrackingQuery.cs
- DataTrigger.cs
- CryptoHelper.cs
- ColorAnimationBase.cs
- __Filters.cs
- AuthenticationModuleElement.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- ChildChangedEventArgs.cs
- Task.cs
- DebugView.cs
- SHA384.cs
- FieldNameLookup.cs
- Rectangle.cs
- BuildManagerHost.cs
- EntityDescriptor.cs
- SystemThemeKey.cs
- SmiSettersStream.cs
- Package.cs
- ScrollBarAutomationPeer.cs
- BaseCAMarshaler.cs
- ScrollItemProviderWrapper.cs
- ReturnType.cs
- ControlBuilder.cs
- MessageSecurityOverTcpElement.cs
- KoreanLunisolarCalendar.cs
- UpdateTranslator.cs
- MapPathBasedVirtualPathProvider.cs
- XmlNotation.cs
- SrgsSubset.cs
- TableLayoutPanel.cs
- SqlCacheDependency.cs
- AsyncSerializedWorker.cs
- X509CertificateInitiatorClientCredential.cs
- DetailsViewDeletedEventArgs.cs
- OdbcDataAdapter.cs
- PersonalizationStateInfo.cs
- PersonalizationEntry.cs
- DataGridHelper.cs
- X509Chain.cs
- RayHitTestParameters.cs
- HttpGetProtocolReflector.cs
- CapabilitiesUse.cs
- DllNotFoundException.cs
- XmlQueryOutput.cs
- EntryWrittenEventArgs.cs
- CorruptingExceptionCommon.cs
- FixedPageProcessor.cs
- AssociationSetEnd.cs
- SocketInformation.cs
- ControlParameter.cs
- SecurityState.cs