Esempio n. 1
0
        public static Task <CommandExecutionResult> SetupClusterAsync(ClusterMode clusterMode)
        {
            return(Task.Run(
                       () =>
            {
                String setupClusterScriptPath = ProjectUtility.GetSetupClusterScriptPath();
                string arguments = String.Format("-Auto -PathToClusterLogRoot {0} -SetupLogFileName {1} ", ProjectUtility.DevClusterLogRoot, ProjectUtility.DefaultSetupLogFileName);
                var timeout = ProjectUtility.ClusterSetupTimeout;
                switch (clusterMode)
                {
                case ClusterMode.OneNode:
                    arguments += "-CreateOneNodeCluster";
                    break;

                case ClusterMode.MeshOneNode:
                    arguments += "-CreateOneNodeCluster -CreateMeshCluster";
                    timeout = ProjectUtility.MeshClusterSetupTimeout;
                    break;

                case ClusterMode.MeshFiveNode:
                    arguments += "-CreateMeshCluster";
                    timeout = ProjectUtility.MeshClusterSetupTimeout;
                    break;
                }

                return ProjectUtility.ExecutePowerShellScript(setupClusterScriptPath, arguments, timeout);
            }));
        }
        public async Task <ApiResponse> Handle(AddProjectIndicatorCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                ProjectIndicators indicator = new ProjectIndicators();
                indicator.CreatedById = request.CreatedById;
                indicator.IsDeleted   = false;
                indicator.CreatedDate = request.CreatedDate;

                await _dbContext.ProjectIndicators.AddAsync(indicator);

                await _dbContext.SaveChangesAsync();

                indicator.IndicatorCode = ProjectUtility.GenerateCode(indicator.ProjectIndicatorId);
                await _dbContext.SaveChangesAsync();

                int count = await _dbContext.ProjectIndicators.Where(x => x.IsDeleted == false).CountAsync();

                response.data.ProjectIndicator = new ProjectIndicatorViewModel();
                response.data.TotalCount       = count;
                response.data.ProjectIndicator.ProjectIndicatorId = indicator.ProjectIndicatorId;
                response.data.ProjectIndicator.IndicatorCode      = indicator.IndicatorCode;
                response.StatusCode = StaticResource.successStatusCode;
                response.Message    = StaticResource.SuccessText;
            }
            catch (Exception exception)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + exception.Message;
            }

            return(response);
        }
        public async Task GetSortedProjectIdsAsync_WhenProjectsIsNull_Throws()
        {
            ArgumentNullException exception = await Assert.ThrowsAsync <ArgumentNullException>(
                () => ProjectUtility.GetSortedProjectIdsAsync(projects : null, CancellationToken.None).AsTask());

            Assert.Equal("projects", exception.ParamName);
        }
Esempio n. 4
0
        //start button
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b   = sender as Button;
            string tag = b.Tag.ToString();

            switch (tag)
            {
            case "runall": {
                InputDeviceID window = new InputDeviceID();
                window.ShowDialog();
                string id = window.DeviceID;
                bool   r  = ProjectUtility.IsSmartHomeDeviceID(id);
                if (!r)
                {
                    return;
                }

                Thread t = new Thread(new ThreadStart(() => {
                        _RunAll(id);
                    }));
                t.IsBackground = true;
                t.Start();
                break;
            }

            default: break;
            }
        }
Esempio n. 5
0
        private static void CleanTicketFiles()
        {
            String localClusterDataRoot = ProjectUtility.GetLocalClusterDataRoot();

            if (Directory.Exists(localClusterDataRoot))
            {
                try
                {
                    var ticketFileList = new List <string>();

                    foreach (var dir in Directory.GetDirectories(localClusterDataRoot))
                    {
                        var ticketFileDir = Path.Combine(dir, ProjectUtility.TicketFileDirectoryRelativePath);

                        if (Directory.Exists(ticketFileDir))
                        {
                            ticketFileList.AddRange(Directory.GetFiles(ticketFileDir, "*.tkt"));
                        }
                    }

                    Parallel.ForEach(ticketFileList, file => ProjectUtility.DeleteFileWithRetry(file));
                }
                catch (Exception)
                {
                    // Nothing to do for now
                }
            }
        }
