private async Task RefreshPropertiesAsync()
        {
            try
            {
                IsBusy = true;
                var result = await _searchService.FindProperties(_navigationParams.location, _navigationParams.toLet);

                _currentPage = result.MetaData.PageNumber;
                _hasNextPage = result.MetaData.HasNextPage;
                _total       = result.MetaData.TotalItemCount;

                PropertiesList.Clear();
                foreach (var property in result.Properties)
                {
                    PropertiesList.Add(property);
                }

                UpdateDisplyingDescription();

                if (_isInitialised == false)
                {
                    _isInitialised = true;
                }
            }
            catch (Exception exc)
            {
                _log.ErrorException("An error has occurred while trying to get search results", exc);
                await _useDialogs.AlertAsync("An error has occurred. Please try again.");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        private async Task LoadMorePropertiesAsync(SearchPropertyResult searchPropertyResult)
        {
            if (searchPropertyResult == null)
            {
                return;
            }

            if (PropertiesList[PropertiesList.Count - 1] == searchPropertyResult && _hasNextPage)
            {
                await Task.Delay(1000);//Only required to be able to view ActivityIndicator in the footer.

                LoadingNextPage = true;
            }

            if (LoadingNextPage == true)
            {
                var result = await _searchService.FindProperties(_locationPrompt, _toLet, _currentPage + 1);

                _currentPage = result.MetaData.PageNumber;
                _hasNextPage = result.MetaData.HasNextPage;

                foreach (var property in result.Properties)
                {
                    PropertiesList.Add(property);
                }

                UpdateDisplyingDescription();

                LoadingNextPage = false;
            }
        }
Exemple #3
0
        /// <summary>
        /// Displays a list of available values for the specified component than sets the value.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
        /// <param name="provider">A service provider object through which editing services may be obtained.</param>
        /// <param name="value">An instance of the value being edited.</param>
        /// <returns>The new value of the object. If the value of the object hasn't changed, this method should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                // This service is in charge of popping our ListBox.
                var service1 = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)));

                if (service1 != null)
                {
                    // This is an internal Microsoft class representing the PropertyGrid entry for our component.
                    if (provider.GetType().FullName == "System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry")
                    {
                        var list = new PropertiesList(context);
                        // Drop the list control.
                        service1.DropDownControl(list);

                        if (list.SelectedIndices.Count == 1)
                        {
                            value = list.SelectedItem.ToString();
                        }
                        // Close the list control after selection.
                        service1.CloseDropDown();
                    }
                }
            }

            return(value);
        }
Exemple #4
0
        /// <summary>
        /// Get after calculate properties list
        /// </summary>
        /// <returns></returns>
        public PropertiesList GetCurrentPropertiesList()
        {
            PropertiesList buffer = GetBasicWeaponProperties();

            buffer = GetUpgradeSet()[UpgradeLevel].Calculate(buffer);
            return(buffer);
        }
Exemple #5
0
        public void AddProperty(string key, PropertyInfoEx newProp)
        {
            var newIndex = PropertiesList.Count;

            newProp.propertyPositionIndex = (short)newIndex;
            PropertiesList.Add(newProp);
            this.Add(key, newIndex);
        }
        /// <summary>
        /// Update the required materials list.
        /// </summary>
        private void UpdateRequiredMaterialsList()
        {
            int scrollBarPosition = PropertiesList.GetVerticalScrollBarPosition();

            // Store the selected item (if any) to restore it after the update
            int selectedItem = PropertiesList.SelectedItems.Count > 0
                ? PropertiesList.SelectedItems[0].Tag.GetHashCode()
                : 0;

            PropertiesList.BeginUpdate();
            try
            {
                // Clear everything
                PropertiesList.Items.Clear();
                PropertiesList.Groups.Clear();
                PropertiesList.Columns.Clear();

                // Create the columns
                PropertiesList.Columns.Add("item", "Item");
                PropertiesList.Columns.Add("qBase", "Quantity (Base)");

                if (Character != null)
                {
                    PropertiesList.Columns.Add("quant", "Quantity (You)");
                }

                IEnumerable <ListViewItem> items = AddGroups();

                // Add the items
                PropertiesList.Items.AddRange(items.OrderBy(x => x.Text).ToArray());

                // Show/Hide the "no item required" label and autoresize the columns
                PropertiesList.Visible = PropertiesList.Items.Count > 0;

                if (PropertiesList.Items.Count > 0)
                {
                    AdjustColumns();
                }

                if (selectedItem <= 0)
                {
                    return;
                }

                // Restore the selected item (if any)
                foreach (ListViewItem lvItem in PropertiesList.Items.Cast <ListViewItem>().Where(
                             lvItem => lvItem.Tag.GetHashCode() == selectedItem))
                {
                    lvItem.Selected = true;
                }
            }
            finally
            {
                PropertiesList.EndUpdate();
                PropertiesList.SetVerticalScrollBarPosition(scrollBarPosition);
            }
        }
 private void UpdateDisplyingDescription()
 {
     if (PropertiesList.Any())
     {
         DisplayingDescription = $"Showing {PropertiesList.Count} of {_total} results";
     }
     else
     {
         DisplayingDescription = "No results found";
     }
 }
 public void AddName(object sender, RoutedEventArgs e)
 {
     try
     {
         PropertiesList newListItem = new PropertiesList();
         newListItem.PropID = EditingProperty.ID;
         newListItem.Value  = "";
         NameList.Add(newListItem);
         ListBoxNames.Items.Refresh();
         int ind = ListBoxNames.Items.Count - 1;
         ListBoxNames.SelectedIndex = ind;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка");
     }
 }
