Ejemplo n.º 1
0
 static void RunProjectTasks(ProjectOptions opts)
 {
     if (opts.Get)
     {
         var result =
             projectApi.getProjects(Email.From(opts.Username), Password.From(opts.Password), resetEvent);
         CliPresenter.present(result.Result);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// General verifier for codefixes.
        /// Creates a Document from the source string, then gets diagnostics on it and applies the relevant codefixes.
        /// Then gets the string after the codefix is applied and compares it with the expected result.
        /// Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true.
        /// </summary>
        /// <param name="language">The language the source code is in</param>
        /// <param name="analyzer">The analyzer to be applied to the source code</param>
        /// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found</param>
        /// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
        /// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
        /// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
        /// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
        /// <param name="projectOptions"></param>
        private void VerifyFix(string language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider,
                               string oldSource, string newSource, int?codeFixIndex, bool allowNewCompilerDiagnostics,
                               ProjectOptions projectOptions)
        {
            var document            = CreateDocument(oldSource, language);
            var analyzerDiagnostics = GetSortedDiagnosticsFromDocuments(analyzer, new[] { document }, projectOptions);
            var compilerDiagnostics = GetCompilerDiagnostics(document);
            var attempts            = analyzerDiagnostics.Length;

            for (int i = 0; i < attempts; ++i)
            {
                var actions = new List <CodeAction>();
                var context = new CodeFixContext(document, analyzerDiagnostics[0], (a, d) => actions.Add(a), CancellationToken.None);
                codeFixProvider.RegisterCodeFixesAsync(context).Wait();

                if (!actions.Any())
                {
                    break;
                }

                if (codeFixIndex != null)
                {
                    document = ApplyFix(document, actions.ElementAt((int)codeFixIndex));
                    break;
                }

                document            = ApplyFix(document, actions.ElementAt(0));
                analyzerDiagnostics = GetSortedDiagnosticsFromDocuments(analyzer, new[] { document }, projectOptions);

                var newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));

                //check if applying the code fix introduced any new compiler diagnostics
                if (!allowNewCompilerDiagnostics && newCompilerDiagnostics.Any())
                {
                    // Format and get the compiler diagnostics again so that the locations make sense in the output
                    document = document.WithSyntaxRoot(Formatter.Format(document.GetSyntaxRootAsync().GetAwaiter().GetResult(), Formatter.Annotation, document.Project.Solution.Workspace));
                    newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));

                    Assert.IsTrue(false,
                                  string.Format("Fix introduced new compiler diagnostics:\r\n{0}\r\n\r\nNew document:\r\n{1}\r\n",
                                                string.Join("\r\n", newCompilerDiagnostics.Select(d => d.ToString())),
                                                document.GetSyntaxRootAsync().GetAwaiter().GetResult().ToFullString()));
                }

                //check if there are analyzer diagnostics left after the code fix
                if (!analyzerDiagnostics.Any())
                {
                    break;
                }
            }

            //after applying all of the code fixes, compare the resulting string to the inputted one
            var actual = GetStringFromDocument(document);

            Assert.AreEqual(newSource, actual);
        }
Ejemplo n.º 3
0
        private Project CreateProject(string projectPath, ProjectOptions projectOptions)
        {
            ProjectRootElement projectRootElement = ProjectRootElement.Open(projectPath, _projectCollection);

            projectOptions.ProjectCollection = _projectCollection;

            var project = Project.FromProjectRootElement(projectRootElement, projectOptions);

            return(project);
        }
        /// <summary>
        /// Adds a JWT (JSON web token) authentication to the web API project.
        /// </summary>
        /// <param name="key">The security key that was used to generated the JWT token.</param>
        /// <param name="issuer">The issuer that was used to generate the JWT token.</param>
        /// <param name="audience">The audience that was used to generate the JWT token.</param>
        public WebApiProjectOptions WithJwtAuthentication(string key, string issuer, string audience)
        {
            Guard.NotNullOrWhitespace(key, nameof(key), "Cannot add JWT authentication authentication option without a security key to validate the JWT token");

            ProjectOptions optionsWithJwtAuthentication = AddOption(
                "--authentication JWT",
                (fixtureDirectory, projectDirectory) => ConfigureJwtAuthentication(fixtureDirectory, projectDirectory, key, issuer, audience));

            return(new WebApiProjectOptions(optionsWithJwtAuthentication));
        }
        /// <summary>
        /// Adds a certificate authentication on the issuer name to the web API project.
        /// </summary>
        /// <param name="subject">The subject name of the certificate that is allowed by the web API project.</param>
        public WebApiProjectOptions WithCertificateSubjectAuthentication(string subject)
        {
            Guard.NotNullOrWhitespace(subject, nameof(subject), "Cannot add certificate authentication project option based on subject without a subject value");

            ProjectOptions optionsWithCertificateAuthentication = AddOption(
                "--authentication Certificate",
                (fixtureDirectory, projectDirectory) => ConfigureCertificateSubjectAuthentication(projectDirectory, subject));

            return(new WebApiProjectOptions(optionsWithCertificateAuthentication));
        }
        private static AnalyzerOptions GetAnalyzerOptions(ProjectOptions projectOptions)
        {
            if (projectOptions == null)
            {
                return(null);
            }


            return(new AnalyzerOptions(projectOptions.AdditionalDocuments.Select(c => new AnalyzerAdditionalFile(c.Name, c.Content)).Cast <AdditionalText>().ToImmutableArray()));
        }
