Exemplo n.º 1
0
        private string AddProperty(string file, IPropertyAdditionOptions options)
        {
            StringEditor stringEditor = new StringEditor(file);

            FindStartingLineForNewProperty(file, options, stringEditor);

            if (!stringEditor.GetLine().Contains("}"))
            {
                stringEditor.Prev();
            }

            if (ContainsProperty(file))
            {
                stringEditor.InsertNewLine();
            }

            if (!options.IsOptional)
            {
                stringEditor.InsertLine("        [Required]");
            }

            if (options.PropertyType == PropertyTypes.String && options.PropertyTypeExtra != null)
            {
                stringEditor.InsertLine($"        [StringLength({options.PropertyTypeExtra})]");
            }

            stringEditor.InsertLine(BackendDtoPropertyLine.GetPropertyLine(options));

            return(stringEditor.GetText());
        }
Exemplo n.º 2
0
        private string AddProperty(string file, IPropertyAdditionOptions options, bool forInterface)
        {
            StringEditor stringEditor = new StringEditor(file);

            FindStartingLineForNewProperty(file, options, stringEditor);

            if (!stringEditor.GetLine().Contains("}"))
            {
                stringEditor.Prev();
            }

            if (ContainsProperty(file))
            {
                stringEditor.InsertNewLine();
            }

            if (forInterface)
            {
                stringEditor.InsertLine(BackendDtoInterfacePropertyLine.GetPropertyLine(options));
            }
            else
            {
                stringEditor.InsertLine(BackendDtoPropertyLine.GetPropertyLine(options));
            }

            return(stringEditor.GetText());
        }
Exemplo n.º 3
0
        private string AddProperty(string file, IRelationSideAdditionOptions options, bool forInterface)
        {
            StringEditor stringEditor = new StringEditor(file);

            FindStartingLineForNewProperty(file, options, stringEditor);

            if (!stringEditor.GetLine().Contains("}"))
            {
                stringEditor.Prev();
            }

            if (ContainsProperty(file))
            {
                stringEditor.InsertNewLine();
            }

            if (forInterface)
            {
                stringEditor.InsertLine($"        {options.PropertyType} {options.PropertyName} {{ get; set; }}");
            }
            else
            {
                stringEditor.InsertLine($"        public {options.PropertyType} {options.PropertyName} {{ get; set; }}");
            }

            return(stringEditor.GetText());
        }
Exemplo n.º 4
0
        private string UpdateFileData(IPropertyAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            // ----------- Creators -----------
            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.NextThatContains($"public static I{options.EntityName} Default()");
            stringEditor.Next(line => line.Trim().Equals("};"));
            stringEditor.InsertLine($"                {options.PropertyName} = {options.EntityName}TestValues.{options.PropertyName}Default,");
            fileData = stringEditor.GetText();

            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains($"public static I{options.EntityName} Default2()");
            stringEditor.Next(line => line.Trim().Equals("};"));
            stringEditor.InsertLine($"                {options.PropertyName} = {options.EntityName}TestValues.{options.PropertyName}Default2,");
            fileData = stringEditor.GetText();

            // ----------- Asserts -----------
            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains("AssertDefault(");
            stringEditor.Next(line => line.Trim().Equals("}"));
            stringEditor.InsertLine($"            Assert.AreEqual({options.EntityName}TestValues.{options.PropertyName}Default, {options.EntityNameLower}.{options.PropertyName});");
            fileData = stringEditor.GetText();

            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains("AssertDefault2(");
            stringEditor.Next(line => line.Trim().Equals("}"));
            stringEditor.InsertLine($"            Assert.AreEqual({options.EntityName}TestValues.{options.PropertyName}Default2, {options.EntityNameLower}.{options.PropertyName});");
            fileData = stringEditor.GetText();

            return(stringEditor.GetText());
        }
