Пример #1
0
        public async override Task AddNugetPackages()
        {
            await this.Context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, "Adding Nuget Packages");

            var wcfDSInstallLocation = CodeGeneratorUtils.GetWCFDSInstallLocation();
            var packageSource        = Path.Combine(wcfDSInstallLocation, @"bin\NuGet");

            if (Directory.Exists(packageSource))
            {
                var files = Directory.EnumerateFiles(packageSource, "*.nupkg").ToList();
                foreach (var nugetPackage in Common.Constants.V3NuGetPackages)
                {
                    if (!files.Any(f => Regex.IsMatch(f, nugetPackage + @"(.\d){2,4}.nupkg")))
                    {
                        packageSource = Common.Constants.NuGetOnlineRepository;
                    }
                }
            }
            else
            {
                packageSource = Common.Constants.NuGetOnlineRepository;
            }

            if (!PackageInstallerServices.IsPackageInstalled(this.Project, this.ClientNuGetPackageName))
            {
                Version packageVersion = null;
                PackageInstaller.InstallPackage(Common.Constants.NuGetOnlineRepository, this.Project, this.ClientNuGetPackageName, packageVersion, false);
            }
        }
Пример #2
0
        private async Task AddNuGetPackagesAsync(ConnectedServiceHandlerContext context, Project currentProject, Version version)
        {
            await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, "Adding Nuget Packages");

            Version packageVersion = null;

            if (version.Major.Equals(3))
            {
                var wcfDSInstallLocation = CodeGeneratorUtils.GetWCFDSInstallLocation();

                var packageSource = Path.Combine(wcfDSInstallLocation, @"bin\NuGet");
                if (Directory.Exists(packageSource))
                {
                    var files = Directory.EnumerateFiles(packageSource, "*.nupkg").ToList();
                    foreach (var nugetPackage in Common.Constants.V3NuGetPackages)
                    {
                        if (!files.Any(f => Regex.IsMatch(f, nugetPackage + @"(.\d){2,4}.nupkg")))
                        {
                            packageSource = Common.Constants.NuGetOnlineRepository;
                        }
                    }
                }
                else
                {
                    packageSource = Common.Constants.NuGetOnlineRepository;
                }

                if (!PackageInstallerServices.IsPackageInstalled(currentProject, Common.Constants.V3ClientNuGetPackage))
                {
                    PackageInstaller.InstallPackage(packageSource, currentProject, Common.Constants.V3ClientNuGetPackage, packageVersion, false);
                }
            }
        }
Пример #3
0
        public void ConditionalText_True_OnlyTrue()
        {
            string text = new StringBuilder()
                          .AppendLine("#$TAG")
                          .AppendLine("True")
                          .AppendLine("$#TAG")
                          .AppendLine("Other part").ToString();

            var afterText = CodeGeneratorUtils.ConditionalText(true, "TAG", text);

            Assert.IsTrue(afterText.Contains("True"));
            Assert.IsTrue(afterText.Contains("Other part"));
            Assert.IsFalse(afterText.Contains("False"));
        }
Пример #4
0
        public ClassField(string name, ClassType type, bool hasDefaultValue = false, object defaultValue = null)
        {
            this.Name          = name;
            this.CamelCaseName = CodeGeneratorUtils.ToCamelCase(name);

            this.SafeCamelCaseName = this.CamelCaseName;

            if (CodeGeneratorUtils.CSharpKeywords.Contains(this.CamelCaseName))
            {
                this.SafeCamelCaseName = "@" + this.SafeCamelCaseName;
            }
            this.Type = type;

            this.HasDefaultValue = hasDefaultValue;
            this.DefaultValue    = defaultValue;
        }
Пример #5
0
        public void ConditionalText_Flase_InvalidName()
        {
            string text = new StringBuilder()
                          .AppendLine("#$TAG")
                          .AppendLine("True")
                          .AppendLine("$#TAG")
                          .AppendLine("#$!TAG")
                          .AppendLine("False")
                          .AppendLine("$#!TAG")
                          .AppendLine("Other part").ToString();

            var afterText = CodeGeneratorUtils.ConditionalText(false, "tag", text);

            Assert.IsTrue(afterText.Contains("True"));
            Assert.IsTrue(afterText.Contains("Other part"));
            Assert.IsTrue(afterText.Contains("False"));
            Assert.IsTrue(afterText.Contains("#$TAG"));
            Assert.IsTrue(afterText.Contains("#$!TAG"));
        }
Пример #6
0
        private async Task GenerateClientCode(ConnectedServiceHandlerContext context, Project project)
        {
            await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, "Generating Client Proxy ...");

            ODataConnectedServiceInstance codeGenInstance = (ODataConnectedServiceInstance)context.ServiceInstance;

            string command = Path.Combine(CodeGeneratorUtils.GetWCFDSInstallLocation(), @"bin\tools\DataSvcUtil.exe");

            string referenceFolderPath = GetReferenceFolderName(context, project);
            string outputFile          = Path.Combine(referenceFolderPath, "Reference.cs");

            StringBuilder arguments = new StringBuilder(string.Format("/c \"\"{0}\" /version:3.0 /language:{1} /out:\"{2}\" /uri:{3}", command, "CSharp", outputFile, codeGenInstance.Endpoint));

            if (codeGenInstance.UseDataServiceCollection)
            {
                arguments.Append("/dataServiceCollection");
            }

            arguments.Append("\"");

            ProcessHelper.ExecuteCommand(command, arguments.ToString());
            await context.HandlerHelper.AddFileAsync(outputFile, outputFile);
        }