Ejemplo n.º 1
0
        public ulong GetLongConditionalHashCode()
        {
            Name.CheckDirty();

            if (!TypesList.IsNullOrEmpty())
            {
                foreach (var item in TypesList)
                {
                    item.CheckDirty();
                }
            }

            DefaultValue?.CheckDirty();

            var result = Name.GetLongConditionalHashCode();

            if (!TypesList.IsNullOrEmpty())
            {
                foreach (var item in TypesList)
                {
                    result ^= item.GetLongConditionalHashCode();
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public static TypeListDTO ConvertTypeListToDTO(TypesList t)
 {
     return(new TypeListDTO
     {
         TypeListId = t.TypeListId,
         AccountId = t.AccountId,
         TypeListName = t.TypeListName
     });
 }
        public ConfigurationRegistry Apply(TypesList typesList, Action <ContainerConfigurationBuilder> modificator)
        {
            if (modificator == null)
            {
                return(this);
            }
            var builder = new ContainerConfigurationBuilder();

            modificator(builder);
            return(builder.RegistryBuilder.Build(typesList, this));
        }
Ejemplo n.º 4
0
        public void DiscoverAllAnnotations(IList <RuleInstance> result)
        {
            Name?.DiscoverAllAnnotations(result);

            if (!TypesList.IsNullOrEmpty())
            {
                foreach (var item in TypesList)
                {
                    item.DiscoverAllAnnotations(result);
                }
            }
        }
Ejemplo n.º 5
0
        public IContainer Build()
        {
            var typesContext = typesContextCache;

            if (typesContext == null)
            {
                var targetTypes = types()
                                  .Concat(Assembly.GetExecutingAssembly().GetTypes())
                                  .Where(x => !x.Name.StartsWith("<>", StringComparison.OrdinalIgnoreCase))
                                  .Distinct()
                                  .ToArray();
                typesContext = new TypesContext {
                    typesList = TypesList.Create(targetTypes)
                };
                typesContext.genericsAutoCloser = new GenericsAutoCloser(typesContext.typesList, assembliesFilter);
                if (configFileName != null && File.Exists(configFileName))
                {
                    typesContext.fileConfigurator = FileConfigurationParser.Parse(typesContext.typesList.Types, configFileName);
                }
                ConfigurationRegistry staticConfiguration;
                if (staticConfigure == null)
                {
                    staticConfiguration = ConfigurationRegistry.Empty;
                }
                else
                {
                    var builder = new ContainerConfigurationBuilder();
                    staticConfigure(builder);
                    staticConfiguration = builder.RegistryBuilder.Build(typesContext.typesList, null);
                }
                var configurationContainer = CreateContainer(typesContext, staticConfiguration);
                typesContext.configuratorRunner = configurationContainer.Get <ConfiguratorRunner>();
                typesContextCache = typesContext;
            }
            ConfigurationRegistry configurationRegistry;

            if (!configurationByProfileCache.TryGetValue(profile ?? typeof(ContainerFactory), out configurationRegistry))
            {
                var builder = new ContainerConfigurationBuilder();
                var configurationContext = new ConfigurationContext(profile, settingsLoader, parameters);
                typesContext.configuratorRunner.Run(builder, configurationContext, priorities);
                if (typesContext.fileConfigurator != null)
                {
                    typesContext.fileConfigurator(builder);
                }
                configurationRegistry = builder.RegistryBuilder.Build(typesContext.typesList, null);
                configurationByProfileCache.Add(profile ?? typeof(ContainerFactory), configurationRegistry);
            }
            return(CreateContainer(typesContext, configurationRegistry.Apply(typesContext.typesList, configure)));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Clones the instance using special context and returns cloned instance.
        /// </summary>
        /// <param name="context">Special context for providing references continuity.</param>
        /// <returns>Cloned instance.</returns>
        public FunctionArgumentInfo Clone(Dictionary <object, object> context)
        {
            if (context.ContainsKey(this))
            {
                return((FunctionArgumentInfo)context[this]);
            }

            var result = new FunctionArgumentInfo();

            context[this] = result;

            result.Name            = Name.Clone(context);
            result.TypesList       = TypesList?.Select(p => p.Clone(context)).ToList();
            result.HasDefaultValue = HasDefaultValue;
            result.DefaultValue    = DefaultValue.CloneValue(context);

            return(result);
        }
            public ConfigurationRegistry Build(TypesList typesList, ConfigurationRegistry parent)
            {
                ApplyDynamicConfigurators(typesList);
                IConfigurationSource configurationSource = new SimpleConfigurationSource(configurations);

                if (parent != null)
                {
                    foreach (var p in parent.contractUnions)
                    {
                        if (!contractUnions.ContainsKey(p.Key))
                        {
                            contractUnions.Add(p);
                        }
                    }
                    implementationSelectors.AddRange(parent.implementationSelectors);
                    configurationSource = new MergingConfigurationSource(configurationSource, parent.configurations);
                }
                return(new ConfigurationRegistry(configurationSource, contractUnions, implementationSelectors));
            }
Ejemplo n.º 8
0
 /// <summary>
 /// הוספת מוצרים לסוג רשימה
 /// </summary>
 /// <param name="typeList"></param>
 /// <param name="listForChange"></param>
 /// <returns></returns>
 public static bool addProductsForList(TypesList typeList, ListForChangeDTO listForChange)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {
         foreach (int id in listForChange.idProductsList)
         {
             if (id != 0)
             {
                 ProductsToTypeList p = new ProductsToTypeList();
                 p.TypeListId = db.TypesLists.FirstOrDefault(type => type.TypeListName == typeList.TypeListName && type.AccountId == typeList.AccountId).TypeListId;
                 p.Amount     = 1;
                 p.ProductId  = id;
                 db.ProductsToTypeLists.Add(p);
             }
         }
         db.SaveChanges();
         return(true);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var listItem = new ListItem("не выбрано", "-1");
                TypesList.Items.Add(listItem);
                TypesList.AppendDataBoundItems = true;

                var query = "SELECT [objID], [name] FROM [_ApplicationType]";
                var dt    = new DataTable();
                var da    = new SqlDataAdapter(query, ConString);
                da.Fill(dt);
                TypesList.DataSource     = dt;
                TypesList.DataTextField  = "name";
                TypesList.DataValueField = "objID";
                TypesList.DataBind();
                MView.ActiveViewIndex = -1;
            }
        }
            private void ApplyDynamicConfigurators(TypesList typesList)
            {
                var configurationSet = new ServiceConfigurationSet();
                var builder          = new ServiceConfigurationBuilder <object>(configurationSet);

                foreach (var c in dynamicConfigurators)
                {
                    var targetTypes = c.BaseType == null?typesList.Types.ToList() : typesList.InheritorsOf(c.BaseType);

                    foreach (var t in targetTypes)
                    {
                        if (configurations.ContainsKey(t))
                        {
                            continue;
                        }
                        try
                        {
                            c.ConfigureAction(t, builder);
                        }
                        catch (Exception e)
                        {
                            const string messageFormat = "exception invoking [{0}] for [{1}]";
                            throw new SimpleContainerException(string.Format(messageFormat, c.Description, t.FormatName()), e);
                        }
                        if (configurationSet.IsEmpty())
                        {
                            continue;
                        }
                        if (!string.IsNullOrEmpty(c.Description))
                        {
                            configurationSet.SetDefaultComment(c.Description);
                        }
                        configurations.Add(t, configurationSet);
                        configurationSet = new ServiceConfigurationSet();
                        builder          = new ServiceConfigurationBuilder <object>(configurationSet);
                    }
                }
            }
Ejemplo n.º 11
0
 /// <summary>
 /// שמירת סוג רשימה חדש לחשבון מסוים
 /// </summary>
 /// <param name="accountId"></param>
 /// <param name="listForChange"></param>
 /// <returns></returns>
 public static bool SaveList(int accountId, ListForChangeDTO listForChange)
 {
     using (ProjectDBEntities db = new ProjectDBEntities())
     {
         TypesList typeList = new TypesList();
         if (db.TypesLists.FirstOrDefault(a => a.AccountId == accountId && a.TypeListName == listForChange.NameList) == null)
         {
             typeList.TypeListName = listForChange.NameList;
             typeList.AccountId    = accountId;
             db.TypesLists.Add(typeList);
         }
         else
         {
             return(false);
         }
         db.SaveChanges();
         if (listForChange.idProductsList != null)
         {
             addProductsForList(typeList, listForChange);
         }
         return(true);
     }
 }
 private void Init(bool isDefault)
 {
     if (isDefault)
     {
         SelectedSection  = SectionsList[0];
         SelectedType     = TypesList[0];
         SelectedStatus   = StatusesList[0];
         SelectedSource   = SourcesList[0];
         SelectedCustomer = CustomersList[0];
         SelectedBroker   = BrokersList[0];
         SelectedTrader   = TradersList[0];
     }
     else
     {
         SelectedSection  = SectionsList.First(s => s.id == Auction.sectionId);
         SelectedType     = TypesList.First(t => t.id == Auction.typeId);
         SelectedStatus   = StatusesList.First(s => s.Id == Auction.StatusId);
         SelectedSource   = SourcesList.First(s => s.id == Auction.SiteId);
         SelectedCustomer = CustomersList.First(c => c.id == Auction.CustomerId);
         SelectedBroker   = BrokersList.First(b => b.Id == Auction.BrokerId);
         SelectedTrader   = TradersList.First(t => t.id == Auction.TraderId);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Pone la seleccion del lisbox en el medio.Es para configuraciones iniciales
        /// </summary>
        /// <param name="type"></param>
        public void UpdateCollectionMiddle(TypesList type )
        {
            //cantidad de elementos visibles en el listbox
            double countItem = 0;
            List<string> fin = null;
            string select = "";
            switch (type)
            {
                case TypesList.Genre:
                    if (Genres == null || Genres.Count <=0)
                    {
                        NotifyChanged("Genres");
                        break;
                    }
                    var t1 = Genres.Count*HeightIListBox + Genres.Count*7;
                    var t2 = HeightListBox/(HeightIListBox + 7);
                    countItem =  t1< HeightListBox
                        ? Genres.Count : t2;
                    fin = new List<string>();
                    select = Genres.First();
                    for (int i = 0; i < countItem/2-1; i++)
                    {
                        fin.Add(Genres[Genres.Count-1]);
                        Genres.RemoveAt(Genres.Count - 1);
                    }
                    fin.Reverse();
                    Genres=new ObservableCollection<string>(fin.Concat(Genres));
                    NotifyChanged("Genres");
                    SelectedGenre = select;
                    MiddleGenre = Genres.IndexOf(select);
                    break;
                case TypesList.Artist:
                    if (Artists == null || Artists.Count <= 0)
                    {
                        NotifyChanged("Artists");
                        break;
                    }
                    t1 = Artists.Count*HeightIListBox + Artists.Count*7;
                    t2 = HeightListBox/(HeightIListBox + 7);
                    countItem = t1< HeightListBox
                        ? Artists.Count :t2 ;
                    fin = new List<string>();
                    select = Artists.First();
                    for (int i = 0; i < countItem / 2 -1; i++)
                    {
                        fin.Add(Artists[Artists.Count - 1]);
                        Artists.RemoveAt(Artists.Count - 1);
                    }
                    fin.Reverse();
                    Artists = new ObservableCollection<string>(fin.Concat(Artists));
                    NotifyChanged("Artists");
                    SelectedArtist = select;
                    MiddleArtist = Artists.IndexOf(select);
                    break;
                case TypesList.Track:
                    if (Tracks == null || Tracks.Count <= 0)
                    {
                        NotifyChanged("Tracks");
                        MiddleTrack = -1;
                        SelectedIndexTrack = (int)MiddleTrack;
                        break;
                    }
                    t1 = Tracks.Count*HeightIListBox + Tracks.Count*7;
                    t2 = HeightListBox/(HeightIListBox + 7);
                    countItem = t1 < HeightListBox
                        ? Tracks.Count : t2;
                    fin = new List<string>();
                    var finDirTrack = new List<string>();
                    select = Tracks.First();
                    for (int i = 0; i < countItem / 2 -1; i++)
                    {
                        fin.Add(Tracks.Last());
                        Tracks.RemoveAt(Tracks.Count - 1);

                        finDirTrack.Add(DirTracks.Last());
                        DirTracks.RemoveAt(DirTracks.Count-1);
                    }
                    fin.Reverse();
                    finDirTrack.Reverse();
                    Tracks = new ObservableCollection<string>(fin.Concat(Tracks));
                    DirTracks = new List<string>(finDirTrack.Concat(DirTracks));
                    NotifyChanged("Tracks");
                    //SelectedTrack = select;
                    MiddleTrack = Tracks.IndexOf(select);
                    //MiddleTrack =countItem > 2 ? countItem % 2 == 0 ? countItem / 2 - 1: countItem / 2-0.5 : 0;
                    SelectedIndexTrack = (int)MiddleTrack;
                    break;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Permet de récuperer la valeur d'un tableau de byte.
        /// </summary>
        public static object GetValue(byte[] number, TypesList type) // TODO: finish this
        {
            try
            {
                switch (type)
                {
                case TypesList.Bool:
                    return(BitConverter.ToBoolean(number, 0));

                case TypesList.Byte:
                    return(number[0]);

                case TypesList.Short:
                    return(BitConverter.ToInt16(number, 0));

                case TypesList.Int:
                    return(BitConverter.ToInt32(number, 0));

                case TypesList.Long:
                    return(BitConverter.ToInt64(number, 0));

                case TypesList.Float:
                    return(BitConverter.ToSingle(number, 0));

                case TypesList.Double:
                    return(BitConverter.ToDouble(number, 0));

                case TypesList.Char:
                    return(BitConverter.ToChar(number, 0));

                case TypesList.BoolA:
                    return(null);

                case TypesList.ByteA:
                    return(null);

                case TypesList.ShortA:
                    return(null);

                case TypesList.IntA:
                    return(null);

                case TypesList.LongA:
                    return(null);

                case TypesList.FloatA:
                    return(null);

                case TypesList.DoubleA:
                    return(null);

                case TypesList.String:
                    return(null);

                case TypesList.Sbyte:
                    return((sbyte)(number[0] + 128));

                case TypesList.uShort:
                    return(BitConverter.ToUInt16(number, 0));

                case TypesList.uInt:
                    return(BitConverter.ToUInt32(number, 0));

                case TypesList.uLong:
                    return(BitConverter.ToUInt64(number, 0));

                default:
                    throw new BinaryConverterError("Une erreur est survenue lors de la conversion d'un tableau binaire en une valeur : (" + e.Data + ")");
                }
            }
            catch (Exception e)
            {
                throw new BinaryConverterError("Une erreur est survenue lors de la conversion d'un tableau binaire en une valeur : (" + e.Data + ")");
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Configure this fake datareader using a list of fields from the query
 /// </summary>
 /// <param name="query"></param>
 /// <param name="rows"></param>
 public void AddFieldToMock(string fieldName, Type type)
 {
     FieldsList.Add(fieldName);
     TypesList.Add(type);
 }
Ejemplo n.º 16
0
        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);
        }
        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);
        }
Ejemplo n.º 18
0
        private void OnLoaded()
        {
            var asset = (TextAsset)target;
            {
                var parseText = asset.text;
                if (parseText.Contains("<?xml") == false)
                {
                    parseText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + parseText;
                }
                Document = new XmlDocument();
                Document.LoadXml(parseText);
                if (Document.DocumentElement?.Name == "ImGuiFx")
                {
                }
                else
                {
                    _disableUi = true;
                    return;
                }
            }

            {
                var showText = asset.text;
                if (showText.Contains("<?xml"))
                {
                    var xmlPos         = showText.IndexOf("<?xml");
                    var firstLineBreak = showText.Substring(xmlPos).IndexOf("\n");
                    showText = showText.Substring(0, xmlPos) + showText.Substring(firstLineBreak + 1);
                }

                showText = showText
                           .Replace("<", "<<b></b>")
                           .Replace("\t", "    ");

                OriginalText            = showText;
                EditorMainTextArea.Text = showText;
            }

            var asm = Assembly.GetAssembly(typeof(Control));

            var controlBaseClass = typeof(Control);
            var layoutBaseClass  = typeof(ILayout);

            var allChildren = asm
                              .GetExportedTypes()
                              .Where(p => p.IsAbstract == false && controlBaseClass.IsAssignableFrom(p))
                              .ToArray();

            foreach (var type in allChildren)
            {
                var tagDefinition = new ImGuiFxType {
                    Name       = type.Name,
                    Attributes = type
                                 .GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name)
                                 .ToArray(),
                    SupportsChildren = layoutBaseClass.IsAssignableFrom(type),
                    FullTypeName     = type.FullName
                };

                TypesList.Add(tagDefinition);
            }

            TypesList = TypesList
                        .OrderBy(p => p.SupportsChildren)
                        .ThenBy(p => p.Name)
                        .ToList();

            var groups = TypesList
                         .GroupBy(p => {
                var split = p.FullTypeName.Split('.');
                return(split.ElementAt(split.Length - 2));
            })
                         .ToArray();

            foreach (var group in groups)
            {
                ControlListLayout.Children.Add(new Foldout {
                    IsOpen   = true,
                    Disabled = true,
                    Label    = "    " + group.Key
                });

                foreach (var imGuiFxType in group.OrderBy(p => p.SupportsChildren))
                {
                    ControlListLayout.Children.Add(new Button {
                        Content = imGuiFxType.Name
                    });
                }
            }
        }