Exemplo n.º 5
0
        private string UpdateFileData(IEntityAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            string usingStatement = $"{options.ProjectName}.Persistence.Modules.{options.Domain}.{options.EntityNamePlural}";

            fileData = UsingStatements.Add(fileData, usingStatement);

            StringEditor stringEditor = new StringEditor(fileData);

            // ----------- DbSet -----------
            stringEditor.NextThatContains("CustomInstantiate");

            stringEditor.InsertLine(GetDbSetLine(options));
            stringEditor.InsertNewLine();

            // ----------- OnModelCreating -----------

            stringEditor.NextThatContains("this.OnModelCreatingPartial(modelBuilder);");

            stringEditor.InsertLine(GetEmptyModelBuilderEntityLine(options));
            stringEditor.InsertNewLine();

            return(stringEditor.GetText());
        }
Exemplo n.º 6
0
        static void DeleteDots(StringEditor str)
        {
            int length = str.String.Length;

            char[] s = str.String.ToCharArray();
            for (int i = 0; i < length; i++)
            {
                if (s[i] == '.')
                {
                    for (int j = i; j < length; j++)
                    {
                        if (j == length - 1)
                        {
                            break;
                        }
                        s[j] = s[j + 1];
                    }
                    length--;
                    i--;
                }
            }
            char[] newCharArray = new char[length];
            for (int i = 0; i < length; i++)
            {
                newCharArray[i] = s[i];
            }
            str.String = new string(newCharArray);
        }
Exemplo n.º 7
0
        private string UpdateFileData(IRelationAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            StringEditor stringEditor = new StringEditor(fileData);

            // ----------- DbSet -----------
            stringEditor.NextThatContains($"export class {options.EntityNameFrom}DetailPage");
            stringEditor.Next();

            stringEditor.InsertNewLine();
            stringEditor.InsertLine($"  public {options.EntityNamePluralLowerTo}TableDataSource = new MatTableDataSource<I{options.EntityNameTo}>([]);");
            stringEditor.InsertLine($"  public {options.EntityNamePluralLowerTo}GridColumns: string[] = [");
            stringEditor.InsertLine($"    'name',");
            stringEditor.InsertLine($"    'detail',");
            stringEditor.InsertLine($"  ];");

            stringEditor.NextThatContains($"private async load{options.EntityNameFrom}(");
            stringEditor.NextThatContains("  }");

            stringEditor.InsertNewLine();
            stringEditor.InsertLine($"    this.{options.EntityNamePluralLowerTo}TableDataSource.data = this.{options.EntityNameLowerFrom}.{options.PropertyNameTo.LowerFirstChar()};");

            return(stringEditor.GetText());
        }
Exemplo n.º 8
0
        private string UpdateFileData(IRelationAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.NextThatContains("constructor(");
            stringEditor.InsertLine($"  {options.EntityNamePluralLowerFrom}: I{options.EntityNameFrom}[];");
            stringEditor.InsertNewLine();

            stringEditor.NextThatContains("private router: Router");
            stringEditor.InsertLine($"    private {options.EntityNamePluralLowerFrom}CrudService: {options.EntityNamePluralFrom}CrudService,");

            stringEditor.NextThatContains("this.formBuilder.group({");
            stringEditor.NextThatContains("});");
            stringEditor.InsertLine($"      {options.PropertyNameFrom.LowerFirstChar()}Id: new FormControl(null, [Validators.required]),");

            stringEditor.MoveToStart();
            stringEditor.NextThatContains("ngOnInit()");
            stringEditor.NextThatStartsWith("  }");
            stringEditor.InsertNewLine();
            stringEditor.InsertLine($"    this.{options.EntityNamePluralLowerFrom} = await this.{options.EntityNamePluralLowerFrom}CrudService.get{options.EntityNamePluralFrom}();");

            return(stringEditor.GetText());
        }