Esempio n. 6
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            var json         = File.ReadAllText(ctx.assetPath);
            var asset        = ScriptableObject.CreateInstance <ActionAsset>();
            var settings     = ProjectUtility.GetOrCreateProjectSettings <ActionGraphGlobalSettings>();
            var jsonSettings = JsonConvert.DefaultSettings.Invoke();

            jsonSettings.TypeNameHandling = TypeNameHandling.All;
            var model = JsonConvert.DeserializeObject <ActionAssetModel>(json, jsonSettings);

            if (model.id.IsCreated)
            {
                AssetDatabase.SetLabels(asset, new string[] { $"Action:{model.id.ToString()}" });
            }
            asset.actionId = model.id;
            if (string.IsNullOrWhiteSpace(userData) || AssetDatabase.GUIDToAssetPath(userData) == null)
            {
                var artifactPath = settings.CreateArtifactPath();

                AssetDatabase.CreateAsset(new TextAsset(), artifactPath);
                userData = AssetDatabase.GUIDFromAssetPath(artifactPath).ToString();
                Debug.Log(artifactPath);
                Debug.Log(userData);
            }
            ctx.AddObjectToAsset("Action", asset, ActionAssetEditor.AssetIcon);
            ctx.SetMainObject(asset);
        }
        public override Task <int> Execute()
        {
            List <FileInfo> matchedProjects = ProjectUtility.GetAllMatchedProjects(_options.RootDir, new[] { ".csproj" }, _options.Include, _options.Exclude).ToList();

            foreach (FileInfo projectFile in matchedProjects)
            {
                Project project = _projectStore.Load(projectFile);

                List <ProjectItemGroupElement> groups = project.Xml.ItemGroups.Where(s => s.Label == "Elephant Project").ToList();

                if (!groups.Any())
                {
                    Log.Debug("Skipping {File}, nothing to do", projectFile.FullName);
                    continue;
                }

                // Remove groups
                foreach (ProjectItemGroupElement groupElement in groups)
                {
                    project.Xml.RemoveChild(groupElement);
                }

                Log.Information("Altered {File}, removed all project reference groups", Path.GetRelativePath(_options.RootDir.FullName, projectFile.FullName));
                project.Save();
            }

            return(Task.FromResult(0));
        }
 public async Task GetSortedProjectIdsAsync_WhenCancellationTokenIsCancelled_Throws()
 {
     await Assert.ThrowsAsync <OperationCanceledException>(
         () => ProjectUtility.GetSortedProjectIdsAsync(
             Enumerable.Empty <IProjectContextInfo>(),
             new CancellationToken(canceled: true)).AsTask());
 }
