Example #1
0
        internal Page(int number, DictionaryToken dictionary, MediaBox mediaBox, CropBox cropBox, PageRotationDegrees rotation, PageContent content,
                      AnnotationProvider annotationProvider,
                      IPdfTokenScanner pdfScanner)
        {
            if (number <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(number), "Page number cannot be 0 or negative.");
            }

            Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary));

            Number   = number;
            MediaBox = mediaBox;
            CropBox  = cropBox;
            Rotation = rotation;
            Content  = content;
            textLazy = new Lazy <string>(() => GetText(Content));

            Width  = mediaBox.Bounds.Width;
            Height = mediaBox.Bounds.Height;

            Size = mediaBox.Bounds.GetPageSize();
            ExperimentalAccess      = new Experimental(this, annotationProvider);
            this.annotationProvider = annotationProvider;
            this.pdfScanner         = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
        }
Example #2
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddColumnNameAndTypeConfiguration(
            [NotNull] PropertyConfiguration propertyConfiguration)
        {
            Check.NotNull(propertyConfiguration, nameof(propertyConfiguration));

            var delimitedColumnName =
                AnnotationProvider.For(propertyConfiguration.Property).ColumnName != null &&
                AnnotationProvider.For(propertyConfiguration.Property).ColumnName != propertyConfiguration.Property.Name
                    ? CSharpUtilities.DelimitString(
                    AnnotationProvider.For(propertyConfiguration.Property).ColumnName)
                    : null;

            var delimitedColumnTypeName =
                AnnotationProvider.For(propertyConfiguration.Property).ColumnType != null
                    ? CSharpUtilities.DelimitString(
                    AnnotationProvider.For(propertyConfiguration.Property).ColumnType)
                    : null;

            if (delimitedColumnName != null &&
                delimitedColumnTypeName != null)
            {
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalPropertyBuilderExtensions.HasColumnName),
                        delimitedColumnName));
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalPropertyBuilderExtensions.HasColumnType),
                        delimitedColumnTypeName));
                propertyConfiguration.AttributeConfigurations.Add(
                    _configurationFactory.CreateAttributeConfiguration(
                        nameof(ColumnAttribute),
                        delimitedColumnName,
                        nameof(ColumnAttribute.TypeName) + " = " + delimitedColumnTypeName));
            }
            else if (delimitedColumnName != null)
            {
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalPropertyBuilderExtensions.HasColumnName),
                        delimitedColumnName));
                propertyConfiguration.AttributeConfigurations.Add(
                    _configurationFactory.CreateAttributeConfiguration(nameof(ColumnAttribute), delimitedColumnName));
            }
            else if (delimitedColumnTypeName != null)
            {
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalPropertyBuilderExtensions.HasColumnType),
                        delimitedColumnTypeName));
                propertyConfiguration.AttributeConfigurations.Add(
                    _configurationFactory.CreateAttributeConfiguration(
                        nameof(ColumnAttribute), nameof(ColumnAttribute.TypeName) + " = " + delimitedColumnTypeName));
            }
        }
Example #3
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual string ClassName()
        {
            var annotatedName = AnnotationProvider.For(Model).DatabaseName;

            if (!string.IsNullOrEmpty(annotatedName))
            {
                return(CSharpUtilities.GenerateCSharpIdentifier(annotatedName + DbContextSuffix, null));
            }

            return(DefaultDbContextName);
        }
Example #4
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddValueGeneratedConfiguration(
            [NotNull] PropertyConfiguration propertyConfiguration)
        {
            Check.NotNull(propertyConfiguration, nameof(propertyConfiguration));

            if (!((Property)propertyConfiguration.Property).GetValueGeneratedConfigurationSource().HasValue)
            {
                return;
            }

            var valueGenerated = propertyConfiguration.Property.ValueGenerated;

            switch (valueGenerated)
            {
            case ValueGenerated.OnAdd:
                // If this property is the single integer primary key on the EntityType then
                // KeyConvention assumes ValueGeneratedOnAdd() so there is no need to add it.
                if (_keyConvention.FindValueGeneratedOnAddProperty(
                        new List <Property> {
                    (Property)propertyConfiguration.Property
                },
                        (EntityType)propertyConfiguration.EntityConfiguration.EntityType) == null &&
                    AnnotationProvider.For(propertyConfiguration.Property).DefaultValueSql == null)
                {
                    propertyConfiguration.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            /* hasAttributeEquivalent */ false,
                            nameof(PropertyBuilder.ValueGeneratedOnAdd)));
                }

                break;

            case ValueGenerated.OnAddOrUpdate:
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ false,
                        nameof(PropertyBuilder.ValueGeneratedOnAddOrUpdate)));
                break;

            case ValueGenerated.Never:
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ false,
                        nameof(PropertyBuilder.ValueGeneratedNever)));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #5
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddComputedExpressionConfiguration(
            [NotNull] PropertyConfiguration propertyConfiguration)
        {
            Check.NotNull(propertyConfiguration, nameof(propertyConfiguration));

            if (AnnotationProvider.For(propertyConfiguration.Property).ComputedColumnSql != null)
            {
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ false,
                        nameof(RelationalPropertyBuilderExtensions.HasComputedColumnSql),
                        CSharpUtilities.DelimitString(
                            AnnotationProvider.For(propertyConfiguration.Property).ComputedColumnSql)));
            }
        }