Exemple #9
0
        public void AddProperty(Property p)
        {
            if (PropertyById.ContainsKey(p.ID))
            {
                throw new InvalidOperationException(String.Format("Property with ID={0} already exists", p.ID));
            }
            if (PropertyByCompactId.ContainsKey(p.CompactID))
            {
                throw new InvalidOperationException(String.Format("Property with CompactID={0} already exists", p.ID));
            }

            PropertyById[p.ID] = p;
            PropertyByCompactId[p.CompactID] = p;

            PropertiesList.Add(p);
            p.Schema = this;
        }
Exemple #10
0
        public HierarchyNode()
        {
            Id = System.Threading.Interlocked.Increment(ref Counter);
            allItems.Add(this);
            Children   = new NotifyingList <HierarchyNode>();
            Properties = new PropertiesList();
            Commands   = new CommandsList(this);

            Children.ItemAdded += (s, a) =>
            {
                a.Item.Parent = this;
                this.NotifyChildAdded(a.Item);
            };
            Children.ItemRemoved += (s, a) =>
            {
                this.NotifyChildRemoved(a.Item);
                a.Item.Parent = null;
            };
        }
        private async Task LoadMorePropertiesAsync(SearchPropertyResult searchPropertyResult)
        {
            if (searchPropertyResult == null)
            {
                return;
            }

            if (PropertiesList[PropertiesList.Count - 1] == searchPropertyResult)
            {
                if (_hasNextPage)
                {
                    try
                    {
                        IsBusy = true;
                        var result = await _searchService.FindProperties(_navigationParams.location, _navigationParams.toLet, _currentPage + 1);

                        _currentPage = result.MetaData.PageNumber;
                        _hasNextPage = result.MetaData.HasNextPage;
                        _total       = result.MetaData.TotalItemCount;

                        foreach (var property in result.Properties)
                        {
                            PropertiesList.Add(property);
                        }

                        UpdateDisplyingDescription();
                    }
                    catch (Exception exc)
                    {
                        _log.ErrorException("An error has occurred while trying to get more results", exc);
                        await _useDialogs.AlertAsync("An error has occurred. Please try again.");
                    }
                    finally
                    {
                        IsBusy = false;
                    }
                }
            }
        }
        /// <summary>
        /// Displays a list of available values for the specified component than sets the value.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
        /// <param name="provider">A service provider object through which editing services may be obtained.</param>
        /// <param name="value">An instance of the value being edited.</param>
        /// <returns>The new value of the object. If the value of the object hasn't changed, this method should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                // This service is in charge of popping our ListBox.
                var service1 = ((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)));

                if (service1 != null)
                {
                    // This is an internal Microsoft class representing the PropertyGrid entry for our component.
                    if (provider.GetType().FullName == "System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry")
                    {
                        var list = new PropertiesList(context);
                        // Drop the list control.
                        service1.DropDownControl(list);

                        if (list.SelectedIndices.Count == 1)
                        {
                            value = list.SelectedItem.ToString();
                        }
                        // Close the list control after selection.
                        service1.CloseDropDown();
                    }
                }
            }

            return value;
        }
        private List <StiToken> PostProcessTokensList(List <StiToken> tokensList)
        {
            List <StiToken> newList = new List <StiToken>();

            tokenPos = 0;
            while (tokenPos < tokensList.Count)
            {
                StiToken token = tokensList[tokenPos];
                tokenPos++;
                if (token.Type == StiTokenType.Identifier)
                {
                    StiDataSource     ds  = report.Dictionary.DataSources[token.Value];
                    StiBusinessObject bos = report.Dictionary.BusinessObjects[token.Value];

                    #region check for DataSource field
                    if (ds != null)
                    {
                        StringBuilder fieldPath = new StringBuilder(StiNameValidator.CorrectName(token.Value));
                        while (tokenPos + 1 < tokensList.Count && tokensList[tokenPos].Type == StiTokenType.Dot)
                        {
                            token = tokensList[tokenPos + 1];
                            string nextName = StiNameValidator.CorrectName(token.Value);

                            StiDataRelation dr = GetDataRelationByName(nextName, ds);
                            if (dr != null)
                            {
                                ds        = dr.ParentSource;
                                tokenPos += 2;
                                fieldPath.Append(".");
                                fieldPath.Append(dr.NameInSource);
                                continue;
                            }
                            if (ds.Columns.Contains(nextName))
                            {
                                tokenPos += 2;
                                fieldPath.Append(".");
                                fieldPath.Append(nextName);
                                break;
                            }
                            foreach (StiDataColumn column in ds.Columns)
                            {
                                if (StiNameValidator.CorrectName(column.Name) == nextName)
                                {
                                    tokenPos += 2;
                                    fieldPath.Append(".");
                                    fieldPath.Append(column.NameInSource);
                                    break;
                                }
                            }

                            CheckDataSourceField(ds.Name, nextName);
                            tokenPos += 2;
                            fieldPath.Append(".");
                            fieldPath.Append(nextName);

                            //token = tokensList[tokenPos - 1];
                            break;
                        }
                        token.Type = StiTokenType.DataSourceField;
                        //надо оптимизировать и сохранять сразу массив строк !!!!!
                        token.Value = fieldPath.ToString();
                    }
                    #endregion

                    #region check for BusinessObject field
                    else if (bos != null)
                    {
                        StringBuilder fieldPath = new StringBuilder(token.Value);
                        while (tokenPos + 1 < tokensList.Count && tokensList[tokenPos].Type == StiTokenType.Dot)
                        //while (inputExpression[pos2] == '.')
                        {
                            token = tokensList[tokenPos + 1];
                            string nextName = token.Value;

                            if (bos.Columns.Contains(nextName))
                            {
                                tokenPos += 2;
                                fieldPath.Append(".");
                                fieldPath.Append(nextName);
                                break;
                            }
                            bos = bos.BusinessObjects[nextName];
                            if (bos != null)
                            {
                                tokenPos += 2;
                                fieldPath.Append(".");
                                fieldPath.Append(bos.Name);
                                continue;
                            }
                            break;
                        }
                        token.Type = StiTokenType.BusinessObjectField;
                        //надо оптимизировать и сохранять сразу массив строк !!!!!
                        token.Value = fieldPath.ToString();
                    }
                    #endregion

                    else if ((newList.Count > 0) && (newList[newList.Count - 1].Type == StiTokenType.Dot))
                    {
                        if (MethodsList.Contains(token.Value))
                        {
                            token.Type = StiTokenType.Method;
                        }
                        else if (PropertiesList.Contains(token.Value))
                        {
                            token.Type = StiTokenType.Property;
                        }
                        else
                        {
                            ThrowError(ParserErrorCode.FieldMethodOrPropertyNotFound, token, token.Value);
                        }
                    }

                    else if (TypesList.Contains(token.Value))
                    {
                        token.Type = StiTokenType.Cast;

                        if ((tokenPos + 1 < tokensList.Count) && (tokensList[tokenPos].Type == StiTokenType.Dot))
                        {
                            string tempName = token.Value + "." + tokensList[tokenPos + 1].Value;
                            if (FunctionsList.Contains(tempName))
                            {
                                token.Type  = StiTokenType.Function;
                                token.Value = tempName;
                                tokenPos   += 2;
                            }
                            if (SystemVariablesList.Contains(tempName))
                            {
                                token.Type  = StiTokenType.SystemVariable;
                                token.Value = tempName;
                                tokenPos   += 2;
                            }
                        }
                    }

                    else if (ComponentsList.Contains(token.Value))
                    {
                        token.Type = StiTokenType.Component;
                        if ((tokenPos + 1 < tokensList.Count) && (tokensList[tokenPos].Type == StiTokenType.Colon) && ComponentsList.Contains(tokensList[tokenPos + 1].Value))
                        {
                            StiComponent comp = (StiComponent)ComponentsList[tokensList[tokenPos + 1].Value];
                            if (comp != null && comp is StiDataBand)
                            {
                                token.Value = (comp as StiDataBand).DataSourceName;
                                token.Type  = StiTokenType.DataSourceField;
                                tokenPos   += 2;
                            }
                        }
                    }

                    else if (FunctionsList.Contains(token.Value))
                    {
                        while ((StiFunctionType)FunctionsList[token.Value] == StiFunctionType.NameSpace)
                        {
                            if (tokenPos + 1 >= tokensList.Count)
                            {
                                ThrowError(ParserErrorCode.UnexpectedEndOfExpression);
                            }
                            token.Value += "." + tokensList[tokenPos + 1].Value;
                            tokenPos    += 2;
                            if (!FunctionsList.Contains(token.Value))
                            {
                                ThrowError(ParserErrorCode.FunctionNotFound, token, token.Value);
                            }
                        }
                        token.Type = StiTokenType.Function;
                    }

                    else if (SystemVariablesList.Contains(token.Value) && (token.Value != "value" || component is Stimulsoft.Report.CrossTab.StiCrossCell))
                    {
                        token.Type = StiTokenType.SystemVariable;
                    }

                    //else if (token.Value.ToLowerInvariant() == "true" || token.Value.ToLowerInvariant() == "false")
                    //{
                    //    if (token.Value.ToLowerInvariant() == "true")
                    //        token.ValueObject = true;
                    //    else
                    //        token.ValueObject = false;
                    //    token.Type = StiTokenType.Number;
                    //}
                    //else if (token.Value.ToLowerInvariant() == "null")
                    //{
                    //    token.ValueObject = null;
                    //    token.Type = StiTokenType.Number;
                    //}

                    else if (ConstantsList.Contains(token.Value))
                    {
                        while (ConstantsList[token.Value] == namespaceObj)
                        {
                            if (tokenPos + 1 >= tokensList.Count)
                            {
                                ThrowError(ParserErrorCode.UnexpectedEndOfExpression);
                            }
                            string oldTokenValue = token.Value;
                            token.Value += "." + tokensList[tokenPos + 1].Value;
                            tokenPos    += 2;
                            if (!ConstantsList.Contains(token.Value))
                            {
                                ThrowError(ParserErrorCode.ItemDoesNotContainDefinition, token, oldTokenValue, tokensList[tokenPos + 1].Value);
                            }
                        }
                        token.ValueObject = ConstantsList[token.Value];
                        token.Type        = StiTokenType.Number;
                    }

                    else if (report.Dictionary.Variables.Contains(token.Value))
                    {
                        token.Type = StiTokenType.Variable;
                    }
                    else if (token.Value == "or" || token.Value == "and" || token.Value == "not")
                    {
                        if (token.Value == "or")
                        {
                            token.Type = StiTokenType.DoubleOr;
                        }
                        if (token.Value == "and")
                        {
                            token.Type = StiTokenType.DoubleAnd;
                        }
                        if (token.Value == "not")
                        {
                            token.Type = StiTokenType.Not;
                        }
                    }
                    else
                    {
                        if ((tokenPos < tokensList.Count) && (tokensList[tokenPos].Type != StiTokenType.Dot) || (tokenPos == tokensList.Count))
                        {
                            CheckDataSourceField(defaultDataSourceName, token.Value);

                            token.Type  = StiTokenType.DataSourceField;
                            token.Value = defaultDataSourceName + "." + token.Value;
                        }
                        else
                        {
                            if ((tokenPos + 1 < tokensList.Count) && (tokensList[tokenPos].Type == StiTokenType.Dot))
                            {
                                CheckDataSourceField(token.Value, tokensList[tokenPos + 1].Value);

                                token.Type  = StiTokenType.DataSourceField;
                                token.Value = token.Value + "." + tokensList[tokenPos + 1].Value;
                                tokenPos   += 2;
                            }
                            else
                            {
                                ThrowError(ParserErrorCode.NameDoesNotExistInCurrentContext, token, token.Value);
                            }
                        }
                    }
                }
                newList.Add(token);
            }
            return(newList);
        }
        /// <summary>
        /// Initialises the dataset <see cref="DataSet"/> using the source of the data set.
        /// </summary>
        /// <para>
        /// A <see cref="DataSet"/> is initialised using the reader to retrieve 
        /// entity information. The data is only loaded when required by the detection
        /// process.
        /// </para>
        /// <param name="dataSet">A data set to be initialised ready for detection</param>
        private static void Load(DataSet dataSet)
        {
            var reader = dataSet.Pool.GetReader();
            try
            {
                reader.BaseStream.Position = 0;
                CommonFactory.LoadHeader(dataSet, reader);
                dataSet.Strings = new VariableList<AsciiString<Entities.DataSet>, DataSet>(
                    dataSet, reader, new StreamAsciiStringFactory(), Constants.StringsCacheSize);
                MemoryFixedList<Component, Entities.DataSet> components = null;
                switch (dataSet.VersionEnum)
                {
                    case BinaryConstants.FormatVersions.PatternV31:
                        components = new MemoryFixedList<Component, Entities.DataSet>(dataSet, reader, new ComponentFactoryV31());
                        break;
                    case BinaryConstants.FormatVersions.PatternV32:
                        components = new MemoryFixedList<Component, Entities.DataSet>(dataSet, reader, new ComponentFactoryV32());
                        break;
                }
                dataSet._components = components;
                var maps = new MemoryFixedList<Map, Entities.DataSet>(dataSet, reader, new MapFactory());
                dataSet._maps = maps;
                var properties = new PropertiesList(dataSet, reader, new PropertyFactory());
                dataSet._properties = properties;
                dataSet._values = new FixedCacheList<Value, DataSet>(dataSet, reader, new ValueFactory<DataSet>(), Constants.ValuesCacheSize);
                dataSet.Profiles = new VariableList<Entities.Profile, DataSet>(dataSet, reader, new ProfileStreamFactory(dataSet.Pool), Constants.ProfilesCacheSize);
                switch (dataSet.VersionEnum)
                {
                    case BinaryConstants.FormatVersions.PatternV31:
                        dataSet._signatures = new FixedCacheList<Signature, DataSet>(dataSet, reader, new SignatureFactoryV31<DataSet>(dataSet), Constants.SignaturesCacheSize);
                        break;
                    case BinaryConstants.FormatVersions.PatternV32:
                        dataSet._signatures = new FixedCacheList<Signature, DataSet>(dataSet, reader, new SignatureFactoryV32<DataSet>(dataSet), Constants.SignaturesCacheSize);
                        dataSet._signatureNodeOffsets = new IntegerList(dataSet, reader);
                        dataSet._nodeRankedSignatureIndexes = new IntegerList(dataSet, reader);
                        break;
                }
                dataSet._rankedSignatureIndexes = new IntegerList(dataSet, reader);
                switch (dataSet.VersionEnum)
                {
                    case BinaryConstants.FormatVersions.PatternV31:
                        dataSet.Nodes = new VariableList<Entities.Node, DataSet>(dataSet, reader, new NodeStreamFactoryV31(dataSet.Pool), Constants.NodesCacheSize);
                        break;
                    case BinaryConstants.FormatVersions.PatternV32:
                        dataSet.Nodes = new VariableList<Entities.Node, DataSet>(dataSet, reader, new NodeStreamFactoryV32(dataSet.Pool), Constants.NodesCacheSize);
                        break;
                }
                var rootNodes = new MemoryFixedList<Entities.Node, Entities.DataSet>(dataSet, reader, new RootNodeFactory());
                dataSet.RootNodes = rootNodes;
                var profileOffsets = new MemoryFixedList<ProfileOffset, Entities.DataSet>(dataSet, reader, new ProfileOffsetFactory());
                dataSet._profileOffsets = profileOffsets;

                // Read into memory all the small lists which are frequently accessed.
                reader.BaseStream.Position = components.Header.StartPosition;
                components.Read(reader);
                reader.BaseStream.Position = maps.Header.StartPosition;
                maps.Read(reader);
                reader.BaseStream.Position = properties.Header.StartPosition;
                properties.Read(reader);
                reader.BaseStream.Position = rootNodes.Header.StartPosition;
                rootNodes.Read(reader);
                reader.BaseStream.Position = profileOffsets.Header.StartPosition;
                profileOffsets.Read(reader);
            }
            finally
            {
                dataSet.Pool.Release(reader);
            }
        }
