Exemplo n.º 1
0
 /// <summary>
 /// Generate code by reading an EDMX schema from an XmlReader and outputting the code into a TextWriter
 /// </summary>
 /// <param name="sourceReader">Reader with a EDMX schema in it</param>
 /// <param name="targetWriter">Target writer for the generated code</param>
 /// <param name="namespacePrefix">Prefix to use for generated namespaces</param>
 /// <remarks>
 /// Note that the NamespacePrefix is used as the only namespace for types in the same namespace
 /// as the default container, and as a prefix for the server-provided namespace for everything else. If
 /// this argument is null, the server-provided namespaces are used for all types.
 /// </remarks>
 /// <returns></returns>
 public IList <EdmSchemaError> GenerateCode(XmlReader sourceReader, TextWriter targetWriter, string namespacePrefix)
 {
     EntityUtil.CheckArgumentNull(sourceReader, "sourceReader");
     EntityUtil.CheckArgumentNull(targetWriter, "targetWriter");
     using (LazyTextWriterCreator target = new LazyTextWriterCreator(targetWriter))
     {
         return(GenerateCode(sourceReader, target, namespacePrefix));
     }   // does not actually close the targetWriter - that is the caller's responsibility
 }
Exemplo n.º 2
0
 public IList <EdmSchemaError> GenerateCode(XmlReader sourceReader, string targetFilePath)
 {
     EntityUtil.CheckArgumentNull(sourceReader, "sourceReader");
     EntityUtil.CheckStringArgument(targetFilePath, "targetPath");
     using (LazyTextWriterCreator target = new LazyTextWriterCreator(targetFilePath))
     {
         // we do want to close the file
         return(GenerateCode(sourceReader, target, null));
     }
 }
Exemplo n.º 3
0
        private IList <EdmSchemaError> GenerateCode(XmlReader sourceReader, LazyTextWriterCreator target, string namespacePrefix)
        {
            List <XmlReader>      readers        = CreateReaders(sourceReader);
            List <EdmSchemaError> errors         = new List <EdmSchemaError>();
            EdmItemCollection     itemCollection = new EdmItemCollection(readers);

#if QFE_ENV
            _version = _versionExplicitlySet ? _version : GetDataServiceCodeVersionFromEnvironment();
            _useDataServiceCollection = _useDataServiceCollectionExplicitlySet ? _useDataServiceCollection : GetUseDataServiceCollectionFromEnvironment();
#endif
            if (_useDataServiceCollection && _version == DataServiceCodeVersion.V1)
            {
                throw new InvalidOperationException(Strings.VersionV1RequiresUseDataServiceCollectionFalse);
            }

            // generate code
            using (ClientApiGenerator generator = new ClientApiGenerator(null, itemCollection, this, errors, namespacePrefix))
            {
                generator.GenerateCode(target);
            }

            return(errors);
        }