Exemplo n.º 9
0
        private void ButtonEdit_OnClick(object sender, RoutedEventArgs e)
        {
            // Get the direction from the current line.
            var direction = ((FrameworkElement)sender).DataContext as Direction;

            // Hmm, no direction.. gracefully exit.
            if (direction == null)
            {
                return;
            }

            // Set the initial text for the editor.
            var win = new StringEditor
            {
                Text                  = direction.Speedwalk,
                EditorMode            = StringEditor.EditorType.Text,
                StatusText            = $"Direction: {direction.Name}",
                Owner                 = App.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };

            // Show the string dialog
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                direction.Speedwalk = win.Text;
            }
        }
        private string UpdateFileData(IEntityAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            fileData = UsingStatements.Add(fileData, $"{options.ProjectName}.Persistence.Modules.{options.Domain}.{options.EntityNamePlural}");
            fileData = UsingStatements.Add(fileData, $"{options.ProjectName}.Persistence.Tests.Modules.{options.Domain}.{options.EntityNamePlural}");

            // ----------- DbSet -----------
            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.NextThatContains("persistenceDbContext.SaveChanges();");

            if (options.HasRequestScope)
            {
                stringEditor.InsertLine($"            persistenceDbContext.{options.EntityNamePlural}.Add(Db{options.EntityName}.ToEf{options.EntityName}(Db{options.EntityName}Test.DbDefault(), {options.EntityName}TestValues.{options.RequestScopeName}IdDbDefault));");
                stringEditor.InsertLine($"            persistenceDbContext.{options.EntityNamePlural}.Add(Db{options.EntityName}.ToEf{options.EntityName}(Db{options.EntityName}Test.DbDefault2(), {options.EntityName}TestValues.{options.RequestScopeName}IdDbDefault));");
            }
            else
            {
                stringEditor.InsertLine($"            persistenceDbContext.{options.EntityNamePlural}.Add(Db{options.EntityName}.ToEf{options.EntityName}(Db{options.EntityName}Test.DbDefault()));");
                stringEditor.InsertLine($"            persistenceDbContext.{options.EntityNamePlural}.Add(Db{options.EntityName}.ToEf{options.EntityName}(Db{options.EntityName}Test.DbDefault2()));");
            }

            stringEditor.InsertNewLine();

            return(stringEditor.GetText());
        }
        private string AddServices(string fileData, IEntityAdditionOptions options, string projectFolder)
        {
            string contractNamespace = GetContractNamespace(options, projectFolder);

            fileData = UsingStatements.Add(fileData, contractNamespace);

            string projectNamespace = GetProjectNamespace(options, projectFolder);

            fileData = UsingStatements.Add(fileData, projectNamespace);

            // Insert into Startup-Method
            StringEditor stringEditor       = new StringEditor(fileData);
            string       addScopedStatement = GetAddScopedStatement(options.EntityNamePlural, projectFolder);

            stringEditor.NextThatContains($"void Startup{options.Domain}");
            stringEditor.Next();
            stringEditor.NextThatContains("}");

            if (!stringEditor.GetLineAtOffset(-1).Trim().Equals("{"))
            {
                stringEditor.InsertNewLine();
            }
            stringEditor.InsertLine($"            // {options.EntityNamePlural}");
            stringEditor.InsertLine(addScopedStatement);

            return(stringEditor.GetText());
        }
Exemplo n.º 12
0
        static void AddSymbols(int pos, string str, StringEditor strObj)
        {
            int len    = strObj.String.Length;
            int strLen = str.Length;

            if (pos <= len && pos >= 0)
            {
                char[] charArr       = strObj.String.ToCharArray();
                char[] addingCharArr = str.ToCharArray();
                char[] newCharArr    = new char[len + strLen];
                int    breakIndex    = 0;
                for (int i = 0; i < pos; i++)
                {
                    newCharArr[i] = charArr[i];
                    breakIndex    = i + 1;
                }
                int j = 0;
                for (int i = pos; i < pos + strLen; i++)
                {
                    newCharArr[i] = addingCharArr[j];
                    j++;
                }
                for (int i = pos + strLen; i < len + strLen; i++)
                {
                    newCharArr[i] = charArr[breakIndex];
                    breakIndex++;
                }
                strObj.String = new string(newCharArr);
            }
            else
            {
                Console.WriteLine("Неверная позиция");
            }
        }