Esempio n. 9
0
        public async void TestProjectLoading()
        {
            Stream loadStream     = null;
            string result         = "";
            var    openFileDialog = new OpenFileDialog
            {
                Filter           = "Project files | *.prj",
                FilterIndex      = 1,
                RestoreDirectory = true,
                Multiselect      = false
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((loadStream = openFileDialog.OpenFile()) != null)
                {
                    using (StreamReader reader = new StreamReader(loadStream))
                    {
                        result = await reader.ReadToEndAsync();
                    }
                }
            }
            var project = new Project("Aurora", "Agmiles", new List <string> {
                "C#"
            }, ProjectType.CSharp_Project);
            var newProject = ProjectUtility.CreateProject(result) as Project;

            Assert.AreEqual(project.ProjectType, newProject.ProjectType);
        }
        public TrayApplicationContext(ApplicationManager appMgr)
        {
            this.appMgr = appMgr;

            this.trayIcon = new NotifyIcon
            {
                ContextMenuStrip = new ContextMenuStrip(),
                Icon             = this.GetTrayIcon(),
                Text             = this.GetCurrentClusterModeText(ProjectUtility.GetCurrentClusterMode()),
                Visible          = true
            };

            // Attach handler to dynamically build context menu each it opens.
            this.trayIcon.ContextMenuStrip.Opening += this.ContextMenuStripOnOpening;
            this.trayIcon.DoubleClick += this.OnTrayIconDoubleClick;

            // Register events to update tooltip text for the systray icon.
            // This helps in updating the tool tip if cluster is removed, recreated using the SDK PS scripts.
            this.trayIcon.Click      += this.OnTrayIconClick;
            this.trayIcon.MouseClick += this.OnTrayIconClick;

            if (appMgr.StartupOperation == ClusterOperationType.None)
            {
                // Display Welcome message
                this.ShowBalloonTip(SR.WelcomeTrayIconText, SR.WelcomeBalloonText, ToolTipIcon.Info);
            }
            else
            {
                // Execute start up operation.
                this.ExecuteOperation(appMgr.StartupOperation);
            }
        }
        private async Task StopCluster_ConfirmationObtained()
        {
            if (ClusterManager.IsClusterRunningOrStartPending)
            {
                this.CheckForAdminPrivileges(ClusterOperationType.Stop);

                this.trayIcon.ContextMenuStrip.Enabled = false;
                this.ShowBalloonTip(SR.StopClusterBalloonTip, ToolTipIcon.Info);
                this.SetTrayIconText(SR.StopClusterToolTip);

                try
                {
                    await ClusterManager.StopClusterAsync();

                    this.ShowBalloonTip(SR.StopClusterSuccessBalloonTip, ToolTipIcon.Info);
                }
                catch (Exception)
                {
                    this.ShowBalloonTip(SR.StopClusterFailedBalloonTip, ToolTipIcon.Error);
                }

                this.SetTrayIconText(this.GetCurrentClusterModeText(ProjectUtility.GetCurrentClusterMode()));
                this.trayIcon.ContextMenuStrip.Enabled = true;
            }
            else
            {
                this.ShowBalloonTip(SR.ClusterAlreadyStoppedBalloonTip, ToolTipIcon.Info);
            }
        }
        private static void UpdateArtifacts(object obj)
        {
            var settings             = ProjectUtility.GetOrCreateProjectSettings <ActionGraphGlobalSettings>();
            var actionSchema         = ProjectUtility.GetOrCreateProjectAsset <ActionSchema>();
            var fieldOperationSchema = ProjectUtility.GetOrCreateProjectAsset <FieldOperationSchema>();
            var definitions          = AssetDatabase.FindAssets($"t:{nameof(ActionDefinitionAsset)}").Select(guid => AssetDatabase.LoadAssetAtPath <ActionDefinitionAsset>(AssetDatabase.GUIDToAssetPath(guid))).ToDictionary(definition => definition.id);

            foreach (var guid in AssetDatabase.FindAssets($"t:{nameof(ActionAsset)}"))
            {
                var path         = AssetDatabase.GUIDToAssetPath(guid);
                var action       = AssetDatabase.LoadAssetAtPath <ActionAsset>(path);
                var artifactFile = action.GetArtifactFile(settings);
                var importer     = AssetImporter.GetAtPath(path);
                var model        = action.CreateModel();
                if (definitions.TryGetValue(action.actionId, out ActionDefinitionAsset definitionAsset) && definitionAsset.delegateType.IsCreated)
                {
                    using var blob = CreateUntyped(model, actionSchema, fieldOperationSchema, definitionAsset, Allocator.Temp);
                    var newGuid = WriteUntypedArtifact(artifactFile, blob, definitionAsset.delegateType);
                    if (importer.userData != newGuid)
                    {
                        importer.userData = newGuid;
                        importer.SaveAndReimport();
                    }
                }
            }
        }
