Esempio n. 1
0
 public DataCatalog(
     IDictionaryFactory dictionaryFactory)
 {
     _assemblies    = new HashSet <string>();
     _types         = new HashSet <Type>();
     _registrations = dictionaryFactory.Create <Type, SupplierRegistration[]>();
 }
 public GoogleUpdateController(IDictionaryStorage store)
     : base(UITableViewStyle.Grouped, null,true)
 {
     this.store = store;
     this.supplier = CreateSupplier ();
     Initialize ();
 }
Esempio n. 3
0
 /// <summary>
 /// Adds single specified dictionary from file.
 /// </summary>
 /// <param name="dictionaryFactory">Implementation of IDictionaryFactory</param>
 /// <param name="filePath">path to file</param>
 public void AddSingleDictionary(IDictionaryFactory dictionaryFactory, string filePath)
 {
     using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
     {
         AddSingleDictionary(dictionaryFactory, fileStream);
     }
 }
 public PageDependenciesFactory(
     IRenderContextFactory renderContextFactory,
     IIdManager idManager,
     IAssetManager assetManager,
     INameManager nameManager,
     ICssWriterFactory cssWriterFactory,
     IJavascriptWriterFactory javascriptWriterFactory,
     IDataScopeProviderFactory dataScopeProviderFactory,
     IDataConsumerFactory dataConsumerFactory,
     IDictionaryFactory dictionaryFactory,
     IDataContextBuilderFactory dataContextBuilderFactory,
     IDataCatalog dataCatalog,
     IDataDependencyFactory dataDependencyFactory)
 {
     _renderContextFactory      = renderContextFactory;
     _idManager                 = idManager;
     _assetManager              = assetManager;
     _nameManager               = nameManager;
     _cssWriterFactory          = cssWriterFactory;
     _javascriptWriterFactory   = javascriptWriterFactory;
     _dataScopeProviderFactory  = dataScopeProviderFactory;
     _dataConsumerFactory       = dataConsumerFactory;
     _dictionaryFactory         = dictionaryFactory;
     _dataContextBuilderFactory = dataContextBuilderFactory;
     _dataCatalog               = dataCatalog;
     _dataDependencyFactory     = dataDependencyFactory;
 }
Esempio n. 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="configuration">Library configuration.</param>
        /// <param name="dictionaryFactory"></param>
        /// <param name="logger"></param>
        public FileDictionaryManager(
            LocalizationConfiguration configuration,
            IDictionaryFactory dictionaryFactory,
            ILogger <FileDictionaryManager> logger = null
            ) : base(configuration, logger)
        {
            m_dictionaries = new HashSet <ILocalizationDictionary>();
            m_dictionariesPerCultureAndScope = new ConcurrentDictionary <CultureInfo, IDictionary <string, ILocalizationDictionary> >
            {
                [DefaultCulture()] = new ConcurrentDictionary <string, ILocalizationDictionary>()
            };

            foreach (var supportedCulture in m_configuration.SupportedCultures)
            {
                if (!m_dictionariesPerCultureAndScope.ContainsKey(supportedCulture))
                {
                    m_dictionariesPerCultureAndScope.Add(supportedCulture, new ConcurrentDictionary <string, ILocalizationDictionary>());
                }
            }

            if (configuration.AutoLoadResources)
            {
                AutoLoadDictionaries(dictionaryFactory);
            }
        }
Esempio n. 6
0
/// <summary>
/// Load the basic dictionary definitions
/// </summary>
/// <param name="factory"></param>

        public static Dictionary <string, DictionaryMx> LoadDictionaries(
            IDictionaryFactory factory)
        {
            DictionaryFactory = factory;
            Dictionaries      = factory.LoadDictionaries();
            return(Dictionaries);
        }
 public GoogleUpdateController(IDictionaryStorage store) :
     base(UITableViewStyle.Grouped, null, true)
 {
     this.store    = store;
     this.supplier = CreateSupplier();
     Initialize();
 }