Exemple #15
0
        /// <summary>
        /// Initialises the dataset <see cref="DataSet"/> using the source of the data set.
        /// </summary>
        /// <para>
        /// A <see cref="DataSet"/> is initialised using the reader to retrieve
        /// entity information. The data is only loaded when required by the detection
        /// process.
        /// </para>
        /// <param name="dataSet">A data set to be initialised ready for detection</param>
        private static void Load(DataSet dataSet)
        {
            var reader = dataSet.Pool.GetReader();

            try
            {
                reader.BaseStream.Position = 0;
                CommonFactory.LoadHeader(dataSet, reader);
                dataSet.Strings = new VariableList <AsciiString>(dataSet, reader, new AsciiStringFactory(), Constants.StringsCacheSize);
                MemoryFixedList <Component> components = null;
                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    components = new MemoryFixedList <Component>(dataSet, reader, new ComponentFactoryV31());
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    components = new MemoryFixedList <Component>(dataSet, reader, new ComponentFactoryV32());
                    break;
                }
                dataSet._components = components;
                var maps = new MemoryFixedList <Map>(dataSet, reader, new MapFactory());
                dataSet._maps = maps;
                var properties = new PropertiesList(dataSet, reader, new PropertyFactory());
                dataSet._properties = properties;
                dataSet._values     = new FixedCacheList <Value>(dataSet, reader, new ValueFactory(), Constants.ValuesCacheSize);
                dataSet.Profiles    = new VariableList <Entities.Profile>(dataSet, reader, new ProfileStreamFactory(dataSet.Pool), Constants.ProfilesCacheSize);
                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    dataSet._signatures = new FixedCacheList <Signature>(dataSet, reader, new SignatureFactoryV31(dataSet), Constants.SignaturesCacheSize);
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    dataSet._signatures                 = new FixedCacheList <Signature>(dataSet, reader, new SignatureFactoryV32(dataSet), Constants.SignaturesCacheSize);
                    dataSet._signatureNodeOffsets       = new FixedList <Integer>(dataSet, reader, new IntegerFactory());
                    dataSet._nodeRankedSignatureIndexes = new FixedList <Integer>(dataSet, reader, new IntegerFactory());
                    break;
                }
                dataSet._rankedSignatureIndexes = new FixedCacheList <Integer>(
                    dataSet, reader, new IntegerFactory(), Constants.RankedSignaturesCacheSize);
                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    dataSet.Nodes = new VariableList <Entities.Node>(dataSet, reader, new NodeStreamFactoryV31(dataSet.Pool), Constants.NodesCacheSize);
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    dataSet.Nodes = new VariableList <Entities.Node>(dataSet, reader, new NodeStreamFactoryV32(dataSet.Pool), Constants.NodesCacheSize);
                    break;
                }
                var rootNodes = new MemoryFixedList <Entities.Node>(dataSet, reader, new RootNodeFactory());
                dataSet.RootNodes = rootNodes;
                var profileOffsets = new MemoryFixedList <ProfileOffset>(dataSet, reader, new ProfileOffsetFactory());
                dataSet._profileOffsets = profileOffsets;

                // Read into memory all the small lists which are frequently accessed.
                reader.BaseStream.Position = components.Header.StartPosition;
                components.Read(reader);
                reader.BaseStream.Position = maps.Header.StartPosition;
                maps.Read(reader);
                reader.BaseStream.Position = properties.Header.StartPosition;
                properties.Read(reader);
                reader.BaseStream.Position = rootNodes.Header.StartPosition;
                rootNodes.Read(reader);
                reader.BaseStream.Position = profileOffsets.Header.StartPosition;
                profileOffsets.Read(reader);
            }
            finally
            {
                dataSet.Pool.Release(reader);
            }
        }
        private List <StiToken> PostProcessTokensList(List <StiToken> tokensList)
        {
            List <StiToken> newList = new List <StiToken>();

            tokenPos = 0;
            while (tokenPos < tokensList.Count)
            {
                StiToken token = tokensList[tokenPos];
                tokenPos++;
                if (token.Type == StiTokenType.Identifier)
                {
                    if ((newList.Count > 0) && (newList[newList.Count - 1].Type == StiTokenType.Dot))
                    {
                        if (MethodsList.Contains(token.Value))
                        {
                            token.Type = StiTokenType.Method;
                        }
                        //Proryv
                        else if (Equals(token.Value, "Value") || ProryvPropertiesList.Contains(token.Value) || PropertiesList.Contains(token.Value))
                        {
                            token.Type = StiTokenType.Property;
                        }
                        else
                        {
                            ThrowError(ParserErrorCode.FieldMethodOrPropertyNotFound, token, token.Value);
                        }
                    }
                    else if (TypesList.Contains(token.Value))
                    {
                        token.Type = StiTokenType.Cast;

                        if ((tokenPos + 1 < tokensList.Count) && (tokensList[tokenPos].Type == StiTokenType.Dot))
                        {
                            string tempName = token.Value + "." + tokensList[tokenPos + 1].Value;
                            if (FunctionsList.Contains(tempName))
                            {
                                token.Type  = StiTokenType.Function;
                                token.Value = tempName;
                                tokenPos   += 2;
                            }
                            //Proryv
                            else if (ProryvFunctionsList.Contains(tempName))
                            {
                                token.Type  = StiTokenType.ProryvFunction;
                                token.Value = tempName;
                                tokenPos   += 2;
                            }
                            if (SystemVariablesList.Contains(tempName))
                            {
                                token.Type  = StiTokenType.SystemVariable;
                                token.Value = tempName;
                                tokenPos   += 2;
                            }
                        }
                    }

                    //Proryv
                    else if (ProryvFunctionsList.Contains(token.Value))
                    {
                        token.Type = StiTokenType.ProryvFunction;
                    }
                    else if (_proryvSpreadsheetProperties != null && _proryvSpreadsheetProperties.ContainsKey(token.Value.ToLowerInvariant()))
                    {
                        token.Type = StiTokenType.ProryvSpreadsheetProperties;
                    }
                    else if (_proryvFreeHierarchyBalanceSignature != null && _proryvFreeHierarchyBalanceSignature.ContainsKey(token.Value.ToLowerInvariant()))
                    {
                        token.Type = StiTokenType.ProryvFreeHierarchyBalanceSignature;
                    }

                    else if (FunctionsList.Contains(token.Value))
                    {
                        while ((ProryvFunctionType)FunctionsList[token.Value] == ProryvFunctionType.NameSpace)
                        {
                            if (tokenPos + 1 >= tokensList.Count)
                            {
                                ThrowError(ParserErrorCode.UnexpectedEndOfExpression);
                            }
                            var np = tokensList[tokenPos + 1].Value;
                            token.Value += "." + np;
                            tokenPos    += 2;
                            if (!FunctionsList.Contains(token.Value))
                            {
                                if (FunctionsList.Contains(np))
                                {
                                    token.Value = np;
                                }
                                else
                                {
                                    ThrowError(ParserErrorCode.FunctionNotFound, token, token.Value);
                                }
                            }
                        }
                        token.Type = StiTokenType.Function;
                    }

                    else if (SystemVariablesList.Contains(token.Value) && (token.Value != "value"))
                    {
                        token.Type = StiTokenType.SystemVariable;
                    }

                    //else if (token.Value.ToLowerInvariant() == "true" || token.Value.ToLowerInvariant() == "false")
                    //{
                    //    if (token.Value.ToLowerInvariant() == "true")
                    //        token.ValueObject = true;
                    //    else
                    //        token.ValueObject = false;
                    //    token.Type = StiTokenType.Number;
                    //}
                    //else if (token.Value.ToLowerInvariant() == "null")
                    //{
                    //    token.ValueObject = null;
                    //    token.Type = StiTokenType.Number;
                    //}

                    else if (ConstantsList.Contains(token.Value))
                    {
                        while (ConstantsList[token.Value] == namespaceObj)
                        {
                            if (tokenPos + 1 >= tokensList.Count)
                            {
                                ThrowError(ParserErrorCode.UnexpectedEndOfExpression);
                            }
                            string oldTokenValue = token.Value;
                            token.Value += "." + tokensList[tokenPos + 1].Value;
                            tokenPos    += 2;
                            if (!ConstantsList.Contains(token.Value))
                            {
                                ThrowError(ParserErrorCode.ItemDoesNotContainDefinition, token, oldTokenValue, tokensList[tokenPos + 1].Value);
                            }
                        }
                        token.ValueObject = ConstantsList[token.Value];
                        token.Type        = StiTokenType.Number;
                    }

                    else if (UserFunctionsList.Contains(token.Value))
                    {
                        token.Type = StiTokenType.Function;
                    }

                    else
                    {
                        ThrowError(ParserErrorCode.NameDoesNotExistInCurrentContext, token, token.Value);
                    }
                }
                newList.Add(token);
            }
            return(newList);
        }
