Exemple #1
0
            public override void Put(ResourceKey key, ResourceValue value, bool noFallback)
            {
                IResourceTable contextsTable = value.GetTable();

                for (int i = 0; contextsTable.GetKeyAndValue(i, key, value); ++i)
                {
                    if (!contextUsageTypeMap.TryGetValue(key.ToString(), out CapitalizationContextUsage usage))
                    {
                        continue;
                    }


                    int[] intVector = value.GetInt32Vector();
                    if (intVector.Length < 2)
                    {
                        continue;
                    }

                    int titlecaseInt = (dataTableCultureDisplayNames.displayContextOptions.Capitalization == Capitalization.UIListOrMenu)
                            ? intVector[0] : intVector[1];
                    if (titlecaseInt == 0)
                    {
                        continue;
                    }

                    dataTableCultureDisplayNames.capitalizationUsage[(int)usage] = true;
                    hasCapitalizationUsage = true;
                }
            }
Exemple #2
0
        public LongUriResource(IResourceTable resourceTable, byte[] data)
        {
            _resourceTable = resourceTable;
            var prefixLength = (int)data[1];

            _valuePage    = BitConverter.ToUInt64(data, 2);
            _valueSegment = data[10];
            _prefix       = Encoding.UTF8.GetString(data, 11, prefixLength);
        }
 public LongLiteralResource(IResourceTable resourceTable, byte[] data)
 {
     _langCodeId = BitConverter.ToUInt64(data, 1);
     _dataTypeId = BitConverter.ToUInt64(data, 9);
     _valuePage = BitConverter.ToUInt64(data, 17);
     _valueSegment = data[25];
     var prefixLength = (int) data[26];
     _prefix = Encoding.UTF8.GetString(data, 27, prefixLength);
     _resourceTable = resourceTable;
 }
Exemple #4
0
 public Store(string storeLocation, IPageStore dataPageStore, IResourceTable resourceTable)
 {
     DirectoryPath = storeLocation;
     _pageStore    = dataPageStore;
     _graphIndex   = new ConcurrentGraphIndex(_pageStore);
     _subjectRelatedResourceIndex = new RelatedResourceIndex.RelatedResourceIndex(_currentTxnId + 1, _pageStore);
     _objectRelatedResourceIndex  = new RelatedResourceIndex.RelatedResourceIndex(_currentTxnId + 1, _pageStore);
     _prefixManager = new PrefixManager(_pageStore);
     _resourceTable = resourceTable;
     _resourceIndex = new ResourceIndex.ResourceIndex(1, _pageStore, _resourceTable);
 }
Exemple #5
0
 public Store(string storeLocation, IPageStore dataPageStore, IResourceTable resourceTable, ulong storePageId, BrightstarProfiler profiler)
 {
     using (profiler.Step("Load Store"))
     {
         DirectoryPath  = storeLocation;
         _pageStore     = dataPageStore;
         _resourceTable = resourceTable;
         var storePage = _pageStore.Retrieve(storePageId, profiler);
         Load(storePage, profiler);
     }
 }
Exemple #6
0
 public Store(string storeLocation, IPageStore dataPageStore, IResourceTable resourceTable, ulong storePageId, BrightstarProfiler profiler)
 {
     using (profiler.Step("Load Store"))
     {
         DirectoryPath = storeLocation;
         _pageStore = dataPageStore;
         _resourceTable = resourceTable;
         var storePage = _pageStore.Retrieve(storePageId, profiler);
         Load(storePage, profiler);
     }
 }
Exemple #7
0
 public Store(string storeLocation, IPageStore dataPageStore, IResourceTable resourceTable)
 {
     DirectoryPath = storeLocation;
     _pageStore = dataPageStore;
     _graphIndex = new ConcurrentGraphIndex(_pageStore);
     _subjectRelatedResourceIndex = new RelatedResourceIndex.RelatedResourceIndex(_currentTxnId + 1, _pageStore);
     _objectRelatedResourceIndex = new RelatedResourceIndex.RelatedResourceIndex(_currentTxnId + 1, _pageStore);
     _prefixManager = new PrefixManager(_pageStore);
     _resourceTable = resourceTable;
     _resourceIndex = new ResourceIndex.ResourceIndex(1, _pageStore, _resourceTable);
 }