Exemplo n.º 13
0
        private string UpdateFileData(IPropertyAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            // ----------- DbSet -----------
            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.NextThatContains("UpdateEf" + options.EntityName);
            stringEditor.Next(line => line.Trim().Equals("}"));

            stringEditor.InsertLine($"            ef{options.EntityName}.{options.PropertyName} = db{options.EntityName}.{options.PropertyName};");
            fileData = stringEditor.GetText();

            // ----------- DbSet -----------
            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains("FromEf" + options.EntityName);
            stringEditor.Next(line => line.Trim().Equals("};"));

            stringEditor.InsertLine($"                {options.PropertyName} = ef{options.EntityName}.{options.PropertyName},");
            fileData = stringEditor.GetText();

            // ----------- DbSet -----------
            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains("ToEf" + options.EntityName);
            stringEditor.Next(line => line.Trim().Equals("};"));

            stringEditor.InsertLine($"                {options.PropertyName} = db{options.EntityName}.{options.PropertyName},");

            return(stringEditor.GetText());
        }
        private void AddTab(IRelationAdditionOptions options, StringEditor stringEditor)
        {
            stringEditor.MoveToStart();
            stringEditor.NextThatContains("    </mat-tab-group>");

            stringEditor.InsertLine($"        <mat-tab label=\"{options.PropertyNameTo.ToReadable()}\">");
            stringEditor.InsertLine($"            <h2>{options.PropertyNameTo.ToReadable()}</h2>");
            stringEditor.InsertLine($"            <div class=\"table-container\">");
            stringEditor.InsertLine($"                <table mat-table [dataSource]=\"{options.EntityNamePluralLowerTo}TableDataSource\">");
            stringEditor.InsertLine($"");
            stringEditor.InsertLine($"                    <ng-container matColumnDef=\"name\">");
            stringEditor.InsertLine($"                        <th mat-header-cell *matHeaderCellDef> Name </th>");
            stringEditor.InsertLine($"                        <td mat-cell *matCellDef=\"let element\"> {{{{element.name}}}} </td>");
            stringEditor.InsertLine($"                    </ng-container>");
            stringEditor.InsertLine($"");
            stringEditor.InsertLine($"                    <ng-container matColumnDef=\"detail\">");
            stringEditor.InsertLine($"                        <th mat-header-cell *matHeaderCellDef></th>");
            stringEditor.InsertLine($"                        <td mat-cell *matCellDef=\"let element\" width=\"10%\">");
            stringEditor.InsertLine($"                            <button mat-button role=\"link\">Detail</button>");
            stringEditor.InsertLine($"                        </td>");
            stringEditor.InsertLine($"                    </ng-container>");
            stringEditor.InsertLine($"");
            stringEditor.InsertLine($"                    <tr mat-header-row *matHeaderRowDef=\"{options.EntityNamePluralLowerTo}GridColumns; sticky: true\"></tr>");
            stringEditor.InsertLine($"                    <tr mat-row *matRowDef=\"let row; columns: {options.EntityNamePluralLowerTo}GridColumns;\"");
            stringEditor.InsertLine($"                        [routerLink]=\"['/{StringConverter.PascalToKebabCase(options.DomainTo)}/{StringConverter.PascalToKebabCase(options.EntityNamePluralTo)}/detail', row.id]\"></tr>");
            stringEditor.InsertLine($"                </table>");
            stringEditor.InsertLine($"            </div>");
            stringEditor.InsertLine($"        </mat-tab>");
        }
Exemplo n.º 15
0
        private string UpdateFileData(IRelationAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            StringEditor stringEditor = new StringEditor(fileData);

            // ----------- DbSet -----------

            if (fileData.Contains("</mat-tab-group>"))
            {
                stringEditor.NextThatContains("<mat-tab label=\"Stammdaten\">");
                stringEditor.NextThatContains("</mat-tab>");
            }
            else
            {
                stringEditor.NextThatStartsWith($"<div class=\"{options.EntityNameTo.ToKebab()}-detail-page\"");
                stringEditor.NextThatStartsWith($"</div>");
            }

            stringEditor.InsertNewLine();

            stringEditor.InsertLine(GetLine(options));

            return(stringEditor.GetText());
        }