Ejemplo n.º 7
0
        private static Microsoft.Build.Evaluation.Project GetEvaluationProject(string projectFilePath)
        {
            // resolves relative paths
            projectFilePath = new Uri(projectFilePath, UriKind.Absolute).LocalPath;

            var matchingProject = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.LoadedProjects.FirstOrDefault(d => string.Equals(d.FullPath, projectFilePath, StringComparison.OrdinalIgnoreCase));

            var projectOptions = new ProjectOptions();

            return(matchingProject ?? Microsoft.Build.Evaluation.Project.FromFile(projectFilePath, projectOptions));
        }
Ejemplo n.º 8
0
        protected Result <string> GetProject(ProjectOptions options, string defaultProject)
        {
            string projectName = !options.Project.IsNullOrEmpty() ?
                                 options.Project : defaultProject;

            return(projectName.IsNullOrEmpty() ?
                   Fail <string>(
                       "Project name is not provided and default is not set. " +
                       "You can set default project by running 'gitlab config --default-project {project}'") :
                   Ok(projectName));
        }
 public ProjectModel(Guid projectGuid, string projectName, string projectPath, bool isBsipaProject,
                     ProjectOptions projectOptions             = ProjectOptions.None, ProjectOptions userFileOptions = ProjectOptions.None,
                     ProjectCapabilities supportedCapabilities = ProjectCapabilities.None)
 {
     ProjectGuid           = projectGuid;
     ProjectName           = projectName;
     ProjectPath           = projectPath;
     IsBSIPAProject        = isBsipaProject;
     ProjectOptions        = projectOptions;
     UserFileOptions       = userFileOptions;
     SupportedCapabilities = supportedCapabilities;
 }
Ejemplo n.º 10
0
 private static void ValidateOptions(ProjectOptions options)
 {
     switch (options.NetRuntime)
     {
     case NetVersion.Net45:
         if (options.IDE != IDE.VS20131517)
         {
             throw new ArgumentException("Invalid Framework=>IDE settings");
         }
         break;
     }
 }
Ejemplo n.º 11
0
 public void Initialize(ProjectOptions options)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     SetSingleActiveBreakpointMode(options.DebuggerOptions.SingleActiveBreakpoint);
     options.DebuggerOptions.PropertyChanged += (s, e) =>
     {
         if (e.PropertyName == nameof(DebuggerOptions.SingleActiveBreakpoint))
         {
             SetSingleActiveBreakpointMode(options.DebuggerOptions.SingleActiveBreakpoint);
         }
     };
 }
Ejemplo n.º 12
0
        private static ProjectOptions ConvertToProjectOptions(ProjectOptionsUserControlViewModel projectOptionsVm)
        {
            var rval = new ProjectOptions
            {
                ProjectModel      = projectOptionsVm.ProjectModel,
                ViewModelSuffix   = projectOptionsVm.ViewModelSuffix,
                ViewLocation      = projectOptionsVm.LocationDescriptorForView.GetDescriptor(),
                ViewModelLocation = projectOptionsVm.LocationDescriptorForViewModel.GetDescriptor()
            };

            return(rval);
        }
        /// <summary>
        /// Adds a shared access key authentication to the web API project.
        /// </summary>
        /// <param name="headerName">The name of the request header which value must match the stored secret.</param>
        /// <param name="secretName">The name of the secret that's being retrieved using the <see cref="ISecretProvider.Get"/> call.</param>
        /// <param name="secretValue">The value of the secret that should be retrieved using the <see cref="ISecretProvider.Get"/> call.</param>
        public WebApiProjectOptions WithSharedAccessAuthentication(string headerName, string secretName, string secretValue)
        {
            Guard.NotNullOrWhitespace(headerName, nameof(headerName), "Cannot add shared access key authentication project option without a HTTP request header name containing the secret name");
            Guard.NotNullOrWhitespace(secretName, nameof(secretName), "Cannot add shared access key authentication project option without a secret name");
            Guard.NotNullOrWhitespace(secretValue, nameof(secretValue), "Cannot add shared access key authentication project option without a secret value");

            ProjectOptions optionsWithSharedAccessAuthentication = AddOption(
                "--authentication SharedAccessKey",
                (fixtureDirectory, projectDirectory) => ConfigureSharedAccessAuthentication(fixtureDirectory, projectDirectory, headerName, secretName, secretValue));

            return(new WebApiProjectOptions(optionsWithSharedAccessAuthentication));
        }