Esempio n. 13
0
        private static void InitCommand()
        {
            // Check if project file already exists
            string path = Environment.CurrentDirectory;

            if (ProjectUtility.ProjectExists(path))
            {
                Console.Error.WriteLine("A Hephaestus project is already initialized. Use 'hephaestus' to launch Hephaestus.");

                Environment.Exit(1);
            }

            if (ConsoleUtility.AskYesNoQuestion("Use the command line?"))
            {
                InitFromCommandLineCommand();
                return;
            }

            // Launch Hephaestus Configurator
            ProcessStartInfo processStartInfo = new ProcessStartInfo
            {
                Arguments = path,
                // TODO: Create key in HephaestusInstaller
                FileName = RegistryUtility.GetKey(@"SOFTWARE\WOW6432Node\ArmaAchilles\Hephaestus\HephaestusConfigurator", "Path")
            };

            Process.Start(processStartInfo);

            Environment.Exit(0);
        }
        public void SyncProjectsOK()
        {
            List <Project> fakeProjects = ProjectUtility.GetFakeSimpleProjects();

            string content = JsonConvert.SerializeObject(fakeProjects.GetRange(0, 2), new JsonSerializerSettings
            {
                DateTimeZoneHandling = DateTimeZoneHandling.Utc
            });

            Mock <HttpWebRequest> mockWebRequest = FakeWebRequest.CreateRequestWithResponse(content, new Dictionary <string, string> {
                { "SyncTimestamp", "stamp1;projectid=3" }
            });

            mockWebRequest.SetupSet(r => r.Method = "GET").Verifiable();

            SyncResult <Project> result = syncService.SyncProjects(null).GetAwaiter().GetResult();

            UriBuilder uriBuilder = new UriBuilder("https://api.aproplan.com/rest/projectsync");

            string expectedUrl = AproplanApiUtility.BuildRestUrl(mockApi.Object.ApiRootUrl, "projectsync", mockApi.Object.ApiVersion, mockApi.Object.RequesterId);

            Assert.AreEqual(expectedUrl, FakeWebRequest.Instance.UriCalled[0].ToString());
            Assert.AreEqual(2, result.Data.Count);
            Assert.AreEqual(fakeProjects[0].Id, result.Data[0].Id);
            Assert.AreEqual(fakeProjects[1].Id, result.Data[1].Id);
            Assert.AreEqual("stamp1;projectid=3", result.ContinuationToken);
            mockWebRequest.Verify();
        }
        private async void ManageClusterMenuItemClick(object sender, EventArgs e)
        {
            if (ClusterManager.IsClusterRunning)
            {
                this.trayIcon.ContextMenuStrip.Enabled = false;

                try
                {
                    this.CheckForPendingRestart(ClusterOperationType.Manage);

                    string sfxUrl = await ClusterManager.GetServiceFabricExplorerUrl();

                    ProjectUtility.LaunchServiceFabricExplorer(sfxUrl);
                }
                catch (Exception)
                {
                    this.ShowBalloonTip(SR.FailedToOpenLCE, ToolTipIcon.Error);
                }

                this.trayIcon.ContextMenuStrip.Enabled = true;
            }
            else
            {
                this.ShowBalloonTip(SR.ClusterNotSetupOrNotRunning, ToolTipIcon.Info);
            }
        }