Example #6
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddDefaultValueConfiguration(
            [NotNull] PropertyConfiguration propertyConfiguration)
        {
            Check.NotNull(propertyConfiguration, nameof(propertyConfiguration));

            if (AnnotationProvider.For(propertyConfiguration.Property).DefaultValue != null)
            {
                propertyConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ false,
                        nameof(RelationalPropertyBuilderExtensions.HasDefaultValue),
                        CSharpUtilities.GenerateLiteral(
                            (dynamic)AnnotationProvider.For(propertyConfiguration.Property).DefaultValue)));
            }
        }
Example #7
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddTableNameConfiguration([NotNull] EntityConfiguration entityConfiguration)
        {
            Check.NotNull(entityConfiguration, nameof(entityConfiguration));

            var entityType = entityConfiguration.EntityType;

            if (AnnotationProvider.For(entityType).Schema != null &&
                AnnotationProvider.For(entityType).Schema != AnnotationProvider.For(Model).DefaultSchema)
            {
                var delimitedTableName =
                    CSharpUtilities.DelimitString(AnnotationProvider.For(entityType).TableName);
                var delimitedSchemaName =
                    CSharpUtilities.DelimitString(AnnotationProvider.For(entityType).Schema);
                entityConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalEntityTypeBuilderExtensions.ToTable),
                        delimitedTableName,
                        delimitedSchemaName));
                entityConfiguration.AttributeConfigurations.Add(
                    _configurationFactory.CreateAttributeConfiguration(
                        nameof(TableAttribute),
                        delimitedTableName,
                        nameof(TableAttribute.Schema) + " = " + delimitedSchemaName));
            }
            else if (AnnotationProvider.For(entityType).TableName != null &&
                     AnnotationProvider.For(entityType).TableName != entityType.Scaffolding().DbSetName)
            {
                var delimitedTableName =
                    CSharpUtilities.DelimitString(AnnotationProvider.For(entityType).TableName);
                entityConfiguration.FluentApiConfigurations.Add(
                    _configurationFactory.CreateFluentApiConfiguration(
                        /* hasAttributeEquivalent */ true,
                        nameof(RelationalEntityTypeBuilderExtensions.ToTable),
                        delimitedTableName));
                entityConfiguration.AttributeConfigurations.Add(
                    _configurationFactory.CreateAttributeConfiguration(
                        nameof(TableAttribute), delimitedTableName));
            }
        }
Example #8
0
        public override void AddTableNameConfiguration(EntityConfiguration entityConfiguration)
        {
            // Rather than being smart, we're just always configuring the
            // table name for every entity.

            var entityType          = entityConfiguration.EntityType;
            var delimitedTableName  = CSharpUtilities.DelimitString(AnnotationProvider.For(entityType).TableName);
            var delimitedSchemaName = CSharpUtilities.DelimitString(AnnotationProvider.For(entityType).Schema);

            entityConfiguration.FluentApiConfigurations.Add(
                _configurationFactory.CreateFluentApiConfiguration(
                    true, /* <= hasAttributeEquivalent */
                    nameof(RelationalEntityTypeBuilderExtensions.ToTable),
                    delimitedTableName,
                    delimitedSchemaName));

            entityConfiguration.AttributeConfigurations.Add(
                _configurationFactory.CreateAttributeConfiguration(
                    nameof(TableAttribute),
                    delimitedTableName,
                    $"{nameof(TableAttribute.Schema)} = {delimitedSchemaName}"));
        }