Exemple #8
0
        public LongLiteralResource(IResourceTable resourceTable, byte[] data)
        {
            _langCodeId   = BitConverter.ToUInt64(data, 1);
            _dataTypeId   = BitConverter.ToUInt64(data, 9);
            _valuePage    = BitConverter.ToUInt64(data, 17);
            _valueSegment = data[25];
            var prefixLength = (int)data[26];

            _prefix        = Encoding.UTF8.GetString(data, 27, prefixLength);
            _resourceTable = resourceTable;
        }
Exemple #9
0
        /// <summary>
        /// Creates a new empty resource index in the specified page store
        /// </summary>
        /// <param name="txnId"></param>
        /// <param name="pageStore"></param>
        /// <param name="resourceTable"></param>
        public ResourceIndex(ulong txnId, IPageStore pageStore, IResourceTable resourceTable)  : base(txnId, pageStore)
        {
            //_resourceCache = new ConcurrentResourceCache();
            //_resourceIdCache = new ConcurrentResourceIdCache();
            _resourceCache   = new LruResourceCache();
            _resourceIdCache = new LruResourceIdCache();
            _resourceStore   = new ResourceStore(resourceTable);
#if DEBUG_BTREE
            Configuration.DebugId = "ResIx";
            Logging.LogDebug("Created new {0} BTree with root page {1}", Configuration.DebugId, RootId);
#endif
        }
        /// <summary>
        /// Opens an existing resource index from the specified page store
        /// </summary>
        /// <param name="pageStore"></param>
        /// <param name="resourceTable">The table used to store long resource strings</param>
        /// <param name="rootNodeId">The ID of the page that contains the root node of the resource index</param>
        public ResourceIndex(IPageStore pageStore, IResourceTable resourceTable, ulong rootNodeId) : base(pageStore, rootNodeId)
        {
            //_resourceCache = new ConcurrentResourceCache();
            //_resourceIdCache = new ConcurrentResourceIdCache();
            _resourceCache= new LruResourceCache();
            _resourceIdCache = new LruResourceIdCache();
            _resourceStore = new ResourceStore(resourceTable);
#if DEBUG_BTREE
            Configuration.DebugId = "ResIx";
            Logging.LogDebug("Opened new {0} BTree with root page {1}", Configuration.DebugId, rootNodeId);
#endif
        }
        /// <summary>
        /// Creates a new empty resource index in the specified page store
        /// </summary>
        /// <param name="txnId"></param>
        /// <param name="pageStore"></param>
        /// <param name="resourceTable"></param>
        public ResourceIndex(ulong txnId, IPageStore pageStore, IResourceTable resourceTable)  : base(txnId, pageStore)
        {
            //_resourceCache = new ConcurrentResourceCache();
            //_resourceIdCache = new ConcurrentResourceIdCache();
            _resourceCache = new LruResourceCache();
            _resourceIdCache = new LruResourceIdCache();
            _resourceStore = new ResourceStore(resourceTable);
#if DEBUG_BTREE
            Configuration.DebugId = "ResIx";
            Logging.LogDebug("Created new {0} BTree with root page {1}", Configuration.DebugId, RootId);
#endif
        }
Exemple #12
0
                /// <summary>
                ///  Currencies%variant{
                ///      TRY{"TL"}
                ///  }
                /// </summary>
                internal void ConsumeCurrenciesVariantTable(ResourceKey key, ResourceValue value)
                {
                    // Note: This data is used for parsing but not formatting.
                    Debug.Assert(parsingData != null);
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        string isoCode = key.ToString();
                        parsingData.symbolToIsoCode[value.GetString()] = isoCode;
                    }
                }
Exemple #13
0
        /// <summary>
        /// Opens an existing resource index from the specified page store
        /// </summary>
        /// <param name="pageStore"></param>
        /// <param name="resourceTable">The table used to store long resource strings</param>
        /// <param name="rootNodeId">The ID of the page that contains the root node of the resource index</param>
        public ResourceIndex(IPageStore pageStore, IResourceTable resourceTable, ulong rootNodeId) : base(pageStore, rootNodeId)
        {
            //_resourceCache = new ConcurrentResourceCache();
            //_resourceIdCache = new ConcurrentResourceIdCache();
            _resourceCache   = new LruResourceCache();
            _resourceIdCache = new LruResourceIdCache();
            _resourceStore   = new ResourceStore(resourceTable);
#if DEBUG_BTREE
            Configuration.DebugId = "ResIx";
            Logging.LogDebug("Opened new {0} BTree with root page {1}", Configuration.DebugId, rootNodeId);
#endif
        }