Esempio n. 16
0
        private void LoadAllFields()
        {
            if (Equals(ComboBoxProjectDirectory.SelectedItem, ComboBoxProjectDirectoryAddNew))
            {
                return;
            }

            string path = ComboBoxProjectDirectory.Text;

            if (!Directory.Exists(path))
            {
                return;
            }

            if (!ProjectUtility.ProjectExists(path))
            {
                return;
            }

            Project project = ProjectUtility.GetProject(path);

            TextBoxSourceDirectory.Text                  = project.SourceDirectory;
            TextBoxTargetDirectory.Text                  = project.TargetDirectory;
            TextBoxAddonBuilderFile.Text                 = project.AddonBuilderFile;
            TextBoxProjectPrefix.Text                    = project.ProjectPrefix;
            TextBoxPrivateKeyFile.Text                   = project.PrivateKeyFile;
            TextBoxGameExecutable.Text                   = project.Game.GameExecutable;
            TextBoxGameExecutableArguments.Text          = project.Game.GameExecutableArguments;
            CheckboxShutdownGameBeforeBuilding.IsChecked = project.ShutdownGameBeforeBuilding;
            CheckboxStartGameAfterBuilding.IsChecked     = project.StartGameAfterBuilding;
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            ApplicationContext.Initialize(Guid.NewGuid().ToString());
            ApplicationContext.Current.Services.Add <IDataService>(new ConnectionStringDataService(SelectedConnection.BuildConnectionString(Password)));
            IProject project = ProjectUtility.InitProject(ModelPath);

            ApplicationContext.Current.Services.Add <IProjectContextService>(new SimpleProjectContextService(project));
        }
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            var settings             = ProjectUtility.GetOrCreateProjectSettings <ActionGraphGlobalSettings>();
            var actionSchema         = ProjectUtility.GetOrCreateProjectAsset <ActionSchema>();
            var fieldOperationSchema = ProjectUtility.GetOrCreateProjectAsset <FieldOperationSchema>();

            foreach (var path in importedAssets.Where(importedAsset => importedAsset.EndsWith($".{ActionGraphGlobalSettings.Extension}")))
            {
                var    importer = AssetImporter.GetAtPath(path);
                var    userData = importer.userData;
                string artifactFile;
                if (string.IsNullOrWhiteSpace(userData))
                {
                    artifactFile = settings.CreateArtifactPath();
                }
                else
                {
                    artifactFile = AssetDatabase.GUIDToAssetPath(userData);
                    if (string.IsNullOrEmpty(artifactFile))
                    {
                        artifactFile = settings.CreateArtifactPath();
                    }
                }
                var actionAsset           = AssetDatabase.LoadAssetAtPath <ActionAsset>(path);
                var actionDefinitionAsset = ActionDefinitionAsset.Load(actionAsset.actionId);
                if (actionDefinitionAsset?.delegateType.IsCreated == true)
                {
                    var guid = (string)typeof(ActionGraphSerializer).GetMethod(nameof(ActionGraphSerializer.WriteArtifact), System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
                               .MakeGenericMethod(actionDefinitionAsset.delegateType)
                               .Invoke(null, new object[] {
                        artifactFile, actionSchema, fieldOperationSchema, actionAsset, actionDefinitionAsset
                    });
                    if (guid != importer.userData)
                    {
                        importer.userData = guid;
                        importer.SaveAndReimport();
                    }
                }
                else
                {
                    AssetDatabase.DeleteAsset(artifactFile);
                }
            }
            foreach (var path in deletedAssets.Where(deletedAsset => deletedAsset.EndsWith($".{ActionGraphGlobalSettings.Extension}")))
            {
                var userData = AssetImporter.GetAtPath(path).userData;
                if (!string.IsNullOrWhiteSpace(userData))
                {
                    var artifactPath = AssetDatabase.GUIDToAssetPath(userData);
                    if (!string.IsNullOrEmpty(artifactPath))
                    {
                        AssetDatabase.DeleteAsset(artifactPath);
                    }
                }
            }
            AssetDatabase.Refresh();
        }
 private void UpdateAssemblyData()
 {
     if (serializedObject.targetObject is ActionDefinitionAsset definitionAsset)
     {
         var assemblyData = ProjectUtility.GetOrCreateProjectAsset <ActionAssemblyData>();
         assemblyData.entries[definitionAsset.id.guid] = new ActionAssemblyData.Entry(definitionAsset);
         ProjectUtility.UpdateProjectAsset(assemblyData);
     }
 }