Ejemplo n.º 14
0
        public CodeGeneratorService(IOptions <ProjectOptions> options, IHostingEnvironment env)
        {
            //_vowels = "A,AI,AU,E,EA,EE,I,IA,IO,O,OA,OI,OO,OU,U".Split(',');
            //_consonants = "B,C,CH,CL,D,F,FF,G,GH,GL,J,K,L,LL,M,MN,N,P,PH,PS,R,RH,S,SC,SH,SK,ST,T,TH,V,W,X,Y,Z"
            //    .Split(',');

            _vowels     = "A,E,I,O,U".Split(',');
            _consonants = "B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y,Z".Split(',');

            _random  = new Random();
            _options = options.Value;
            _env     = env;
        }
        public IEnumerable <ProjectDescriptor> GetProjects(ProjectOptions options, bool includeMiscProjectsAndSolutionFolders = false)
        {
            Dispatcher.CurrentDispatcher.VerifyAccess();

            IEnumHierarchies ppEnum;
            Guid             tempGuid = Guid.Empty;

            ErrorHandler.ThrowOnFailure(m_solution.GetProjectEnum((uint)options, ref tempGuid, out ppEnum));


            if (ppEnum != null)
            {
                uint           actualResult = 0;
                IVsHierarchy[] nodes        = new IVsHierarchy[1];
                while (0 == ppEnum.Next(1, nodes, out actualResult))
                {
                    Guid   projectId;
                    object projectName;
                    ErrorHandler.ThrowOnFailure(nodes[0].GetGuidProperty((uint)Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out projectId));
                    ErrorHandler.ThrowOnFailure(nodes[0].GetProperty((uint)Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ProjectName, out projectName));

                    Guid projectTypeId;
                    Guid projectKind = Guid.Empty;

                    if (ErrorHandler.Succeeded(nodes[0].GetGuidProperty(Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_TypeGuid, out projectTypeId)))
                    {
                        object pVar;
                        if (ErrorHandler.Succeeded(nodes[0].GetProperty(Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out pVar)))
                        {
                            Project project = pVar as Project;
                            if (project != null)
                            {
                                Guid.TryParse(project.Kind, out projectKind);
                            }
                        }
                    }

                    // Solution Folder: {66A26720-8FB5-11D2-AA7E-00C04F688DDE}
                    // If the project is actually a solution folder and we have elected to skip those, then skip it.
                    if (!includeMiscProjectsAndSolutionFolders)
                    {
                        if (projectKind == Guid.Parse(EnvDTE.Constants.vsProjectKindSolutionItems) ||
                            projectKind == Guid.Parse(EnvDTE.Constants.vsProjectKindMisc))
                        {
                            continue;
                        }
                    }
                    yield return(new ProjectDescriptor(projectId, (string)projectName, projectKind));
                }
            }
        }
        public Project UpdateProject(ProjectOptions projectOptions, int projectId)
        {
            var project = dbContext.Projects.Find(projectId);

            project.Title         = projectOptions.Title;
            project.Description   = projectOptions.Description;
            project.Category      = projectOptions.Category;
            project.Goal          = projectOptions.Goal;
            project.CurrentAmount = projectOptions.CurrentAmount;
            project.EndDate       = projectOptions.EndDate;
            project.PicturePath   = projectOptions.PicturePath;
            dbContext.SaveChanges();
            return(project);
        }
Ejemplo n.º 17
0
        public static ProjectInstance CreateProjectInstanceFromRootElement(ProjectRootElement projectRootElement)
        {
            // Use a new project collection to avoid collisions in the global one.
            // TODO! Refactor tests to be more isolated, both ProjectCollection-wide and disk-wise
            var projectCollection = new ProjectCollection();

            var projectOptions = new ProjectOptions
            {
                GlobalProperties  = _globalProperties,
                ProjectCollection = projectCollection,
            };

            return(ProjectInstance.FromProjectRootElement(projectRootElement, projectOptions));
        }
Ejemplo n.º 18
0
 internal Converter(ProjectOptions options)
 {
     _options  = options;
     _tempGuid = Guid.NewGuid();
     _tempPath = Path.Combine(Path.GetTempPath(), _tempGuid.ToString());
     Directory.CreateDirectory(_tempPath);
     Directory.CreateDirectory(TempSolutionPath);
     Directory.CreateDirectory(TempProjectPath);
     Directory.CreateDirectory(TempPropertiesPath);
     Directory.CreateDirectory(TempNetOfficePath);
     Environments    = new EnvironmentVersions();
     SolutionFormats = new SolutionFormatVersions();
     Tools           = new ToolsVersions();
     Runtimes        = new RuntimeVersions();
 }
