Exemple #1
0
        // TODO: Refactor dependency mess
        public SoundGeneratorViewModel(ISessionContextService sessionContext,
                                       IDialogService dialogService,
                                       IFoldersExplorerFactory <SoundEvent, Sound> factory,
                                       IPreferenceService preferenceService,
                                       ISoundJsonUpdaterFactory jsonUpdaterFactory,
                                       IEditorFormFactory <Sound> editorFormFactory,
                                       IUniqueValidator <SoundEvent> soundEventValidator,
                                       ICodeGenerationService codeGenerationService)
            : base(sessionContext, dialogService, factory)
        {
            Preferences = preferenceService.GetOrCreate <SoundsGeneratorPreferences>();

            PreferenceService     = preferenceService;
            JsonUpdaterFactory    = jsonUpdaterFactory;
            SoundEventValidator   = soundEventValidator;
            CodeGenerationService = codeGenerationService;

            Explorer.AllowFileExtensions(".ogg");
            Explorer.OpenFileDialog.Filter                = "Sound file (*.ogg) | *.ogg";
            Explorer.OpenFileDialog.Multiselect           = true;
            Explorer.OpenFileDialog.CheckFileExists       = true;
            Explorer.OpenFileDialog.ValidateNames         = true;
            Explorer.OpenFolderDialog.ShowNewFolderButton = true;

            FileEditor             = editorFormFactory.Create();
            FileEditor.ItemEdited += OnSoundEdited;
        }
Exemple #2
0
 public MaterialGeneratorViewModel(ISessionContextService sessionContext,
                                   IEditorFormFactory <Material> editorFormFactory,
                                   IUniqueValidator <Material> validator,
                                   ICodeGenerationService codeGenerationService)
     : base(sessionContext, editorFormFactory, validator, codeGenerationService)
 {
 }
Exemple #3
0
        protected override void PopulateForDatabase()
        {
            foreach (ITablePopulator table in this.Tables)
            {
                // store uniques in temporary place
                IUniqueValidator[] uniques = new IUniqueValidator[table.Uniques.Count];
                table.Uniques.CopyTo(uniques, 0);

                // replace each unique validator by a SqlCommandUniqueValidator
                foreach (IUniqueValidator unique in uniques)
                {
                    // remove old unique
                    table.Uniques.Remove(unique);

                    // create new uniquevalidator
                    SqlCommandUniqueValidator sqlUnique =
                        new SqlCommandUniqueValidator(table, unique.Unique, this.ConnectionString);

                    // looking if autoincrement
                    if (unique.Unique.IsPrimaryKey && unique.Unique.Columns.Length == 1 && unique.Unique.Columns[0].AutoIncrement)
                    {
                        sqlUnique.IsIdentity = true;
                    }

                    table.Uniques.Add(sqlUnique);
                }
            }
        }
        protected override void PopulateForDatabase()
        {
            foreach (ITablePopulator table in this.Tables)
            {
                // store uniques in temporary place
                IUniqueValidator[] uniques = new IUniqueValidator[table.Uniques.Count];
                table.Uniques.CopyTo(uniques, 0);

                // replace each unique validator by a SqlCommandUniqueValidator
                foreach (IUniqueValidator unique in uniques)
                {
                    // remove old unique
                    table.Uniques.Remove(unique);

                    // create new uniquevalidator
                    SqlCommandUniqueValidator sqlUnique =
                        new SqlCommandUniqueValidator(table, unique.Unique, this.ConnectionString);

                    // looking if autoincrement
                    if (unique.Unique.IsPrimaryKey && unique.Unique.Columns.Length == 1 && unique.Unique.Columns[0].AutoIncrement)
                        sqlUnique.IsIdentity = true;

                    table.Uniques.Add(sqlUnique);
                }
            }
        }
 public BlockGeneratorViewModel(ISessionContextService sessionContext,
                                IEditorFormFactory <Block> editorFormFactory,
                                IUniqueValidator <Block> validator,
                                ICodeGenerationService codeGenerationService)
     : base(sessionContext, editorFormFactory, validator, codeGenerationService)
 {
 }
 public bool Contains(IUniqueValidator unique)
 {
     if (unique == null)
     {
         throw new ArgumentNullException("unique");
     }
     return(this.Contains(unique.Unique));
 }
 public void Remove(IUniqueValidator unique)
 {
     if (unique == null)
     {
         throw new ArgumentNullException("unique");
     }
     if (unique == this.primaryKey)
     {
         this.primaryKey = null;
     }
     this.contraints.Remove(unique.Unique);
 }
 public SimpleInitViewModelBase(ISessionContextService sessionContext,
                                IEditorFormFactory <TModel> editorFormFactory,
                                IUniqueValidator <TModel> validator,
                                ICodeGenerationService codeGenerationService)
     : base(sessionContext)
 {
     Validator              = validator;
     CodeGenerationService  = codeGenerationService;
     EditorForm             = editorFormFactory.Create();
     EditorForm.ItemEdited += OnModelEdited;
     EditorForm.Validator   = validator;
 }
        public void Remove(UniqueConstraint unique)
        {
            if (unique == null)
            {
                throw new ArgumentNullException("unique");
            }
            IUniqueValidator uv = this.contraints[unique] as IUniqueValidator;

            if (uv != null && uv == this.primaryKey)
            {
                this.primaryKey = null;
            }
            this.contraints.Remove(unique);
        }
        public void Add(IUniqueValidator unique)
        {
            if (unique == null)
            {
                throw new ArgumentNullException("unique");
            }
            if (unique.Unique.IsPrimaryKey && this.primaryKey != null)
            {
                throw new InvalidOperationException("duplicate primary key");
            }
            else
            {
                this.primaryKey = unique;
            }

            this.contraints.Add(unique.Unique, unique);
        }
        public CommandGeneratorViewModel(ISessionContextService sessionContext,
                                         IFoldersExplorerFactory <ObservableFolder <Command>, Command> factory,
                                         IEditorFormFactory <Command> editorFormFactory,
                                         IUniqueValidator <Command> validator,
                                         ICodeGenerationService codeGenerationService)
            : base(sessionContext, factory)
        {
            CommandValidator       = validator;
            CodeGenerationService  = codeGenerationService;
            EditorForm             = editorFormFactory.Create();
            EditorForm.ItemEdited += CreateCommand;
            EditorForm.Validator   = validator;

            Explorer.OpenFileDialog.Filter                = "Java file (*.java) | *.java";
            Explorer.OpenFileDialog.Multiselect           = true;
            Explorer.OpenFileDialog.CheckFileExists       = true;
            Explorer.OpenFileDialog.ValidateNames         = true;
            Explorer.OpenFolderDialog.ShowNewFolderButton = true;
            Explorer.AllowFileExtensions(".java");

            Explorer.FileSynchronizer.SyncFilter = NotifyFilter.File;
        }