Exemple #14
0
                /// <summary>
                ///  CurrencyUnitPatterns{
                ///      other{"{0} {1}"}
                ///      ...
                ///  }
                /// </summary>
                internal void ConsumeCurrencyUnitPatternsTable(ResourceKey key, ResourceValue value)
                {
                    Debug.Assert(unitPatterns != null);
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        String pluralKeyword = key.ToString();
                        if (unitPatterns.Get(pluralKeyword) == null)
                        {
                            unitPatterns[pluralKeyword] = value.GetString();
                        }
                    }
                }
Exemple #15
0
        private void DoUpdate()
        {
            if (version.closed)
            {
                Debug.Log(version.closedReason);
                //TODO tip
                DoComplete(true);
                return;
            }

            if (!localVersion.baseVersion.Equals(version.baseVersion))
            {
                Reinstall();
                return;
            }

            LoaderMgr.baseUrl       = version.updateAddr;
            LoaderMgr.backupBaseUrl = version.updateAddr2;

            if (forceUpdateResource || !localVersion.lastVersion.Equals(version.lastVersion))
            {
                var bl = LoaderMgr.LoadBatch();
                bl.AddLoader(localResourceTablePath);
                bl.AddLoader(version.resourceTableAddr);
                bl.isCheckRedirectError = true;

                bl.onComplete += ld =>
                {
                    var localTxt = bl.GetLoader(localResourceTablePath).text;
                    resourceTableText  = bl.GetLoader(version.resourceTableAddr).text;
                    localResourceTable = new ResourceTableImpl();
                    resourceTable      = new ResourceTableImpl();

                    if (localResourceTable.Deserialize(localTxt) &&
                        resourceTable.Deserialize(resourceTableText))
                    {
                        UpdateResource();
                    }
                    else
                    {
                        //TODO tip
                        DoComplete(true);
                    }
                };
            }
            else
            {
                DoComplete();
            }
        }
Exemple #16
0
                /// <summary>
                ///  currencySpacing{
                ///      afterCurrency{
                ///          currencyMatch{"[:^S:]"}
                ///          insertBetween{" "}
                ///          surroundingMatch{"[:digit:]"}
                ///      }
                ///      beforeCurrency{
                ///          currencyMatch{"[:^S:]"}
                ///          insertBetween{" "}
                ///          surroundingMatch{"[:digit:]"}
                ///      }
                ///  }
                /// </summary>
                internal void ConsumeCurrencySpacingTable(ResourceKey key, ResourceValue value)
                {
                    Debug.Assert(spacingInfo != null);
                    IResourceTable spacingTypesTable = value.GetTable();

                    for (int i = 0; spacingTypesTable.GetKeyAndValue(i, key, value); ++i)
                    {
                        CurrencySpacingInfo.SpacingType type;
                        if (key.ContentEquals("beforeCurrency"))
                        {
                            type = CurrencySpacingInfo.SpacingType.Before;
                            spacingInfo.HasBeforeCurrency = true;
                        }
                        else if (key.ContentEquals("afterCurrency"))
                        {
                            type = CurrencySpacingInfo.SpacingType.After;
                            spacingInfo.HasAfterCurrency = true;
                        }
                        else
                        {
                            continue;
                        }

                        IResourceTable patternsTable = value.GetTable();
                        for (int j = 0; patternsTable.GetKeyAndValue(j, key, value); ++j)
                        {
                            CurrencySpacingInfo.SpacingPattern pattern;
                            if (key.ContentEquals("currencyMatch"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.CurrencyMatch;
                            }
                            else if (key.ContentEquals("surroundingMatch"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.SurroundingMatch;
                            }
                            else if (key.ContentEquals("insertBetween"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.InsertBetween;
                            }
                            else
                            {
                                continue;
                            }

                            spacingInfo.SetSymbolIfNull(type, pattern, value.GetString());
                        }
                    }
                }
Exemple #17
0
                internal void ConsumeCurrencyPluralsEntry(ResourceKey key, ResourceValue value)
                {
                    Debug.Assert(pluralsData != null);
                    IResourceTable pluralsTable = value.GetTable();

                    for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++)
                    {
                        StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString());
                        if (plural == null)
                        {
                            throw new ICUException("Could not make StandardPlural from keyword " + key);
                        }

                        if (pluralsData[1 + (int)plural] == null)
                        {
                            pluralsData[1 + (int)plural] = value.GetString();
                        }
                    }
                }
Exemple #18
0
                private void ConsumeTopTable(ResourceKey key, ResourceValue value)
                {
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        if (key.ContentEquals("Currencies"))
                        {
                            ConsumeCurrenciesTable(key, value);
                        }
                        else if (key.ContentEquals("Currencies%variant"))
                        {
                            ConsumeCurrenciesVariantTable(key, value);
                        }
                        else if (key.ContentEquals("CurrencyPlurals"))
                        {
                            ConsumeCurrencyPluralsTable(key, value);
                        }
                    }
                }