Ejemplo n.º 19
0
 internal Converter(ProjectOptions options)
 {
     _options = options;
     _tempGuid = Guid.NewGuid();
     _tempPath = Path.Combine(Path.GetTempPath(), _tempGuid.ToString());
     Directory.CreateDirectory(_tempPath);
     Directory.CreateDirectory(TempSolutionPath);
     Directory.CreateDirectory(TempProjectPath);
     Directory.CreateDirectory(TempPropertiesPath);
     Directory.CreateDirectory(TempNetOfficePath);
     Environments = new EnvironmentVersions();
     SolutionFormats = new SolutionFormatVersions();
     Tools = new ToolsVersions();
     Runtimes = new RuntimeVersions();
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ICodeGeneratorService codeGenerator, ICodeAccessService accessService, IOptions <ProjectOptions> options)
        {
            _codeGenerator = codeGenerator;
            _accessService = accessService;
            _options       = options.Value;

            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Use(async(context, next) =>
            {
                if (!_accessService.IsGeneratedCodeExists())
                {
                    var codes = _codeGenerator.GenerateMany(_options.CodesCount);
                    _accessService.Write(codes);
                }
                await next.Invoke();
            });

            //app.UseCodeGeneratorMiddleware();

            //app.UseMvc();

            app.Run(async(context) =>
            {
                string path = context.Request.Path;
                if (path.Contains("/api/code/"))
                {
                    int id;
                    if (int.TryParse(path.Substring(path.LastIndexOf('/') + 1), out id))
                    {
                        await context.Response.WriteAsync(_accessService.Get(id));
                    }
                }
                else
                {
                    await context.Response.WriteAsync("Error");
                }
            });
            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hey hey/!");
            //});
        }
Ejemplo n.º 21
0
        public override void Configure(CommandLineApplication command)
        {
            var options = new ProjectOptions();

            options.Configure(command);

            _configuration         = options.Configuration;
            _project               = options.Project;
            _projectExtensionsPath = options.ProjectExtensionsPath;
            _runtime               = options.Runtime;
            _targetFramework       = options.TargetFramework;

            _output = command.Option("--output <Path>", Resources.OutputDescription);
            command.VersionOption("--version", ProductInfo.GetVersion);
            _args = command.RemainingArguments;

            base.Configure(command);
        }
        public void DimensionClippingTest()
        {
            var options = new ProjectOptions();

            options.VisualizerOptions.NDRange3D = true;
            var selector = new GroupIndexSelector(options);

            var changedPropertyName = "";

            selector.PropertyChanged += (s, e) => changedPropertyName = e.PropertyName;

            selector.DimX = 2;
            Assert.Equal(nameof(selector.DimX), changedPropertyName);

            selector.X = 3;
            Assert.Equal(nameof(selector.X), changedPropertyName);
            Assert.Equal <uint>(1, selector.X); // clipped to DimX - 1
        }
        /// <summary>
        /// Given an array of strings as sources and a language, turn them into a project and return the documents and spans of it.
        /// </summary>
        /// <param name="sources">Classes in the form of strings</param>
        /// <param name="language">The language the source code is in</param>
        /// <param name="projectOptions">Additional project options.</param>
        /// <returns>A Tuple containing the Documents produced from the sources and their TextSpans if relevant</returns>
        private static Document[] GetDocuments(string[] sources, string language, ProjectOptions projectOptions = null)
        {
            if (language != LanguageNames.CSharp && language != LanguageNames.VisualBasic)
            {
                throw new ArgumentException("Unsupported Language");
            }

            var project = CreateProject(sources, language, projectOptions);

            var documents = project.Documents.ToArray();

            if (sources.Length != documents.Length)
            {
                throw new InvalidOperationException("Amount of sources did not match amount of Documents created");
            }

            return(documents);
        }
        public void SaveProjectOptionsToSettingsFile(ProjectOptions projectOptions)
        {
            try
            {
                const string header =
                    "# This is a settings file generated by the MVVM Tools Visual Studio extension.  A\r\n" +
                    "# similar file is generated and stored alongside your solution file and each project\r\n" +
                    "# file.\r\n" +
                    "# \r\n" +
                    "# Please DO NOT modify this file directly.  Instead, open a solution and open\r\n" +
                    "# Tools => Options => MVVM Tools, where all these MVVM settings files are manipulated.\r\n" +
                    "# \r\n" +
                    "# The MVVM Tools extension is available via\r\n" +
                    "# Tools => Extensions and Updates, or at\r\n" +
                    "# https://visualstudiogallery.msdn.microsoft.com/978ed555-9f0d-44a2-884c-9084844ac469\r\n" +
                    "# The source is available on GitHub at https://github.com/cbordeman/Mvvm-Tools/issues  if\r\n" +
                    "# you'd like to contribute!\r\n" +
                    "# \r\n" +
                    "# Enjoy!\r\n" +
                    "\r\n";

                var text = header + JsonConvert.SerializeObject(projectOptions, Formatting.Indented);

                // Read original text so we don't overwrite an unchanged file.
                bool textMatches = false;
                if (File.Exists(projectOptions.ProjectModel.SettingsFile))
                {
                    var existingText = File.ReadAllText(projectOptions.ProjectModel.SettingsFile);
                    if (text == existingText)
                    {
                        textMatches = true;
                    }
                }
                if (!textMatches)
                {
                    File.WriteAllText(projectOptions.ProjectModel.SettingsFile, text);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"Couldn't save {projectOptions.ProjectModel?.SettingsFile}.  Error: {ex.Message}");
                throw;
            }
        }