Exemple #17
0
        /// <summary>
        /// Creates a new <see cref="DataSet"/> from the binary reader provided.
        /// </summary>
        /// <param name="dataSet">The data set to be loaded with data from the reader</param>
        /// <param name="reader">
        /// Reader connected to the source data structure and positioned to start reading
        /// </param>
        /// <param name="init">
        /// True to indicate that the data set should be fulling initialised
        /// </param>
        /// <para>
        /// A <see cref="DataSet"/> is constructed using the reader to retrieve
        /// the header information. This is then passed to the Read methods to create the
        /// lists before reading the data into memory. Finally it initialise is required
        /// references between entities are worked out and stored.
        /// </para>
        internal static void Load(DataSet dataSet, Reader reader, bool init)
        {
            CommonFactory.LoadHeader(dataSet, reader);

            var strings = new MemoryVariableList <AsciiString>(dataSet, reader, new AsciiStringFactory());
            MemoryFixedList <Component> components = null;

            switch (dataSet.VersionEnum)
            {
            case BinaryConstants.FormatVersions.PatternV31:
                components = new MemoryFixedList <Component>(dataSet, reader, new ComponentFactoryV31());
                break;

            case BinaryConstants.FormatVersions.PatternV32:
                components = new MemoryFixedList <Component>(dataSet, reader, new ComponentFactoryV32());
                break;
            }
            var maps       = new MemoryFixedList <Map>(dataSet, reader, new MapFactory());
            var properties = new PropertiesList(dataSet, reader, new PropertyFactory());
            var values     = new MemoryFixedList <Value>(dataSet, reader, new ValueFactory());
            var profiles   = new MemoryVariableList <Entities.Profile>(dataSet, reader, new ProfileMemoryFactory());
            MemoryFixedList <Signature> signatures                 = null;
            MemoryFixedList <Integer>   signatureNodeOffsets       = null;
            MemoryFixedList <Integer>   nodeRankedSignatureIndexes = null;

            switch (dataSet.VersionEnum)
            {
            case BinaryConstants.FormatVersions.PatternV31:
                signatures = new MemoryFixedList <Signature>(dataSet, reader, new SignatureFactoryV31(dataSet));
                break;

            case BinaryConstants.FormatVersions.PatternV32:
                signatures                 = new MemoryFixedList <Signature>(dataSet, reader, new SignatureFactoryV32(dataSet));
                signatureNodeOffsets       = new MemoryFixedList <Integer>(dataSet, reader, new IntegerFactory());
                nodeRankedSignatureIndexes = new MemoryFixedList <Integer>(dataSet, reader, new IntegerFactory());
                break;
            }
            var rankedSignatureIndexes = new MemoryFixedList <Integer>(
                dataSet, reader, new IntegerFactory());
            MemoryVariableList <Entities.Node> nodes = null;

            switch (dataSet.VersionEnum)
            {
            case BinaryConstants.FormatVersions.PatternV31:
                nodes = new MemoryVariableList <Entities.Node>(dataSet, reader, new NodeMemoryFactoryV31());
                break;

            case BinaryConstants.FormatVersions.PatternV32:
                nodes = new MemoryVariableList <Entities.Node>(dataSet, reader, new NodeMemoryFactoryV32());
                break;
            }
            var rootNodes      = new MemoryFixedList <Entities.Node>(dataSet, reader, new RootNodeFactory());
            var profileOffsets = new MemoryFixedList <ProfileOffset>(dataSet, reader, new ProfileOffsetFactory());

            dataSet.Strings                 = strings;
            dataSet._components             = components;
            dataSet._maps                   = maps;
            dataSet._properties             = properties;
            dataSet._values                 = values;
            dataSet.Profiles                = profiles;
            dataSet._signatures             = signatures;
            dataSet._rankedSignatureIndexes = rankedSignatureIndexes;
            switch (dataSet.VersionEnum)
            {
            case BinaryConstants.FormatVersions.PatternV32:
                dataSet._signatureNodeOffsets       = signatureNodeOffsets;
                dataSet._nodeRankedSignatureIndexes = nodeRankedSignatureIndexes;
                break;
            }
            dataSet.Nodes           = nodes;
            dataSet.RootNodes       = rootNodes;
            dataSet._profileOffsets = profileOffsets;

            strings.Read(reader);
            components.Read(reader);
            maps.Read(reader);
            properties.Read(reader);
            values.Read(reader);
            profiles.Read(reader);
            signatures.Read(reader);
            switch (dataSet.VersionEnum)
            {
            case BinaryConstants.FormatVersions.PatternV32:
                signatureNodeOffsets.Read(reader);
                nodeRankedSignatureIndexes.Read(reader);
                break;
            }
            rankedSignatureIndexes.Read(reader);
            nodes.Read(reader);
            rootNodes.Read(reader);
            profileOffsets.Read(reader);

            if (init)
            {
                // Set references between objects.
                dataSet.Init();

                // The following lists will not be needed anymore
                // so they can be freed.
                dataSet._signatureNodeOffsets       = null;
                dataSet._nodeRankedSignatureIndexes = null;

                // Force garbage collection as a lot of memory has been freed.
                GC.Collect();
            }
        }
        /// <summary>
        /// Creates a new <see cref="DataSet"/> from the binary reader provided.
        /// </summary>
        /// <param name="dataSet">The data set to be loaded with data from the reader</param>
        /// <param name="reader">
        /// Reader connected to the source data structure and positioned to start reading
        /// </param>
        /// <param name="init">
        /// True to indicate that the data set should be fulling initialised
        /// </param>
        /// <para>
        /// A <see cref="DataSet"/> is constructed using the reader to retrieve 
        /// the header information. This is then passed to the Read methods to create the
        /// lists before reading the data into memory. Finally it initialise is required
        /// references between entities are worked out and stored.
        /// </para>
        internal static void Load(DataSet dataSet, Reader reader, bool init)
        {
            CommonFactory.LoadHeader(dataSet, reader);

            var strings = new MemoryVariableList<AsciiString<DataSet>, DataSet>(dataSet, reader, new MemoryAsciiStringFactory());
            MemoryFixedList<Component, DataSet> components = null;
            switch(dataSet.VersionEnum)
            {
                case BinaryConstants.FormatVersions.PatternV31:
                    components = new MemoryFixedList<Component, DataSet>(dataSet, reader, new ComponentFactoryV31());
                    break;
                case BinaryConstants.FormatVersions.PatternV32:
                    components = new MemoryFixedList<Component, DataSet>(dataSet, reader, new ComponentFactoryV32());
                    break;
            }
            var maps = new MemoryFixedList<Map, DataSet>(dataSet, reader, new MapFactory());
            var properties = new PropertiesList(dataSet, reader, new PropertyFactory());
            var values = new MemoryFixedList<Value, DataSet>(dataSet, reader, new ValueFactory<DataSet>());
            var profiles = new MemoryVariableList<Entities.Profile, DataSet>(dataSet, reader, new ProfileMemoryFactory());
            MemoryFixedList<Signature, DataSet> signatures = null;
            MemoryIntegerList signatureNodeOffsets = null;
            MemoryIntegerList nodeRankedSignatureIndexes = null;
            switch(dataSet.VersionEnum)
            {
                case BinaryConstants.FormatVersions.PatternV31:
                    signatures = new MemoryFixedList<Signature, DataSet>(dataSet, reader, new SignatureFactoryV31<DataSet>(dataSet));
                    break;
                case BinaryConstants.FormatVersions.PatternV32:
                    signatures = new MemoryFixedList<Signature, DataSet>(dataSet, reader, new SignatureFactoryV32<DataSet>(dataSet));
                    signatureNodeOffsets = new MemoryIntegerList(reader);
                    nodeRankedSignatureIndexes = new MemoryIntegerList(reader);
                    break;
            }
            var rankedSignatureIndexes = new MemoryIntegerList(reader);
            MemoryVariableList<Entities.Node, DataSet> nodes = null;
            switch (dataSet.VersionEnum)
            {
                case BinaryConstants.FormatVersions.PatternV31:
                    nodes = new MemoryVariableList<Entities.Node, DataSet>(dataSet, reader, new NodeMemoryFactoryV31());
                    break;
                case BinaryConstants.FormatVersions.PatternV32:
                    nodes = new MemoryVariableList<Entities.Node, DataSet>(dataSet, reader, new NodeMemoryFactoryV32());
                    break;
            }
            var rootNodes = new MemoryFixedList<Entities.Node, DataSet>(dataSet, reader, new RootNodeFactory());
            var profileOffsets = new MemoryFixedList<ProfileOffset, DataSet>(dataSet, reader, new ProfileOffsetFactory());

            dataSet.Strings = strings;
            dataSet._components = components;
            dataSet._maps = maps;
            dataSet._properties = properties;
            dataSet._values = values;
            dataSet.Profiles = profiles;
            dataSet._signatures = signatures;
            dataSet._rankedSignatureIndexes = rankedSignatureIndexes;
            switch (dataSet.VersionEnum)
            {
                case BinaryConstants.FormatVersions.PatternV32:
                    dataSet._signatureNodeOffsets = signatureNodeOffsets;
                    dataSet._nodeRankedSignatureIndexes = nodeRankedSignatureIndexes;
                    break;
            }
            dataSet.Nodes = nodes;
            dataSet.RootNodes = rootNodes;
            dataSet._profileOffsets = profileOffsets;

            strings.Read(reader);
            components.Read(reader);
            maps.Read(reader);
            properties.Read(reader);
            values.Read(reader);
            profiles.Read(reader);
            signatures.Read(reader);
            switch (dataSet.VersionEnum)
            {
                case BinaryConstants.FormatVersions.PatternV32:
                    signatureNodeOffsets.Read(reader);
                    nodeRankedSignatureIndexes.Read(reader);
                    break;
            }
            rankedSignatureIndexes.Read(reader);
            nodes.Read(reader);
            rootNodes.Read(reader);
            profileOffsets.Read(reader);

            if (init)
            {
                // Set references between objects.
                dataSet.Init();

                // The following lists will not be needed anymore
                // so they can be freed.
                dataSet._signatureNodeOffsets = null;
                dataSet._nodeRankedSignatureIndexes = null;

                // Force garbage collection as a lot of memory has been freed.
                GC.Collect();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertiesListElement"/> class.
 /// </summary>
 public PropertiesListElement()
 {
     Properties = new PropertiesList(this);
 }
Exemple #20
0
        /// <summary>
        /// Load the necessary values from the data file in to the DataSet.
        /// Initially, this will only load data such as file headers
        /// and the smaller lists.
        /// </summary>
        /// <param name="dataSet">The dataset object to load in to</param>
        /// <param name="cacheConfiguration">the cache configuration to use when creating the caches</param>
        private static void LoadForStreaming(IndirectDataSet dataSet, Dictionary <CacheType, ICacheOptions> cacheConfiguration)
        {
            var reader = dataSet.Pool.GetReader();

            try
            {
                CacheMap cacheMap = BuildCaches(cacheConfiguration);
                dataSet.CacheMap = cacheMap;

                reader.BaseStream.Position = 0;
                CommonFactory.LoadHeader(dataSet, reader);

                // ---- Create AsciiString list
                var stringLoader = EntityLoaderFactory.GetLoaderFor(
                    new Header(reader),
                    cacheMap.StringCache,
                    dataSet,
                    new StreamAsciiStringFactory());
                dataSet.Strings = new StreamList <AsciiString, IStreamDataSet>(stringLoader);

                MemoryFixedList <Component, DataSet> components = null;
                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    components = new MemoryFixedList <Component, DataSet>(
                        dataSet,
                        reader,
                        new ComponentFactoryV31());
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    components = new MemoryFixedList <Component, DataSet>(
                        dataSet,
                        reader,
                        new ComponentFactoryV32());
                    break;
                }
                dataSet._components = components;
                var maps = new MemoryFixedList <Map, DataSet>(
                    dataSet,
                    reader,
                    new MapFactory());
                dataSet._maps = maps;
                var properties = new PropertiesList(
                    dataSet,
                    reader,
                    new PropertyFactory());
                dataSet._properties = properties;

                // ---- Create Value list
                var valueLoader = EntityLoaderFactory.GetLoaderFor(new Header(reader),
                                                                   cacheMap.ValueCache,
                                                                   dataSet,
                                                                   new ValueFactory <IStreamDataSet>());
                dataSet._values = new StreamList <Value, IStreamDataSet>(valueLoader);

                // ---- Create Profile list
                var profileLoader = EntityLoaderFactory.GetLoaderFor(new Header(reader),
                                                                     cacheMap.ProfileCache,
                                                                     dataSet,
                                                                     new ProfileStreamFactory(dataSet.Pool));
                dataSet.Profiles = new StreamList <Entities.Profile, IStreamDataSet>(profileLoader);

                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    // ---- Create Signature list for V31
                    var signatureLoaderV31 = EntityLoaderFactory.GetLoaderFor(
                        new Header(reader),
                        cacheMap.SignatureCache,
                        dataSet,
                        new SignatureFactoryV31 <IndirectDataSet>(dataSet));
                    dataSet._signatures = new StreamList <Signature, IndirectDataSet>(
                        signatureLoaderV31);
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    // ---- Create Signature list for V32
                    var signatureLoaderV32 = EntityLoaderFactory.GetLoaderFor(
                        new Header(reader),
                        cacheMap.SignatureCache,
                        dataSet,
                        new SignatureFactoryV32 <IndirectDataSet>(dataSet));
                    dataSet._signatures = new StreamList <Signature, IndirectDataSet>(
                        signatureLoaderV32);
                    dataSet._signatureNodeOffsets       = new IntegerList(dataSet, reader);
                    dataSet._nodeRankedSignatureIndexes = new IntegerList(dataSet, reader);
                    break;
                }
                dataSet._rankedSignatureIndexes = new IntegerList(dataSet, reader);
                switch (dataSet.VersionEnum)
                {
                case BinaryConstants.FormatVersions.PatternV31:
                    // ---- Create Nodes list for V31
                    var nodeLoaderV31 = EntityLoaderFactory.GetLoaderFor(
                        new Header(reader),
                        cacheMap.NodeCache,
                        dataSet,
                        new NodeStreamFactoryV31(dataSet.Pool));
                    dataSet.Nodes = new StreamList <Entities.Node, IStreamDataSet>(
                        nodeLoaderV31);
                    break;

                case BinaryConstants.FormatVersions.PatternV32:
                    // ---- Create Nodes list for V31
                    var nodeLoaderV32 = EntityLoaderFactory.GetLoaderFor(
                        new Header(reader),
                        cacheMap.NodeCache,
                        dataSet,
                        new NodeStreamFactoryV32(dataSet.Pool));
                    dataSet.Nodes = new StreamList <Entities.Node, IStreamDataSet>(
                        nodeLoaderV32);
                    break;
                }
                var rootNodes = new MemoryFixedList <Entities.Node, DataSet>(
                    dataSet,
                    reader,
                    new RootNodeFactory());
                dataSet.RootNodes = rootNodes;
                var profileOffsets = new MemoryFixedList <ProfileOffset, DataSet>(
                    dataSet,
                    reader,
                    new ProfileOffsetFactory());
                dataSet._profileOffsets = profileOffsets;

                // Read into memory all the small lists which are frequently accessed.
                reader.BaseStream.Position = components.Header.StartPosition;
                components.Read(reader);
                reader.BaseStream.Position = maps.Header.StartPosition;
                maps.Read(reader);
                reader.BaseStream.Position = properties.Header.StartPosition;
                properties.Read(reader);
                reader.BaseStream.Position = rootNodes.Header.StartPosition;
                rootNodes.Read(reader);
                reader.BaseStream.Position = profileOffsets.Header.StartPosition;
                profileOffsets.Read(reader);
            }
            finally
            {
                dataSet.Pool.Release(reader);
            }
        }