Exemplo n.º 16
0
        private void ButtonEdit_OnClick(object sender, RoutedEventArgs e)
        {
            // Get the direction from the current line.
            var direction = ((FrameworkElement)sender).DataContext as Direction;

            // Hmm, no direction.. gracefully exit.
            if (direction == null)
            {
                return;
            }

            // Set the initial text for the editor.
            var win = new StringEditor
            {
                Text = direction.Speedwalk
            };

            // Set this to be a text editor.
            win.EditorMode = StringEditor.EditorType.Text;

            // Startup position of the dialog should be in the center of the parent window.  The
            // owner has to be set for this to work.
            win.Owner = App.MainWindow;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            // Show the string dialog
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                direction.Speedwalk = win.Text;
            }
        }
Exemplo n.º 17
0
 public static void VariablesPopup(GameObject go, string fsmName, UIHint hint, SkillString variable)
 {
     if (SkillEditorGUILayout.BrowseButton(go != null, Strings.get_Tooltip_Browse_variables_in_FSM()))
     {
         StringEditor.editingVariable = variable;
         StringEditor.DoVariablesMenu(go, fsmName, hint);
     }
 }
Exemplo n.º 18
0
 public static StringEditor instance()
 {
     if (_instance == null)
     {
         _instance = CreateInstance <StringEditor>();
         _instance.OnEnable();
     }
     return(_instance);
 }
Exemplo n.º 19
0
    public static StringEditor              ShowManifestEditorWindow()
    {
        StringEditor editor = EditorWindow.GetWindow(typeof(StringEditor),
                                                     true, "String Manifest Editor") as StringEditor;

        editor.initialize();
        editor.Show();
        return(editor);
    }
Exemplo n.º 20
0
    void initialize()
    {
        manifest = new Manifest();
        plugins  = new AgentDependency();
        if (System.IO.File.Exists(AgentDependency.AgentsFile))
        {
            plugins = AndroidAgentEditor.LoadAgentsFromFile(AgentDependency.AgentsFile);
            if (System.IO.File.Exists(Manifest.ManifestFile))
            {
                manifest = AndroidManifestEditor.LoadManifestFromFile(Manifest.ManifestFile);
            }
            else
            {
                manifest = new Manifest();
            }

            if (System.IO.File.Exists(ManifestResource.StringsFilename))
            {
                exist_strings = StringEditor.LoadResourcesFromFile(ManifestResource.StringsFilename);
            }
            else
            {
                exist_strings = new ManifestResource();
            }
            strings = new ManifestResource();
        }
        else
        {
            Debug.LogError("AgentDependencies.xml not found.");
        }

        PositiveButton.fixedWidth    = 30;
        PositiveButton.stretchWidth  = false;
        NegetiveButton.fixedWidth    = 30;
        NegetiveButton.stretchWidth  = false;
        BoldLabel.normal.textColor   = Color.white;
        BoldLabel.fontStyle          = FontStyle.Bold;
        SubBoldLabel.fontStyle       = FontStyle.Bold;
        RedLabel.normal.textColor    = new Color(0.8f, 0.1f, 0.1f, 1.0f);
        GreenLabel.normal.textColor  = new Color(0.1f, 0.8f, 0.1f, 1.0f);
        YellowLabel.normal.textColor = new Color(0.8f, 0.8f, 0.1f, 1.0f);

        if (System.IO.Directory.Exists(AgentVersion.VersionsPath))
        {
            Versions = GetVersionsFromPath(AgentVersion.VersionsPath, plugins);
        }
        else
        {
            Versions = new List <AgentSetVersion>();
        }

        guiVersions   = new UnityGUI_Versions(Versions, plugins, manifest);
        guiProperties = new UnityGUI_AgentVersion(manifest);
        guiVersions.SetStyles(PositiveButton, NegetiveButton, BoldLabel, GreenLabel, RedLabel, YellowLabel);
        guiProperties.SetStyles(PositiveButton, NegetiveButton, SubBoldLabel, GreenLabel, RedLabel, YellowLabel);
    }
Exemplo n.º 21
0
 public static void AnimationNamePopup(GameObject go, SkillString variable, object obj = null, FieldInfo field = null)
 {
     if (SkillEditorGUILayout.BrowseButton(go != null, Strings.get_Tooltip_Browse_Animations_on_GameObject()))
     {
         StringEditor.editingVariable = variable;
         StringEditor.editingObject   = obj;
         StringEditor.editingField    = field;
         StringEditor.DoAnimationNameMenu(go);
     }
 }