Ejemplo n.º 25
0
        private void CommandBinding_SettingsCmdExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            ProjectOptions opt = MogitorsRoot.Instance.ProjectOptions;
            SettingsDialog dlg = new SettingsDialog(opt);

            List <string> directories = new List <string>();

            opt.ResourceDirectories.ForEach(s => directories.Add(s));

            if (dlg.ShowDialog() == true)
            {
                bool identical = true;
                if (directories.Count == opt.ResourceDirectories.Count)
                {
                    foreach (string orgStr in directories)
                    {
                        bool found = false;
                        foreach (string newStr in opt.ResourceDirectories)
                        {
                            if (orgStr == newStr)
                            {
                                found = true;
                            }
                        }
                        if (!found)
                        {
                            identical = false;
                            break;
                        }
                    }
                }
                else
                {
                    identical = false;
                }

                if (!identical)
                {
                    ogreControl.ReloadUserResources();
                }
            }
        }
Ejemplo n.º 26
0
        public override void SetTargetPlatform(ProjectOptions options)
        {
            if (this.LastModifiedTime == this.lastModifiedTimeOfPlatform)
            {
                return;
            }
            //TODO: what about referenced projects with different target platforms? This should probably be a mistake and should generate an error.
            this.lastModifiedTimeOfPlatform = this.LastModifiedTime;
            //TODO: handle errors caused by bad path names and/or missing platform assemblies
            switch (options.TargetPlatform)
            {
            case PlatformType.v1: Microsoft.SpecSharp.TargetPlatform.SetToV1(options.TargetPlatformLocation); break;

            case PlatformType.v11: Microsoft.SpecSharp.TargetPlatform.SetToV1_1(options.TargetPlatformLocation); break;

            case PlatformType.v2: Microsoft.SpecSharp.TargetPlatform.SetToV2(options.TargetPlatformLocation); break;

            case PlatformType.cli1: Microsoft.SpecSharp.TargetPlatform.SetToPostV1_1(options.TargetPlatformLocation); break;
            }
        }
Ejemplo n.º 27
0
        public static Project LoadProject(string projectPath, string configuration = null, string platform = null)
        {
            var popt = new ProjectOptions();

            if (configuration != null || platform != null)
            {
                popt.GlobalProperties = popt.GlobalProperties ?? new Dictionary <string, string>();
                if (configuration != null)
                {
                    popt.GlobalProperties["Configuration"] = configuration;
                }
                if (platform != null)
                {
                    popt.GlobalProperties["Platform"] = platform;
                }
            }
            var collection = new ProjectCollection(popt.GlobalProperties);

            return(collection.LoadProject(projectPath));
        }