Esempio n. 8
0
 public LayoutDependenciesFactory(
     IDictionaryFactory dictionaryFactory,
     IDataConsumerFactory dataConsumerFactory)
 {
     DictionaryFactory   = dictionaryFactory;
     DataConsumerFactory = dataConsumerFactory;
 }
Esempio n. 9
0
        /// <summary>
        /// Adds single specified dictionary from stream.
        /// </summary>
        /// <param name="dictionaryFactory">Implementation of IDictionaryFactory</param>
        /// <param name="resourceStream">stream</param>
        public void AddSingleDictionary(IDictionaryFactory dictionaryFactory, Stream resourceStream)
        {
            var dictionaryManager = (FileDictionaryManager)m_dictionaryManagers[LocTranslationSource.File];

            dictionaryManager.AddDictionaryToHierarchyTrees(
                dictionaryFactory.CreateDictionary(resourceStream)
                );
        }
Esempio n. 10
0
 public SuperTypedPropertyBag(IDictionaryFactory dictionaryFactory)
 {
     _intValues       = dictionaryFactory.GenerateDictionary <int>();
     _boolValues      = dictionaryFactory.GenerateDictionary <bool>();
     _shortValues     = dictionaryFactory.GenerateDictionary <short>();
     _longValues      = dictionaryFactory.GenerateDictionary <long>();
     _referenceValues = dictionaryFactory.GenerateDictionary <object>();
 }
Esempio n. 11
0
        private void AddLocalizationDictionary(
            IAutoDictionaryManager dictionaryManager,
            IDictionaryFactory dictionaryFactory,
            string fileName
            )
        {
            var filePath = Path.Combine("OtherLocalization", fileName);

            dictionaryManager.AddSingleDictionary(dictionaryFactory, filePath);
        }
Esempio n. 12
0
        /// <summary>Initializes a new instance of the <see cref="T:Blondin.JaggedDictionary`2" />
        /// class that is empty, has the default initial capacity, and uses the default equality
        /// comparer for the key type.</summary>
        public JaggedDictionary(int depth, IDictionaryFactory <TKey> dictionaryFactory = null)
        {
            if (depth < 1)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException1(ExceptionArgument.capacity);
            }

            this._dictionaryFactory = dictionaryFactory ?? DictionaryFactory <TKey> .Default;
            this.Depth = depth;
            this._root = CreateInternalDictionary(0);
        }
        public void Resolve_can_create_dictionary_of_instances_by_enum_values([Frozen, ResolvesToFailure] IResolver proxiedResolver,
                                                                              [Frozen] IDictionaryFactory dictionaryFactory,
                                                                              [Frozen] IServiceRegistrationProvider registrationProvider,
                                                                              NamedInstanceDictionaryResolverProxy sut,
                                                                              ResolutionRequest request,
                                                                              SampleEnum[] names,
                                                                              ResolutionPath path)
        {
            // Arrange
            var serviceType = request.ServiceType;
            var keyType     = typeof(SampleEnum);
            var valueType   = typeof(ISampleService);

            Mock.Get(dictionaryFactory)
            .Setup(x => x.IsGenericDictionaryType(serviceType))
            .Returns(true);
            Mock.Get(dictionaryFactory)
            .Setup(x => x.GetKeyType(serviceType))
            .Returns(keyType);
            Mock.Get(dictionaryFactory)
            .Setup(x => x.GetValueType(serviceType))
            .Returns(valueType);
            Mock.Get(dictionaryFactory)
            .Setup(x => x.Create(keyType, valueType))
            .Returns(() => new Dictionary <SampleEnum, ISampleService>());
            var registrations = names
                                .Select(x => x.ToString())
                                .Select(x => Mock.Of <IServiceRegistration>(r => r.Name == x && r.ServiceType == valueType))
                                .ToArray();

            Mock.Get(registrationProvider)
            .Setup(x => x.GetAll(valueType))
            .Returns(registrations);
            Mock.Get(proxiedResolver)
            .Setup(x => x.Resolve(It.Is <ResolutionRequest>(r => r.ServiceType == valueType)))
            .Returns((ResolutionRequest r) => ResolutionResult.Success(path, new SampleServiceImplementationOne()));

            // Act
            var result = sut.Resolve(request);

            // Assert
            Mock.Get(proxiedResolver)
            .Verify(x => x.Resolve(It.Is <ResolutionRequest>(r => r.ServiceType == valueType)), Times.Exactly(names.Length));
            foreach (var name in names.Select(x => x.ToString()).ToArray())
            {
                Mock.Get(proxiedResolver)
                .Verify(x => x.Resolve(It.Is <ResolutionRequest>(r => r.Name == name)), Times.Once);
            }
            Assert.That(result.IsSuccess, Is.True);
            Assert.That(result.ResolvedObject, Is.InstanceOf <IDictionary <SampleEnum, ISampleService> >());
            var resolvedObject = (IDictionary <SampleEnum, ISampleService>)result.ResolvedObject;

            Assert.That(resolvedObject, Has.Count.EqualTo(names.Length));
        }