Esempio n. 20
0
 public static Task <CommandExecutionResult> RemoveClusterAsync()
 {
     return(Task.Run(
                () =>
     {
         String removeClusterScriptPath = ProjectUtility.GetRemoveClusterScriptPath();
         return ProjectUtility.ExecutePowerShellScript(removeClusterScriptPath, String.Format("-Auto -PathToClusterLogRoot {0} -SetupLogFileName {1}", ProjectUtility.DevClusterLogRoot, ProjectUtility.DefaultSetupLogFileName), ProjectUtility.ClusterCleanupTimeout);
     }));
 }
 private void UpdateTrayIconText()
 {
     // NOTE: All tooltip text must not be more than 63 chars long.
     // get cluster mode from registry and update tooltip text if an operation is not running.
     if (!this.IsOperationRunning())
     {
         this.SetTrayIconText(this.GetCurrentClusterModeText(ProjectUtility.GetCurrentClusterMode()));
     }
 }
Esempio n. 22
0
        public async Task <string> GetProjectJobCode(ProjectJobDetail model)
        {
            ProjectDetail projectDetail = await _dbContext.ProjectDetail.FirstOrDefaultAsync(x => x.ProjectId == model.ProjectId &&
                                                                                             x.IsDeleted == false);

            long projectjobCount = await _dbContext.ProjectJobDetail.LongCountAsync(x => x.ProjectId == model.ProjectId &&
                                                                                    x.IsDeleted == false);

            return(ProjectUtility.GenerateProjectJobCode(projectDetail.ProjectCode, projectjobCount++));
        }