Exemple #12
0
        public RecipeGeneratorViewModel(ISessionContextService sessionContext,
                                        IFoldersExplorerFactory <ObservableFolder <Recipe>, Recipe> factory,
                                        IEditorFormFactory <RecipeCreator> editorFormFactory,
                                        IUniqueValidator <Recipe> recipeValidator,
                                        ISerializer <Recipe> recipeSerializer,
                                        ICodeGenerationService codeGenerationService)
            : base(sessionContext, factory)
        {
            RecipeValidator        = recipeValidator;
            RecipeSerializer       = recipeSerializer;
            CodeGenerationService  = codeGenerationService;
            EditorForm             = editorFormFactory.Create();
            EditorForm.ItemEdited += CreateRecipe;

            Explorer.OpenFileDialog.Filter                = "Json file (*.json) | *.json";
            Explorer.OpenFileDialog.Multiselect           = true;
            Explorer.OpenFileDialog.CheckFileExists       = true;
            Explorer.OpenFileDialog.ValidateNames         = true;
            Explorer.OpenFolderDialog.ShowNewFolderButton = true;
            Explorer.AllowFileExtensions(".json");

            Explorer.FileSynchronizer.SyncFilter = NotifyFilter.File;
        }
        public void Add(IUniqueValidator unique)
        {
            if (unique==null)
                throw new ArgumentNullException("unique");
            if (unique.Unique.IsPrimaryKey && this.primaryKey!=null)
                throw new InvalidOperationException("duplicate primary key");
            else
                this.primaryKey=unique;

            this.contraints.Add(unique.Unique,unique);
        }
 public void Clear()
 {
     this.contraints.Clear();
     this.primaryKey=null;
 }
 public void Clear()
 {
     this.contraints.Clear();
     this.primaryKey = null;
 }
 public bool Contains(IUniqueValidator unique)
 {
     if (unique==null)
         throw new ArgumentNullException("unique");
     return this.Contains(unique.Unique);
 }
 public void Remove(IUniqueValidator unique)
 {
     if (unique==null)
         throw new ArgumentNullException("unique");
     if (unique==this.primaryKey)
         this.primaryKey=null;
     this.contraints.Remove(unique.Unique);
 }
 public void Remove(UniqueConstraint unique)
 {
     if (unique==null)
         throw new ArgumentNullException("unique");
     IUniqueValidator uv = this.contraints[unique] as IUniqueValidator;
     if (uv!=null && uv==this.primaryKey)
         this.primaryKey=null;
     this.contraints.Remove(unique);
 }