Esempio n. 14
0
        public AssetManager(
            IRequestRouter requestRouter,
            IFrameworkConfiguration frameworkConfiguration,
            ICssWriterFactory cssWriterFactory,
            IJavascriptWriterFactory javascriptWriterFactory,
            IStringBuilderFactory stringBuilderFactory,
            IDictionaryFactory dictionaryFactory)
        {
            _frameworkConfiguration  = frameworkConfiguration;
            _cssWriterFactory        = cssWriterFactory;
            _javascriptWriterFactory = javascriptWriterFactory;
            _stringBuilderFactory    = stringBuilderFactory;

            _elementsAddedToWebsite = new HashSet <string>();
            _elementsAddedToModule  = dictionaryFactory.Create <string, HashSet <string> >();
            _elementsAddedToPage    = dictionaryFactory.Create <string, HashSet <string> >();

            _moduleStyles    = dictionaryFactory.Create <string, string>();
            _moduleFunctions = dictionaryFactory.Create <string, string>();
            _pageStyles      = dictionaryFactory.Create <string, string>();
            _pageFunctions   = dictionaryFactory.Create <string, string>();

            _websiteStylesBuilder    = stringBuilderFactory.Create();
            _websiteFunctionsBuilder = stringBuilderFactory.Create();

            _moduleStyleBuilders    = dictionaryFactory.Create <string, IStringBuilder>();
            _moduleFunctionBuilders = dictionaryFactory.Create <string, IStringBuilder>();
            _pageStyleBuilders      = dictionaryFactory.Create <string, IStringBuilder>();
            _pageFunctionBuilders   = dictionaryFactory.Create <string, IStringBuilder>();

            frameworkConfiguration.Subscribe(config =>
            {
                var rootPath = config.AssetRootPath;
                if (rootPath.EndsWith("/") && rootPath.Length > 1)
                {
                    rootPath = rootPath.Substring(0, rootPath.Length - 1);
                }
                _rootPath = new PathString(rootPath);

                var priorRegistration = _runableRegistration;

                _runableRegistration = requestRouter.Register(this,
                                                              new FilterAllFilters(
                                                                  new FilterByMethod(Method.Get),
                                                                  new FilterByPath(_rootPath.Value + "/**")), -10);

                if (priorRegistration != null)
                {
                    priorRegistration.Dispose();
                }
            });
        }
Esempio n. 15
0
        public DataContext(
            IDictionaryFactory dictionaryFactory,
            DataContextFactory dataContextFactory,
            IDataDependencyFactory dataDependencyFactory,
            IIdManager idManager)
        {
            _dataContextFactory    = dataContextFactory;
            _dataDependencyFactory = dataDependencyFactory;
            _properties            = new System.Collections.Generic.LinkedList <PropertyEntry>();
#if DEBUG
            _id = idManager.GetUniqueId();
#endif
        }