Esempio n. 23
0
        private List <Project> GetProjectList()
        {
            List <Project> worksTitle = new List <Project>();

            try {
                worksTitle = ProjectUtility.GetProjectTitle();
            } catch (Exception) {
                MessageBox.Show("Проверьте настройки приложения", "Ошибка приложения", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return(worksTitle);
        }
Esempio n. 24
0
        private void Login()
        {
            ApplicationContext.Initialize(Guid.NewGuid().ToString());
            ApplicationContext.Current.Services.Add <IDataService>(new ConnectionStringDataService(SelectedConnection.BuildConnectionString(Password)));
            IProject project = ProjectUtility.InitProject(ModelPath);

            ApplicationContext.Current.Services.Add <IProjectContextService>(new SimpleProjectContextService(project));
            if (LoginSuccessful != null)
            {
                LoginSuccessful(this, EventArgs.Empty);
            }
        }
Esempio n. 25
0
 public List <SerializableMethod> GetMethods(FieldInfo fieldInfo, SerializedProperty property)
 {
     if (property.serializedObject.targetObject is ActionDefinitionAsset definitionAsset && definitionAsset.delegateType.IsCreated)
     {
         var returnType = definitionAsset.delegateType.Value.GetMethod("Invoke").ReturnType;
         if (returnType != typeof(void) && ProjectUtility.GetOrCreateProjectAsset <ActionReturnTypeAggregatorSchema>().data.TryGetValue(returnType, out var result))
         {
             return(result);
         }
     }
     return(null);
 }
        public async Task <ApiResponse> Handle(AddAreaDetailCommand request, CancellationToken cancellationToken)
        {
            ApiResponse response     = new ApiResponse();
            long        LatestCodeId = 0;
            var         code         = string.Empty;

            try
            {
                var data = await _dbContext.AreaDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.AreaName.Trim().ToLower() == request.AreaName.Trim().ToLower());

                if (data == null)
                {
                    AreaDetail obj        = _mapper.Map <AddAreaDetailCommand, AreaDetail>(request);
                    var        AreaDetail = await _dbContext.AreaDetail
                                            .OrderByDescending(x => x.AreaId)
                                            .FirstOrDefaultAsync(x => x.IsDeleted == false);

                    if (AreaDetail == null)
                    {
                        LatestCodeId = 1;
                        code         = ProjectUtility.GenerateCode(LatestCodeId);
                    }
                    else
                    {
                        LatestCodeId = AreaDetail.AreaId + 1;
                        code         = ProjectUtility.GenerateCode(LatestCodeId);
                    }
                    obj.AreaCode    = code;
                    obj.AreaName    = request.AreaName;
                    obj.IsDeleted   = false;
                    obj.CreatedById = request.CreatedById;
                    obj.CreatedDate = DateTime.UtcNow;
                    await _dbContext.AreaDetail.AddAsync(obj);

                    await _dbContext.SaveChangesAsync();

                    response.StatusCode = StaticResource.successStatusCode;
                    response.Message    = "Success";
                }
                else
                {
                    response.StatusCode = StaticResource.NameAlreadyExist;
                    response.Message    = StaticResource.ListNameAlreadyExist;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = StaticResource.failStatusCode;
                response.Message    = StaticResource.SomethingWrong + ex.Message;
            }
            return(response);
        }
Esempio n. 27
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var field    = new ActionAssetField();
            var attr     = fieldInfo.GetCustomAttribute <ActionTypeAttribute>();
            var settings = ProjectUtility.GetProjectAsset <ActionGraphGlobalSettings>();

            if (attr != null && ActionDefinitionAsset.Load(attr.type, out var info))
            {
                field.ActionId = info.id;
            }
            field.Label = property.displayName;
            field.BindProperty(property);
            return(field);
        }
Esempio n. 28
0
        public static void RebuildDlls()
        {
            var data = ProjectUtility.GetProjectAsset <ActionAssemblyData>();

            if (data != null)
            {
                var hash = data.GenerateHash();
                if (data.lastHash != hash)
                {
                    data.lastHash = hash;
                    ProjectUtility.UpdateProjectAsset(data);
                    ActionSystemProducer.CreateAssembly();
                }
            }
        }
Esempio n. 29
0
        public override VisualElement CreatePropertyGUI(SerializedProperty property)
        {
            var           settings    = ProjectUtility.GetProjectSettings <ActionGraphGlobalSettings>();
            var           definitions = ActionDefinitionAsset.LoadAll().ToArray();
            List <string> guids       = definitions.Select(a => a.id.guid).ToList();

            guids.Insert(0, string.Empty);
            var popup = new PopupField <string>(property.displayName, guids, property.FindPropertyRelative("guid").stringValue, (choice) => FormatCell(definitions, choice)
                                                , (choice) => FormatCell(definitions, choice)
                                                );

            popup.SetEnabled(settings != null);
            popup.BindProperty(property.FindPropertyRelative("guid"));
            return(popup);
        }
        static private bool CheckIsSourceFile(ProjectItem item)
        {
            try
            {
                string itemType = "";
                if (ProjectUtility.HasProperty(item.Properties, "ItemType"))
                {
                    itemType = item.Properties.Item("ItemType").Value.ToString();
                }

                if (itemType == "ClCompile")
                {
                    Logging.Logging.LogInfo("Accepting item because of its \"ItemType\" property");
                    return(true);
                }

                if (itemType == "None")
                {
                    Logging.Logging.LogInfo("Discarding item because \"ItemType\" has been set to \"Does not participate in build\"");
                    return(false);
                }

                string contentType = "";
                if (ProjectUtility.HasProperty(item.Properties, "ContentType"))
                {
                    contentType = item.Properties.Item("ContentType").Value.ToString();
                }

                if (contentType == "CppCode")
                {
                    Logging.Logging.LogInfo("Accepting item because of its \"ContentType\" property");
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.Logging.LogError("Exception: " + e.Message);
            }

            if (_sourceExtensionWhiteList.Contains(GetFileExtension(item).ToLower()))
            {
                Logging.Logging.LogInfo("Accepting item because of its file extension");
                return(true);
            }

            Logging.Logging.LogInfo("Discarding item because of wrong code model");
            return(false);
        }