Exemple #19
0
                /// <summary>
                ///  Currencies{
                ///      ...
                ///      USD{
                ///          "US$",        => symbol
                ///          "US Dollar",  => display name
                ///      }
                ///      ...
                ///      ESP{
                ///          "₧",                  => symbol
                ///          "pesseta espanyola",  => display name
                ///          {
                ///              "¤ #,##0.00",     => currency-specific pattern
                ///              ",",              => currency-specific grouping separator
                ///              ".",              => currency-specific decimal separator
                ///          }
                ///      }
                ///      ...
                ///  }
                /// </summary>
                internal void ConsumeCurrenciesTable(ResourceKey key, ResourceValue value)
                {
                    // The full Currencies table is consumed for parsing only.
                    Debug.Assert(parsingData != null);
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        string isoCode = key.ToString();
                        if (value.Type != UResourceType.Array)
                        {
                            throw new ICUException("Unexpected data type in Currencies table for " + isoCode);
                        }
                        IResourceArray array = value.GetArray();

                        parsingData.symbolToIsoCode[isoCode] = isoCode; // Add the ISO code itself as a symbol
                        array.GetValue(0, value);
                        parsingData.symbolToIsoCode[value.GetString()] = isoCode;
                        array.GetValue(1, value);
                        parsingData.nameToIsoCode[value.GetString()] = isoCode;
                    }
                }
Exemple #20
0
                /// <summary>
                ///  CurrencyPlurals{
                ///      BYB{
                ///          one{"Belarusian new rouble (1994–1999)"}
                ///          other{"Belarusian new roubles (1994–1999)"}
                ///      }
                ///      ...
                ///  }
                /// </summary>
                internal void ConsumeCurrencyPluralsTable(ResourceKey key, ResourceValue value)
                {
                    // The full CurrencyPlurals table is consumed for parsing only.
                    Debug.Assert(parsingData != null);
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        string         isoCode      = key.ToString();
                        IResourceTable pluralsTable = value.GetTable();
                        for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++)
                        {
                            StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString());
                            if (plural == null)
                            {
                                throw new ICUException("Could not make StandardPlural from keyword " + key);
                            }

                            parsingData.nameToIsoCode[value.GetString()] = isoCode;
                        }
                    }
                }
 public ResourceStore(IResourceTable resourceTable)
 {
     _resourceTable = resourceTable;
 }
Exemple #22
0
 public ResourceMgrImpl()
 {
     resourceTable = new ResourceTableImpl();
 }
Exemple #23
0
 public ResourceMgrImpl(IResourceTable table)
 {
     resourceTable = table;
 }
Exemple #24
0
 /// <summary>
 /// Opens an existing resource index from the specified page store
 /// </summary>
 /// <param name="pageStore"></param>
 /// <param name="resourceTable">The table used to store long resource strings</param>
 /// <param name="rootNodeId">The ID of the page that contains the root node of the resource index</param>
 public ResourceIndex(IPageStore pageStore, IResourceTable resourceTable, ulong rootNodeId) : base(pageStore, rootNodeId)
 {
     _resourceCache   = new ConcurrentResourceCache();
     _resourceIdCache = new ConcurrentResourceIdCache();
     _resourceStore   = new ResourceStore(resourceTable);
 }
Exemple #25
0
 public ResourceStore(IResourceTable resourceTable)
 {
     _resourceTable = resourceTable;
 }
 /// <summary>
 /// Opens an existing resource index from the specified page store
 /// </summary>
 /// <param name="pageStore"></param>
 /// <param name="resourceTable">The table used to store long resource strings</param>
 /// <param name="rootNodeId">The ID of the page that contains the root node of the resource index</param>
 public ResourceIndex(IPageStore pageStore, IResourceTable resourceTable, ulong rootNodeId) : base(pageStore, rootNodeId)
 {
     _resourceCache = new ConcurrentResourceCache();
     _resourceIdCache = new ConcurrentResourceIdCache();
     _resourceStore = new ResourceStore(resourceTable);
 }