BlueDot.MsBuild.Tasks.DeployApplication.FindOrCreateApplication C# (CSharp) Метод

FindOrCreateApplication() приватный Метод

private FindOrCreateApplication ( ApplicationManagementClient proxy ) : Application
proxy ApplicationManagementClient
Результат Application
        private Application FindOrCreateApplication(ApplicationManagementClient proxy)
        {
            var applications = GetAllApplications(proxy);

            if (InstallFilePath.ToUpperInvariant().EndsWith(".MSI"))
            {
                var info = SimpleMsiReader.GetMsiInfo(InstallFilePath);
                Version = info.ProductVersion;
                if (string.IsNullOrEmpty(InstallCommandLine))
                {
                    InstallCommandLine = String.Format("/i \"{0}\" /qn", Path.GetFileName(InstallFilePath));
                }
                var app = applications.SingleOrDefault(p => p.ProductCode == info.ProductCode);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                            {
                                ApplicationFolderId = 1,
                                ApplicationFormalName = info.ProductName,
                                ProductCode = info.ProductCode,
                                CreatedByUserName = Environment.UserName,
                                CustomDeviceHandlerModuleId = 4
                            });

                    LogMessage(MessageImportance.Low,
                               String.Format("Created new application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                else
                {
                    LogMessage(MessageImportance.Low,
                               String.Format("Application '{0} ({1})' already exists", info.ProductName,
                                             info.ProductCode));
                }
                return app;
            }

            if (InstallFilePath.ToUpperInvariant().EndsWith(".CAB"))
            {
                var name = GetApplicationNameFromCabFile(InstallFilePath);

                var app = applications.SingleOrDefault(p => p.ApplicationFormalName == name);
                if (app == null)
                {
                    app = proxy.CreateApplication(
                        new NewApplication
                            {
                                ApplicationFolderId = 1,
                                ApplicationFormalName = name,
                                CreatedByUserName = Environment.UserName,
                                CustomDeviceHandlerModuleId = 3
                            });

                    LogMessage(MessageImportance.Low, String.Format("Created new application '{0}'", name));
                }
                else
                {
                    LogMessage(MessageImportance.Low, String.Format("Application '{0}' already exists", name));
                }
                return app;
            }

            throw new NotImplementedException("Only CAB and MSI files are supported");
        }