Esempio n. 16
0
 public RenderContext(
     IAssetManager assetManager,
     IHtmlWriter htmlWriter,
     IDictionaryFactory dictionaryFactory,
     IStringBuilderFactory stringBuilderFactory,
     Action <IOwinContext, Func <string> > trace)
 {
     _assetManager         = assetManager;
     _stringBuilderFactory = stringBuilderFactory;
     _trace        = trace;
     _dataContexts = dictionaryFactory.Create <int, IDataContext>();
     Html          = htmlWriter;
 }
 public RenderContextFactory(
     IAssetManager assetManager,
     IHtmlWriterFactory htmlWriterFactory,
     IHtmlConfiguration htmlConfiguration,
     IDictionaryFactory dictionaryFactory,
     IStringBuilderFactory stringBuilderFactory)
 {
     _assetManager         = assetManager;
     _htmlWriterFactory    = htmlWriterFactory;
     _htmlConfiguration    = htmlConfiguration;
     _dictionaryFactory    = dictionaryFactory;
     _stringBuilderFactory = stringBuilderFactory;
 }
Esempio n. 18
0
        /// <summary>
        /// Automatically loads dictionary files based on folder structure in basePath (specified in library config).
        /// </summary>
        /// <param name="dictionaryFactory">Dictionary factory.</param>
        private void AutoLoadDictionaries(IDictionaryFactory dictionaryFactory)
        {
            var localizationFilesToLoad = CheckResourceFiles(m_configuration, dictionaryFactory);

            foreach (var loadedDictionary in localizationFilesToLoad)
            {
                AddDictionaryToHierarchyTreesWithoutBuildTree(dictionaryFactory.CreateDictionary(loadedDictionary));
            }

            CheckGlobalScopeAvailabilityInAllCulture();

            BuildDictionaryHierarchyTrees();
        }
Esempio n. 19
0
        public DataContextFactory(
            IQueueFactory queueFactory,
            IDictionaryFactory dictionaryFactory,
            IDataDependencyFactory dataDependencyFactory,
            IIdManager idManager)
            : base(queueFactory)
        {
            _dictionaryFactory     = dictionaryFactory;
            _dataDependencyFactory = dataDependencyFactory;
            _idManager             = idManager;

            Initialize(100);
        }
Esempio n. 20
0
        IDictionaryFactory DictionaryFactoryInstance;         // real new or old service factory

        public DictionaryFactory()
        {
            if (ServiceFacade.UseRemoteServices)
            {
                //Mobius.Data.DictionaryMx expects to be used to maintain a local cache and
                // the individual "gets" require that DictionaryMx.Dictionaries isn't null
                // but the caller of "Dictionary<string, DictionaryMx> GetDictionaryMetaData()"
                // is expected to take care of this
            }
            else
            {
                DictionaryFactoryInstance = new MetaFactoryNamespace.DictionaryFactory();
            }
        }
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="T:CSF.FlexDi.Resolution.Proxies.NamedInstanceDictionaryResolverProxy"/> class.
        /// </summary>
        /// <param name="proxiedResolver">Proxied resolver.</param>
        /// <param name="registrationAccessor">Registration accessor.</param>
        /// <param name="dictionaryFactory">Dictionary factory.</param>
        public NamedInstanceDictionaryResolverProxy(IResolver proxiedResolver,
                                                    IServiceRegistrationProvider registrationAccessor,
                                                    IDictionaryFactory dictionaryFactory) : base(proxiedResolver)
        {
            if (dictionaryFactory == null)
            {
                throw new ArgumentNullException(nameof(dictionaryFactory));
            }
            if (registrationAccessor == null)
            {
                throw new ArgumentNullException(nameof(registrationAccessor));
            }

            this.registrationAccessor = registrationAccessor;
            this.dictionaryFactory    = dictionaryFactory;
        }
        public void Resolve_uses_proxied_resolver_for_non_dictionary_types([Frozen, ResolvesToFailure] IResolver proxiedResolver,
                                                                           [Frozen] IDictionaryFactory dictionaryFactory,
                                                                           NamedInstanceDictionaryResolverProxy sut,
                                                                           ResolutionRequest request)
        {
            // Arrange
            Mock.Get(dictionaryFactory)
            .Setup(x => x.IsGenericDictionaryType(request.ServiceType))
            .Returns(false);

            // Act
            var result = sut.Resolve(request);

            // Assert
            Mock.Get(proxiedResolver).Verify(x => x.Resolve(request), Times.Once);
            Mock.Get(proxiedResolver).Verify(x => x.Resolve(It.Is <ResolutionRequest>(r => r != request)), Times.Never);
        }