Ejemplo n.º 28
0
        public ProjectOptions CreateProject([FromForm] ProjectOptions projectOpts)
        {
            //if (projectWithPictureModel == null) return null;
            //var formFile = projectWithPictureModel.Photo;
            //var filename = projectWithPictureModel.Photo.FileName;
            //if (formFile.Length > 0)
            //{
            //    var filePath = Path.Combine(hostingEnvironment.WebRootPath, "uploadedimages", filename);
            //    using (var stream = System.IO.File.Create(filePath))
            //    {
            //        formFile.CopyTo(stream);
            //    }
            //}
            //var formFile2 = projectWithPictureModel.Video;
            //var filename2 = projectWithPictureModel.Video.FileName;
            //if (formFile2.Length > 0)
            //{
            //    var filePath2 = Path.Combine(hostingEnvironment.WebRootPath, "uploadedvideos", filename2);
            //    using (var stream = System.IO.File.Create(filePath2))
            //    {
            //        formFile2.CopyTo(stream);
            //    }
            //}


            ProjectOptions projectoptions = new ProjectOptions
            {
                Category    = projectOpts.Category,
                CreatorId   = projectOpts.CreatorId,
                CurrentFund = projectOpts.CurrentFund,
                Description = projectOpts.Description,
                Goal        = projectOpts.Goal,
                Status      = projectOpts.Status,
                TimesFunded = projectOpts.TimesFunded,
                Title       = projectOpts.Title,
                Photo       = projectOpts.Photo,
                Video       = projectOpts.Video
            };

            return(projectService.CreateProject(projectoptions));
        }
        public ProjectOptions GetProjectOptionsFromSettingsFile(ProjectModel projectModel, ProjectOptions inheritedProjectOptions)
        {
            if (!File.Exists(projectModel.SettingsFile))
            {
                var po = new ProjectOptions {
                    ProjectModel = projectModel
                };
                po.ApplyInherited(inheritedProjectOptions);
                return(po);
            }

            try
            {
                var text = File.ReadAllText(projectModel.SettingsFile);

                // Find first empty line.
                var startPosition = text.IndexOf("\r\n\r\n", StringComparison.OrdinalIgnoreCase);
                if (startPosition == -1)
                {
                    return(null);
                }

                var json = text.Substring(startPosition + 4);

                var projectOptions = JsonConvert.DeserializeObject <ProjectOptions>(json);
                // .ProjectModel is excluded from serialization so we set it now.
                projectOptions.ProjectModel = projectModel;

                return(projectOptions);
            }
            catch (Exception ex)
            {
                // Can't read or deserialize the file for any reason.
                Trace.WriteLine($"Couldn't read file {projectModel.SettingsFile}.  Error: {ex.Message}");
                var po = new ProjectOptions {
                    ProjectModel = projectModel
                };
                po.ApplyInherited(inheritedProjectOptions);
                return(po);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates a new project under the authenticated account. Makes both a POST and a GET request to the Projects resource.
        /// </summary>
        /// <param name="name">The project name</param>
        /// <param name="clientId">The client to whom the project belongs</param>
        /// <param name="active">The status of the project</param>
        /// <param name="billBy">The invoicing method for the project</param>
        /// <param name="code">The project code</param>
        /// <param name="notes">Notes about the project</param>
        /// <param name="budgetBy">The budgeting method for the project</param>
        /// <param name="budget">The budget of the project</param>
        public Project CreateProject(string name, long clientId, bool active = true, BillingMethod billBy = BillingMethod.None, string code = null, string notes = null, BudgetMethod budgetBy = BudgetMethod.None, decimal?budget = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var options = new ProjectOptions()
            {
                ClientId = clientId,
                Name     = name,
                Code     = code,
                Active   = active,
                BillBy   = billBy,
                Notes    = notes,
                BudgetBy = budgetBy,
                Budget   = budget
            };

            return(CreateProject(options));
        }
Ejemplo n.º 31
0
        private static ProjectOptions GetCreateProjectOptions(string name, long clientId, bool active, BillingMethod billBy, string code, string notes, BudgetMethod budgetBy, decimal?budget)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var options = new ProjectOptions
            {
                ClientId = clientId,
                Name     = name,
                Code     = code,
                Active   = active,
                BillBy   = billBy,
                Notes    = notes,
                BudgetBy = budgetBy,
                Budget   = budget
            };

            return(options);
        }
 internal ToolsSingleAddinConverterVB(ProjectOptions options)
     : base(options)
 {
 }
Ejemplo n.º 33
0
		/// <summary>
		/// Set dirty state of project
		/// </summary>
		/// <param name="value">boolean value indicating dirty state</param>
		public void SetProjectFileDirty(bool value)
		{
			this.options = null;
			this.isDirty = value;
			if(this.isDirty)
			{
				this.lastModifiedTime = DateTime.Now;
				this.buildIsPrepared = false;
			}
		}
Ejemplo n.º 34
0
		/// <summary>
		/// Set configuration properties for a specific configuration
		/// </summary>
		/// <param name="config">configuration name</param>
		protected virtual void SetBuildConfigurationProperties(string config)
		{
			ProjectOptions options = null;

			if(!String.IsNullOrEmpty(config))
			{
				options = this.GetProjectOptions(config);
			}

			if(options != null && this.buildProject != null)
			{
				// Make sure the project configuration is set properly
				this.SetConfiguration(config);
			}
		}
Ejemplo n.º 35
0
		public virtual void SetTargetPlatform(ProjectOptions options)
		{
		}
Ejemplo n.º 36
0
 /// <summary>
 /// Create a Converter instance depending on project options
 /// </summary>
 /// <param name="options">conversion options</param>
 /// <returns></returns>
 public static Converter CreateConverter(ProjectOptions options)
 {
     ValidateOptions(options);
     switch (options.ProjectType)
     {
         case ProjectType.SimpleAddin:
             {
                 switch (options.Language)
                 {
                     case ProgrammingLanguage.CSharp:
                         if(options.OfficeApps.Length > 1)
                             return new SimpleMultiAddinConverterCS(options);
                         else
                             return new SimpleSingleAddinConverterCS(options);
                     case ProgrammingLanguage.VB:
                         if (options.OfficeApps.Length > 1)
                             return new SimpleMultiAddinConverterVB(options);
                         else
                             return new SimpleSingleAddinConverterVB(options);
                     default:
                         throw new ArgumentOutOfRangeException("language");
                 }
             }
         case ProjectType.NetOfficeAddin:
             {
                 switch (options.Language)
                 {
                     case ProgrammingLanguage.CSharp:
                         if (options.OfficeApps.Length > 1)
                             return new ToolsMultiAddinConverterCS(options);
                         else
                             return new ToolsSingleAddinConverterCS(options);
                     case ProgrammingLanguage.VB:
                         if (options.OfficeApps.Length > 1)
                             return new ToolsMultiAddinConverterVB(options);
                         else
                             return new ToolsSingleAddinConverterVB(options);
                     default:
                         throw new ArgumentOutOfRangeException("language");
                 }
             }
         case ProjectType.WindowsForms:
             {
                 switch (options.Language)
                 {
                     case ProgrammingLanguage.CSharp:
                         return new WindowsFormsConverterCS(options);
                     case ProgrammingLanguage.VB:
                         return new WindowsFormsConverterVB(options);
                     default:
                         throw new ArgumentOutOfRangeException("language");
                 }
             }
         case ProjectType.ClassLibrary:
             {
                 switch (options.Language)
                 {
                     case ProgrammingLanguage.CSharp:
                         return new ClassLibraryConverterCS(options);
                     case ProgrammingLanguage.VB:
                         return new ClassLibraryConverterVB(options);
                     default:
                         throw new ArgumentOutOfRangeException("language");
                 }
             }
         case ProjectType.Console:
             {
                 switch (options.Language)
                 {
                     case ProgrammingLanguage.CSharp:
                         return new ConsoleConverterCS(options);
                     case ProgrammingLanguage.VB:
                         return new ConsoleConverterVB(options);
                     default:
                         throw new ArgumentOutOfRangeException("language");
                 }
             }
         default:
             throw new ArgumentOutOfRangeException("ProjectType");
     }
 }
Ejemplo n.º 37
0
 internal ClassLibraryConverterCS(ProjectOptions options)
     : base(options)
 {
 }
Ejemplo n.º 38
0
 private static void ValidateOptions(ProjectOptions options)
 {
     switch (options.NetRuntime)
     {
         case NetVersion.Net45:
             if (options.IDE != IDE.VS2013)
                 throw new ArgumentException("Invalid Framework=>IDE settings");
             break;
     }
 }
 internal SimpleSingleAddinConverterCS(ProjectOptions options)
     : base(options)
 {
 }
Ejemplo n.º 40
0
 internal WindowsFormsConverterVB(ProjectOptions options)
     : base(options)
 {
 }
 public Project AddProject(string projectName, Service service, IEnumerable<File> files, ProjectOptions options, IEnumerable<File> referenceFiles = null)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 42
0
 public DataSchemaProject()
 {
     InputFiles = new List<string>();
     Options = new ProjectOptions();
     Transformations = new List<Transformation>();
 }
Ejemplo n.º 43
0
 internal ConsoleConverterCS(ProjectOptions options)
     : base(options)
 {
 }
 internal ToolsMultiAddinConverterVB(ProjectOptions options)
     : base(options)
 {
 }
Ejemplo n.º 45
0
		public virtual ProjectOptions GetProjectOptions(string config)
		{
			if(this.options != null)
				return this.options;

			ProjectOptions options = this.options = CreateProjectOptions();

			if(config == null)
				return options;

			options.GenerateExecutable = true;

			this.SetConfiguration(config);

			string outputPath = this.GetOutputPath(this.currentConfig);
			if(!String.IsNullOrEmpty(outputPath))
			{
				// absolutize relative to project folder location
				outputPath = Path.Combine(this.ProjectFolder, outputPath);
			}

			// Set some default values
			options.OutputAssembly = outputPath + this.Caption + ".exe";
			options.ModuleKind = ModuleKindFlags.ConsoleApplication;

			options.RootNamespace = GetProjectProperty(ProjectFileConstants.RootNamespace, false);
			options.OutputAssembly = outputPath + this.GetAssemblyName(config);

			string outputtype = GetProjectProperty(ProjectFileConstants.OutputType, false);
			if(!string.IsNullOrEmpty(outputtype))
			{
				outputtype = outputtype.ToLower(CultureInfo.InvariantCulture);
			}

			if(outputtype == "library")
			{
				options.ModuleKind = ModuleKindFlags.DynamicallyLinkedLibrary;
				options.GenerateExecutable = false; // DLL's have no entry point.
			}
			else if(outputtype == "winexe")
				options.ModuleKind = ModuleKindFlags.WindowsApplication;
			else
				options.ModuleKind = ModuleKindFlags.ConsoleApplication;

			options.Win32Icon = GetProjectProperty("ApplicationIcon", false);
			options.MainClass = GetProjectProperty("StartupObject", false);

			string targetPlatform = GetProjectProperty("TargetPlatform", false);

			if(targetPlatform != null && targetPlatform.Length > 0)
			{
				try
				{
					options.TargetPlatform = (PlatformType)Enum.Parse(typeof(PlatformType), targetPlatform);
				}
				catch(ArgumentException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				options.TargetPlatformLocation = GetProjectProperty("TargetPlatformLocation", false);
				this.SetTargetPlatform(options);
			}

			//    other settings from CSharp we may want to adopt at some point...
			//    AssemblyKeyContainerName = ""  //This is the key file used to sign the interop assembly generated when importing a com object via add reference
			//    AssemblyOriginatorKeyFile = ""
			//    DelaySign = "false"
			//    DefaultClientScript = "JScript"
			//    DefaultHTMLPageLayout = "Grid"
			//    DefaultTargetSchema = "IE50"
			//    PreBuildEvent = ""
			//    PostBuildEvent = ""
			//    RunPostBuildEvent = "OnBuildSuccess"

			// transfer all config build options...
			if(GetBoolAttr(this.currentConfig, "AllowUnsafeBlocks"))
			{
				options.AllowUnsafeCode = true;
			}

			if(GetProjectProperty("BaseAddress", false) != null)
			{
				try
				{
					options.BaseAddress = Int64.Parse(GetProjectProperty("BaseAddress", false), CultureInfo.InvariantCulture);
				}
				catch(ArgumentNullException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(ArgumentException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(FormatException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(OverflowException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
			}

			if(GetBoolAttr(this.currentConfig, "CheckForOverflowUnderflow"))
			{
				options.CheckedArithmetic = true;
			}

			if(GetProjectProperty("DefineConstants", false) != null)
			{
				options.DefinedPreprocessorSymbols = new StringCollection();
				foreach(string s in GetProjectProperty("DefineConstants", false).Replace(" \t\r\n", "").Split(';'))
				{
					options.DefinedPreprocessorSymbols.Add(s);
				}
			}

			string docFile = GetProjectProperty("DocumentationFile", false);
			if(!String.IsNullOrEmpty(docFile))
			{
				options.XmlDocFileName = Path.Combine(this.ProjectFolder, docFile);
			}

			if(GetBoolAttr(this.currentConfig, "DebugSymbols"))
			{
				options.IncludeDebugInformation = true;
			}

			if(GetProjectProperty("FileAlignment", false) != null)
			{
				try
				{
					options.FileAlignment = Int32.Parse(GetProjectProperty("FileAlignment", false), CultureInfo.InvariantCulture);
				}
				catch(ArgumentNullException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(ArgumentException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(FormatException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(OverflowException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
			}

			if(GetBoolAttr(this.currentConfig, "IncrementalBuild"))
			{
				options.IncrementalCompile = true;
			}

			if(GetBoolAttr(this.currentConfig, "Optimize"))
			{
				options.Optimize = true;
			}

			if(GetBoolAttr(this.currentConfig, "RegisterForComInterop"))
			{
			}

			if(GetBoolAttr(this.currentConfig, "RemoveIntegerChecks"))
			{
			}

			if(GetBoolAttr(this.currentConfig, "TreatWarningsAsErrors"))
			{
				options.TreatWarningsAsErrors = true;
			}

			if(GetProjectProperty("WarningLevel", false) != null)
			{
				try
				{
					options.WarningLevel = Int32.Parse(GetProjectProperty("WarningLevel", false), CultureInfo.InvariantCulture);
				}
				catch(ArgumentNullException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(ArgumentException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(FormatException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
				catch(OverflowException e)
				{
					Trace.WriteLine("Exception : " + e.Message);
				}
			}

			return options;
		}
 public Project AddProject(string projectName, Service service, string[] filePaths, ProjectOptions options, string[] referenceFilePaths = null)
 {
     throw new NotImplementedException();
 }
 internal SimpleMultiAddinConverterCS(ProjectOptions options)
     : base(options)
 {
 }