Exemplo n.º 22
0
 private static void DoAnimatorParameterPopup(GameObject go, AnimatorControllerParameterType parameterType, SkillString variable, object obj = null, FieldInfo field = null)
 {
     if (SkillEditorGUILayout.BrowseButton(go != null, string.Format(Strings.get_Tooltip_Browse_Animator_Parameters(), parameterType)))
     {
         StringEditor.editingVariable = variable;
         StringEditor.editingObject   = obj;
         StringEditor.editingField    = field;
         StringEditor.DoAnimatorParameterMenu(go, parameterType);
     }
 }
Exemplo n.º 23
0
 public static void SortingLayerNameBrowseButton(SkillString variable, object obj = null, FieldInfo field = null)
 {
     if (SkillEditorGUILayout.BrowseButton(true, Strings.get_Label_Sorting_Layers()))
     {
         StringEditor.editingVariable = variable;
         StringEditor.editingObject   = obj;
         StringEditor.editingField    = field;
         StringEditor.DoSortingLayerMenu();
     }
 }
Exemplo n.º 24
0
 public void Initialize(UIElement dialogContent)
 {
     this.DialogContent                   = dialogContent;
     this.propertyNameEditor              = LogicalTreeHelper.FindLogicalNode((DependencyObject)this.DialogContent, "PropertyName") as StringEditor;
     this.acceptButton                    = LogicalTreeHelper.FindLogicalNode((DependencyObject)this.DialogContent, "AcceptButton") as Button;
     this.propertyNameValidator           = new MessageBubbleValidator <string, TextChangedEventArgs>((Func <string>)(() => this.propertyNameEditor.Text), new Func <string, string>(this.ValidatePropertyName));
     this.propertyNameMessageBubble       = new MessageBubbleHelper((UIElement)this.propertyNameEditor, (IMessageBubbleValidator)this.propertyNameValidator);
     this.propertyNameEditor.TextChanged += new TextChangedEventHandler(this.propertyNameValidator.EventHook);
     this.acceptButton.IsEnabled          = false;
 }
    public static void Main()
    {
        var stringEditor = new StringEditor();

        stringEditor.Login("pesho");
        stringEditor.Prepend("pesho", "stringexample");
        stringEditor.Delete("pesho", 3, 6);
        stringEditor.Insert("pesho", 3, "asdassdaasd");
        Console.WriteLine(stringEditor.Print("pesho"));
    }
        private string UpdateFileData(IRelationAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            fileData = UsingStatements.Add(fileData, $"{options.ProjectName}.Contract.Persistence.Modules.{options.DomainFrom}.{options.EntityNamePluralFrom}");
            fileData = UsingStatements.Add(fileData, $"{options.ProjectName}.Logic.Tests.Modules.{options.DomainFrom}.{options.EntityNamePluralFrom}");

            // ----------- Repository Generation -----------
            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.MoveToEnd();
            stringEditor.Next();
            stringEditor.PrevThatContains("}");
            stringEditor.PrevThatContains("}");
            stringEditor.InsertLine("\n" +
                                    $"        private Mock<I{options.EntityNamePluralFrom}CrudRepository> Setup{options.EntityNamePluralFrom}RepositoryDefault()\n" +
                                    "        {\n" +
                                    $"            var {options.EntityNamePluralLowerFrom}CrudRepository = new Mock<I{options.EntityNamePluralFrom}CrudRepository>(MockBehavior.Strict);\n" +
                                    $"            {options.EntityNamePluralLowerFrom}CrudRepository.Setup(repository => repository.Does{options.EntityNameFrom}Exist({options.EntityNameFrom}TestValues.IdDefault)).Returns(true);\n" +
                                    $"            {options.EntityNamePluralLowerFrom}CrudRepository.Setup(repository => repository.Does{options.EntityNameFrom}Exist({options.EntityNameFrom}TestValues.IdDefault2)).Returns(true);\n" +
                                    $"            {options.EntityNamePluralLowerFrom}CrudRepository.Setup(repository => repository.Does{options.EntityNameFrom}Exist({options.EntityNameFrom}TestValues.IdForCreate)).Returns(false);\n" +
                                    $"            return {options.EntityNamePluralLowerFrom}CrudRepository;\n" +
                                    "        }");

            fileData = stringEditor.GetText();

            // ----------- TestMethods -----------
            stringEditor = new StringEditor(fileData);
            stringEditor.NextThatContains("[TestMethod]");
            while (stringEditor.GetLineNumber() < stringEditor.GetLineCount())
            {
                stringEditor.Next();
                if (stringEditor.GetLine().Contains("Create" + options.EntityNameTo) ||
                    stringEditor.GetLine().Contains("Update" + options.EntityNameTo))
                {
                    stringEditor.NextThatContains($"Mock<I{options.EntityNamePluralTo}CrudRepository>");
                    stringEditor.Next(line => !line.Contains("CrudRepository>") && line.Trim().Length > 0);
                    stringEditor.InsertLine($"            Mock<I{options.EntityNamePluralFrom}CrudRepository> {options.EntityNamePluralLowerFrom}CrudRepository = this.Setup{options.EntityNamePluralFrom}RepositoryDefault();");

                    stringEditor.NextThatContains($"{options.EntityNamePluralTo}CrudLogic {options.EntityNamePluralLowerTo}CrudLogic = new {options.EntityNamePluralTo}CrudLogic");
                    stringEditor.Next(line => !line.Contains("CrudRepository.Object"));
                    stringEditor.InsertLine($"                {options.EntityNamePluralLowerFrom}CrudRepository.Object,");
                }
                else
                {
                    stringEditor.NextThatContains($"{options.EntityNamePluralTo}CrudLogic {options.EntityNamePluralLowerTo}CrudLogic = new {options.EntityNamePluralTo}CrudLogic");
                    stringEditor.Next(line => !line.Contains("CrudRepository.Object"));
                    stringEditor.InsertLine("                null,");
                }
                stringEditor.NextThatContains("[TestMethod]");
            }

            return(stringEditor.GetText());
        }