Esempio n. 23
0
        public void Setup()
        {
            _dictionaryFactory = Activator.CreateInstance(DictionaryFactoryType) as IDictionaryFactory;
            _propertyBag       = Activator.CreateInstance(ProperyBagType, _dictionaryFactory) as IPropertyBag;

            _random = new Random(1000);

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Int{i}", 0);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Bool{i}", false);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Ref{i}", new object());
            }
        }
Esempio n. 24
0
        private static void ConfigureLocalizationInModule(
            this IFileDictionaryManager localization,
            IDictionaryFactory dictionaryFactory,
            ModuleContext moduleContext
            )
        {
            var localizationFiles = moduleContext.LibModuleInfo.GetLocalizationFiles(moduleContext.Assembly);

            if (localizationFiles == null)
            {
                return;
            }
            foreach (var localizationFile in localizationFiles)
            {
                using (var stream = localizationFile.FileStream)
                {
                    localization.AddDictionaryToHierarchyTrees(
                        dictionaryFactory.CreateDictionary(stream)
                        );
                }
            }
        }
Esempio n. 25
0
 public LayoutDependencies(
     IDictionaryFactory dictionaryFactory)
 {
     DictionaryFactory = dictionaryFactory;
 }
Esempio n. 26
0
 public void AddSingleDictionary(IDictionaryFactory dictionaryFactory, Stream resourceStream)
 {
     m_dictionaryManager.AddSingleDictionary(dictionaryFactory, resourceStream);
 }
Esempio n. 27
0
 public void AddSingleDictionary(IDictionaryFactory dictionaryFactory, string filePath)
 {
     m_dictionaryManager.AddSingleDictionary(dictionaryFactory, filePath);
 }
Esempio n. 28
0
 public void Setup()
 {
     _dictionaryFactory = Activator.CreateInstance(DictionaryFactoryType) as IDictionaryFactory;
     _propertyBag       = Activator.CreateInstance(ProperyBagType, _dictionaryFactory) as IPropertyBag;
 }
Esempio n. 29
0
        /// <summary>
        /// Check for resource files base on folders structure in basePath.
        /// </summary>
        /// <param name="configuration">Library configuration.</param>
        /// <param name="dictionaryFactory"></param>
        /// <returns>List of resource files to load.</returns>
        private IEnumerable <string> CheckResourceFiles(LocalizationConfiguration configuration, IDictionaryFactory dictionaryFactory)
        {
            var fs = new FolderScanner(dictionaryFactory);

            return(fs.CheckResourceFiles(configuration));
        }
Esempio n. 30
0
 public void Setup()
 {
     _dictionaryFactory = Activator.CreateInstance(DictionaryFactoryType) as IDictionaryFactory;
 }
Esempio n. 31
0
 public FolderScanner(IDictionaryFactory dictionaryFactory, ILogger <FolderScanner> logger = null)
 {
     m_dictionaryFactory = dictionaryFactory;
     m_logger            = logger;
 }