public Assembly GetProxy(OdcmModel model, IConfigurationProvider _configurationProvider = null, IEnumerable <string> internalsVisibleTo = null) { var writer = new CSharpWriter.CSharpWriter(model, _configurationProvider); var proxySource = writer.GenerateProxy(); if (internalsVisibleTo != null && internalsVisibleTo.Any()) { var internalsHeader = "using System.Runtime.CompilerServices;\n\n" + internalsVisibleTo .Select(s => string.Format("[assembly: InternalsVisibleTo(\"{0}\")]\n\n", s)) .Aggregate((a, i) => a + i); proxySource = internalsHeader + proxySource; } Debug.WriteLine(proxySource); var referencedAssemblies = new List <string> { typeof(Microsoft.OData.Client.BaseEntityType).Assembly.Location, typeof(Microsoft.OData.Edm.EdmConcurrencyMode).Assembly.Location, typeof(Microsoft.OData.ProxyExtensions.LowerCasePropertyAttribute).Assembly.Location, "System.Core.dll", "System.Xml.dll", "System.Runtime.dll", "System.Linq.Expressions.dll", "System.Threading.Tasks.dll", "System.IO.dll" }; return(CompileText(referencedAssemblies, proxySource)); }
private static string ODataToString <T>(string edmxString) where T : IReader, new() { var edmx = XElement.Parse(edmxString); var reader = new T(); var model = reader.GenerateOdcmModel(new Dictionary <string, string>() { { "$metadata", edmxString } }); var writer = new CSharpWriter.CSharpWriter(model, null); return(writer.GenerateProxy()); }