Exemplo n.º 27
0
 public static void LayerNamePopup(GUIContent label, SkillString variable, object obj = null, FieldInfo field = null)
 {
     SkillEditorGUILayout.PrefixLabel(label);
     if (GUILayout.Button(variable.get_Value(), EditorStyles.get_popup(), new GUILayoutOption[0]))
     {
         StringEditor.editingVariable = variable;
         StringEditor.editingObject   = obj;
         StringEditor.editingField    = field;
         StringEditor.DoLayerMenu();
     }
 }
Exemplo n.º 28
0
        private static void OnIsPendingEditChanged(object sender, DependencyPropertyChangedEventArgs args)
        {
            StringEditor stringEditor = sender as StringEditor;

            if (stringEditor == null || !(bool)args.NewValue)
            {
                return;
            }
            stringEditor.SetValue(PendableEdit.IsPendingEditProperty, (object)false);
            stringEditor.IsEditing = true;
        }
Exemplo n.º 29
0
 void IComponentConnector.Connect(int connectionId, object target)
 {
     if (connectionId == 1)
     {
         this.ExpressionTextBox = (StringEditor)target;
     }
     else
     {
         this._contentLoaded = true;
     }
 }
Exemplo n.º 30
0
        private string UpdateFileData(IPropertyAdditionOptions options, string filePath)
        {
            string fileData = File.ReadAllText(filePath);

            StringEditor stringEditor = new StringEditor(fileData);

            stringEditor.NextThatContains("this.formBuilder.group({");
            stringEditor.NextThatContains("});");
            stringEditor.InsertLine(FrontendFormBuilderPropertyLine.GetPropertyLine(options));

            return(stringEditor.GetText());
        }