Example #9
0
        internal Page(int number, DictionaryToken dictionary, MediaBox mediaBox, CropBox cropBox, PageContent content,
                      AnnotationProvider annotationProvider)
        {
            if (number <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(number), "Page number cannot be 0 or negative.");
            }

            Dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary));

            Number   = number;
            MediaBox = mediaBox;
            CropBox  = cropBox;
            Content  = content;
            Text     = GetText(content);

            Width  = mediaBox.Bounds.Width;
            Height = mediaBox.Bounds.Height;

            Size = mediaBox.Bounds.GetPageSize();
            ExperimentalAccess = new Experimental(this, annotationProvider);
        }
Example #10
0
        /// <summary>
        /// Changement de statut du post'it
        /// </summary>
        /// <param name="statut">Annulé ou Terminé</param>
        private void ChangeStatut(string statut)
        {
            if (dgvEvenements.RowCount > 0)
            {
                if (dgvEvenements.CurrentRow.Cells[3].Value.ToString() == "Terminé" || dgvEvenements.CurrentRow.Cells[3].Value.ToString() == "Annulé")
                {
                    /* Deja traite ou annule */
                    MessageBox.Show("Ce post'it ne peut plus changer de statut !", "Impossible", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    DialogResult result = MessageBox.Show("Etes-vous certain de vouloir modifier le statut de ce post'it ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        int       ID        = int.Parse(dgvEvenements.CurrentRow.Cells[0].Value.ToString());
                        Evenement evenement = evenementProvider.GetEvenementById(ID);
                        evenement.Statut = statut;
                        evenementProvider.Update(evenement);

                        /* Ajout d'une annotation */
                        string             commentaire        = statut;
                        AnnotationProvider annotationProvider = new AnnotationProvider();
                        Annotation         annotation         = new Annotation
                        {
                            Date        = DateTime.Now,
                            Commentaire = commentaire,
                            Operateur   = "-",
                            CreatedAt   = DateTime.Now,
                            EvenementId = ID
                        };
                        annotationProvider.Create(evenement, annotation);

                        RefreshData();
                    }
                }
            }
        }
Example #11
0
 internal Experimental(Page page, AnnotationProvider annotationProvider)
 {
     this.page = page;
     this.annotationProvider = annotationProvider;
 }
Example #12
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void AddSequenceConfigurations()
        {
            _sequenceConfigurations = new List <SequenceConfiguration>();
            foreach (var sequence in AnnotationProvider.For(Model).Sequences)
            {
                var config = _configurationFactory.CreateSequenceConfiguration();

                config.NameIdentifier = CSharpUtilities.DelimitString(sequence.Name);

                if (sequence.ClrType != Sequence.DefaultClrType)
                {
                    config.TypeIdentifier = CSharpUtilities.GetTypeName(sequence.ClrType);
                }

                if (!string.IsNullOrEmpty(sequence.Schema) &&
                    AnnotationProvider.For(Model).DefaultSchema != sequence.Schema)
                {
                    config.SchemaNameIdentifier = CSharpUtilities.DelimitString(sequence.Schema);
                }

                if (sequence.StartValue != Sequence.DefaultStartValue)
                {
                    config.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            false,
                            nameof(RelationalSequenceBuilder.StartsAt),
                            sequence.StartValue.ToString(CultureInfo.InvariantCulture)));
                }
                if (sequence.IncrementBy != Sequence.DefaultIncrementBy)
                {
                    config.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            false,
                            nameof(RelationalSequenceBuilder.IncrementsBy),
                            sequence.IncrementBy.ToString(CultureInfo.InvariantCulture)));
                }

                if (sequence.MinValue != Sequence.DefaultMinValue)
                {
                    config.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            false,
                            nameof(RelationalSequenceBuilder.HasMin),
                            sequence.MinValue?.ToString(CultureInfo.InvariantCulture) ?? ""));
                }

                if (sequence.MaxValue != Sequence.DefaultMaxValue)
                {
                    config.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            false,
                            nameof(RelationalSequenceBuilder.HasMax),
                            sequence.MaxValue?.ToString(CultureInfo.InvariantCulture) ?? ""));
                }

                if (sequence.IsCyclic != Sequence.DefaultIsCyclic)
                {
                    config.FluentApiConfigurations.Add(
                        _configurationFactory.CreateFluentApiConfiguration(
                            false,
                            nameof(RelationalSequenceBuilder.IsCyclic)));
                }

                _sequenceConfigurations.Add(config);
            }
        }