Exemplo n.º 1
0
 public FbDatabase(IContainerSettings settings)
 {
     var set = (FbDatabaseSettings)settings;
     _conw = new FbConnection(set.ConnectionString);
     try
     {
         _conw.Open();
         SwitchTrigger("MD5_LIST_FROM_EMPTY", UpdateEmptyList() > 0);
     }
     catch (FbException e)
     {
         if (e.ErrorCode == 335544344)
         {
             if (System.Windows.Forms.MessageBox.Show("File not exists" + (set.isEmbedded ? " or database is opened" : string.Empty) + ".\r\nTry to create file?", "Error", MessageBoxButtons.YesNo) == DialogResult.No)
                 throw;
             CreateDb(_conw.ConnectionString, Path.Combine(Helpers.AssemblyDirectory(Assembly.GetExecutingAssembly()), "struct.sql"));
             _conw.Open();
         }
         else
             throw;
     }
     if (_conw.State == System.Data.ConnectionState.Closed)
         _conw.Open();
     _CurrentSettings = (FbDatabaseSettings)set.Clone();
     _conr = new FbConnection(set.ConnectionString);
     _conr.Open();
     InitTagsLength();
     StoppedEvent.Set();
 }
Exemplo n.º 2
0
        protected void ValidateContainerSettings(IContainerSettings settings)
        {
            if (string.IsNullOrWhiteSpace(Settings.GeneratedContainerNamespace))
            {
                throw new ContainerSettingsValidationException(GetIsNullEmptyOrWhitespaceMessage("GeneratedContainerNamespace"));
            }

            if (string.IsNullOrWhiteSpace(Settings.GeneratedContainerClassName))
            {
                throw new ContainerSettingsValidationException(GetIsNullEmptyOrWhitespaceMessage("GeneratedContainerClassName"));
            }

            if (string.IsNullOrWhiteSpace(Settings.GeneratedContainerAssemblyName))
            {
                throw new ContainerSettingsValidationException(GetIsNullEmptyOrWhitespaceMessage("GeneratedContainerAssemblyName"));
            }

            if (string.IsNullOrWhiteSpace(Settings.GeneratedContainerAssemblyLocation))
            {
                throw new ContainerSettingsValidationException(GetIsNullEmptyOrWhitespaceMessage("GeneratedContainerAssemblyLocation"));
            }

            if (false == Directory.Exists(Settings.GeneratedContainerAssemblyLocation))
            {
                throw new DirectoryNotFoundException(
                    "The directory specified by IContainerSettings.GeneratedContainerAssemblyLocation property value was not found."
                    );
            }
        }
 protected RegistrationCodeGeneratorBase(IContainerSettings settings, TemplateRegistrationMetadata metadata, Type returnType)
 {
     Settings = settings;
     Metadata = metadata;
     ReturnType = returnType;
     InstanceField = null != metadata ? InstanceFieldPrefix + Metadata.Index : null;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GeneratedContainerBulider" /> class.
        /// </summary>
        /// <param name="containerGenerator">The container generator.</param>
        /// <param name="registrationAggregator">The registration aggregator.</param>
        /// <param name="containerSettings">The container settings.</param>
        /// <param name="registries">The registries.</param>
        /// <exception cref="System.ArgumentNullException">containerGenerator</exception>
        public GeneratedContainerBulider(IContainerGenerator containerGenerator, IContainerSettings containerSettings, IRegistrationAggregator registrationAggregator, params IRegistry[] registries)
        {
            if (null == containerGenerator)
            {
                throw new ArgumentNullException("containerGenerator");
            }

            _containerGenerator = containerGenerator;
            _containerSettings = containerSettings ?? new DefaultContainerSettings();
            _registrationAggregator = registrationAggregator ?? new RegistrationAggregator();
            _registries = new List<IRegistry>();

            if (null != registries && registries.Length > 0)
            {
                _registries.AddRange(registries);
            }
        }
Exemplo n.º 5
0
        public ContainerCompiler(IContainerSettings settings, Dictionary<string, Assembly> referencedAssemblies, string sourceCode)
        {
            if (null == settings)
            {
                throw new ArgumentNullException("settings");
            }

            if (string.IsNullOrWhiteSpace(sourceCode))
            {
                throw new ArgumentNullException("sourceCode");
            }

            Settings = settings;
            SourceCode = sourceCode;
            ReferencedAssemblies = referencedAssemblies;
            OutputAssemblyFilename = Settings.GeneratedContainerAssemblyPath;
            SourceCodeFilename = Settings.GeneratedContainerSourceCodeFilename;
            Parameters = InitializeCompilerParameters();
        }
Exemplo n.º 6
0
        public IContainer GenerateContainer(IList<IRegistration> registrations, IContainerSettings settings = null)
        {
            if (null == registrations)
            {
                throw new ArgumentNullException("registrations");
            }
            if (registrations.Count < 1)
            {
                throw new ArgumentException("The registrations argument cannot be empty.", "registrations");
            }

            ReferencedAssemblies = InitializeReferencedAssemblies();
            Registrations = registrations;
            Settings = settings ?? new DefaultContainerSettings("Speedioc");
            ValidateContainerSettings(Settings);  // Validate the settings before attempting to use them.
            AssemblyFilename = Path.Combine(Settings.GeneratedContainerAssemblyLocation, Settings.GeneratedContainerAssemblyName + ".dll");
            FullTypeName = string.Format("{0}.{1}", Settings.GeneratedContainerNamespace, Settings.GeneratedContainerClassName);

            return
                ShouldGenerateContainer()
                    ? GenerateContainer()
                    : LoadContainer();
        }
 public ThreadLifetimeRegistrationCodeGenerator(IContainerSettings settings, TemplateRegistrationMetadata metadata, Type returnType)
     : base(settings, metadata, returnType)
 {
 }
Exemplo n.º 8
0
 protected abstract IContainer CreateContainer(IContainerSettings settings, IRegistry registry);
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneratedContainerBulider" /> class.
 /// </summary>
 /// <param name="containerGenerator">The container generator.</param>
 /// <param name="registrationAggregator">The registration aggregator.</param>
 /// <param name="containerSettings">The container settings.</param>
 public GeneratedContainerBulider(IContainerGenerator containerGenerator, IContainerSettings containerSettings = null, IRegistrationAggregator registrationAggregator = null)
     : this(containerGenerator, containerSettings, registrationAggregator, null)
 {
 }
 protected override IContainer CreateContainer(IContainerSettings settings, IRegistry registry)
 {
     IContainerGenerator containerGenerator = new TemplateContainerGenerator();
     IRegistrationAggregator registrationAggregator = new RegistrationAggregator();
     IList<IRegistration> registrations = registrationAggregator.AggregateRegistrations(new List<IRegistry> { registry });
     return containerGenerator.GenerateContainer(registrations, settings);
 }