Exemplo n.º 31
0
		public void FillControls(MethodDefinition mdef)
		{
			OpCodeBindingSource.DataSource = PluginFactory.GetInstance().GetAllOpCodes();
			OpCodes.SelectedIndex = 0;

			Operands.Items.Add(new NoneOperandEditor());
			Operands.Items.Add(new ByteEditor());
			Operands.Items.Add(new SByteEditor());
			Operands.Items.Add(new IntegerEditor());
			Operands.Items.Add(new LongEditor());
			Operands.Items.Add(new SingleEditor());
			Operands.Items.Add(new DoubleEditor());

			var stringEditor = new StringEditor();
			var verbatimStringEditor = new VerbatimStringEditor();
			var bridge = new OperandEditorBridge<string>(stringEditor, verbatimStringEditor);
			Disposed += delegate { bridge.Dispose(); };

			Operands.Items.Add(stringEditor);
			Operands.Items.Add(verbatimStringEditor);

			if (mdef.HasBody)
			{
				Operands.Items.Add(new InstructionReferenceEditor(mdef.Body.Instructions));
				Operands.Items.Add(new MultipleInstructionReferenceEditor(mdef.Body.Instructions));
				Operands.Items.Add(new VariableReferenceEditor(mdef.Body.Variables));
			}
			else
			{
				Operands.Items.Add(new OperandReferenceEditor<Instruction, InstructionWrapper>(null));
				Operands.Items.Add(new MultipleInstructionReferenceEditor(null));
				Operands.Items.Add(new OperandReferenceEditor<VariableDefinition, VariableWrapper>(null));
			}

			Operands.Items.Add(new ParameterReferenceEditor(mdef.Parameters));
			Operands.Items.Add(new FieldReferenceEditor());
			Operands.Items.Add(new MethodReferenceEditor());
			Operands.Items.Add(new GenericParameterEditor());
			Operands.Items.Add(new TypeReferenceEditor());
			Operands.Items.Add(new NotSupportedOperandEditor());

			Operands.SelectedIndex = 0;
		}
Exemplo n.º 32
0
		public ConstantEditor()
		{
			InitializeComponent();

			ConstantTypes.Items.Add(new NoneOperandEditor());
			ConstantTypes.Items.Add(new NullOperandEditor());
			ConstantTypes.Items.Add(new ByteEditor());
			ConstantTypes.Items.Add(new SByteEditor());
			ConstantTypes.Items.Add(new IntegerEditor());
			ConstantTypes.Items.Add(new LongEditor());
			ConstantTypes.Items.Add(new SingleEditor());
			ConstantTypes.Items.Add(new DoubleEditor());

			var stringEditor = new StringEditor();
			var verbatimStringEditor = new VerbatimStringEditor();
			var bridge = new OperandEditorBridge<string>(stringEditor, verbatimStringEditor);
			Disposed += delegate { bridge.Dispose(); };

			ConstantTypes.Items.Add(stringEditor);
			ConstantTypes.Items.Add(verbatimStringEditor);

			ConstantTypes.SelectedIndex = 0;
		}
		public CustomAttributeArgumentEditor()
		{
			InitializeComponent();

			TypeSpecification.Items.Add(Editors.TypeSpecification.Default);
			if (AllowArray) TypeSpecification.Items.Add(Editors.TypeSpecification.Array);
			TypeSpecification.SelectedIndex = 0;

			ArgumentTypes.Items.Add(new NullOperandEditor());
			ArgumentTypes.Items.Add(new BooleanEditor());
			ArgumentTypes.Items.Add(new ByteEditor());
			ArgumentTypes.Items.Add(new SByteEditor());
			ArgumentTypes.Items.Add(new IntegerEditor());
			ArgumentTypes.Items.Add(new LongEditor());
			ArgumentTypes.Items.Add(new SingleEditor());
			ArgumentTypes.Items.Add(new DoubleEditor());

			var stringEditor = new StringEditor();
			var verbatimStringEditor = new VerbatimStringEditor();
			var bridge = new GenericOperandEditorBridge<string>(stringEditor, verbatimStringEditor);
			Disposed += delegate { bridge.Dispose(); };

			ArgumentTypes.Items.Add(stringEditor);
			ArgumentTypes.Items.Add(verbatimStringEditor);

			ArgumentTypes.Items.Add(new TypeReferenceEditor());

			ArgumentTypes.SelectedIndex = 0;
		}