Beispiel #1
0
        private IEnumerable <TextFile> MetadataToClientSource(string edmxString)
        {
            var model = OdcmReader.GenerateOdcmModel(new List <TextFile> {
                new TextFile("$metadata", edmxString)
            });

            ExportOcdmModel(model);

            return(OdcmWriter.GenerateProxy(model));
        }
Beispiel #2
0
        public void Initialize()
        {
            string dir = Directory.GetCurrentDirectory();

            string     edmx   = File.ReadAllText(dir + $"{Path.DirectorySeparatorChar}Edmx{Path.DirectorySeparatorChar}Containment.xml");
            OdcmReader reader = new OdcmReader();

            model = reader.GenerateOdcmModel(new List <TextFile> {
                new TextFile("$metadata", edmx)
            });
        }
Beispiel #3
0
        public void Initialize()
        {
            string dir = Directory.GetCurrentDirectory();

            dir = dir.Replace("\\bin\\Debug", "");

            string     edmx   = File.ReadAllText(dir + "\\Edmx\\Containment.xml");
            OdcmReader reader = new OdcmReader();

            model = reader.GenerateOdcmModel(new List <TextFile> {
                new TextFile("$metadata", edmx)
            });
        }
        public void DeleteRestrictions_should_be_properly_parsed()
        {
            OdcmReader odata4Reader = new OdcmReader();
            OdcmModel  model        = odata4Reader.GenerateOdcmModel(GetOneNoteEdmModel());

            model.EntityContainer.Properties.Should().Contain(prop => prop.Name == "notebooks");

            var notebookProperty = model.EntityContainer.Properties.First(prop => prop.Name == "notebooks");

            var deleteRestriction = notebookProperty.Annotations.Should()
                                    .Contain(an => an.Name == "DeleteRestrictions" && an.Namespace == "Org.OData.Capabilities.V1").Which;

            var annotationValue = deleteRestriction.Value.Should().BeOfType <DeleteRestrictionsType>().Which;

            annotationValue.Deletable.Should().BeFalse();
            annotationValue.NonDeletableNavigationProperties.Should().HaveCount(2).And.Contain("sectionGroups").And.Contain("sections");
        }
        /// <summary>
        /// Generates code files from an edmx file.
        /// </summary>
        /// <param name="edmxString">The EDMX file as a string.</param>
        /// <param name="targetLanguage">Specifies the target language. Possible values are csharp, php, etc.</param>
        /// <returns></returns>
        static private IEnumerable <TextFile> MetadataToClientSource(string edmxString, string targetLanguage, IEnumerable <string> properties, string endpointVersion = "v1.0")
        {
            if (String.IsNullOrEmpty(edmxString))
            {
                throw new ArgumentNullException("edmxString", "The EDMX file string contains no content.");
            }

            var reader = new OdcmReader();
            var writer = new TemplateWriter(targetLanguage, properties, endpointVersion);

            writer.SetConfigurationProvider(new ConfigurationProvider());

            var model = reader.GenerateOdcmModel(new List <TextFile> {
                new TextFile("$metadata", edmxString)
            });

            return(writer.GenerateProxy(model));
        }