Example #1
0
        /// <summary>
        /// Apply tempates for specified builder.
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="templates"></param>
        private void ApplyTemplates(IEntityGraphBuilder builder, EntityTemplate[] templates)
        {
            builder.OnChanged += new SourceChanged(builder_OnChanged);

            EntityTemplate[][] OrderedTemplates = OrderedTemplatesCache.GetItem(templates);

            foreach (EntityTemplate[] templatesWithSamePriority in OrderedTemplates)
            {
                builder.Reset();

                while (builder.MoveNext())
                {
                    foreach (EntityTemplate template in templatesWithSamePriority)
                    {
                        if (AllIsOk)
                        {
                            template.ApplyTo(builder);
                        }
                    }
                    if (!AllIsOk)
                    {
                        AllIsOk = true;
                        break;
                    }
                }
            }
        }
Example #2
0
        public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
        {
            List <IEntity>[] match = info.GetMatch();

            builder.Add(new ConditionalRuleRelationship(
                            EntitiesUtils.PrepareToHandle(match[Arguments[0]][0]) as IClassEntity,
                            EntitiesUtils.PrepareToHandle(match[Arguments[1]][0]) as IPropertyEntity,
                            EntitiesUtils.PrepareToHandle(match[Arguments[2]][0]) as IPropertyEntity));
        }
        public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
        {
            List <IEntity>[] match = info.GetMatch();

            builder.Add(new ClassToClassRelationship(
                            match[Arguments[0]][0].Value,
                            match[Arguments[1]][0] as IClassEntity,
                            match[Arguments[2]][0] as IClassEntity,
                            RelationshipKindHelper.GetKind(ArgumentsDescription[3])));
        }
Example #4
0
 /// <summary>
 /// Add to IEntityGraph all instances of ITrueEntity from IEntityList.
 /// </summary>
 /// <param name="builder">IEntityGraph to with add entities.</param>
 /// <returns>New IEntityGraph.</returns>
 public static void UseEntitiesRule(IEntityGraphBuilder builder)
 {
     for (int i = 0; i < builder.Source.Count; i++)
     {
         if (builder.Source[i] is ITrueEntity)
         {
             builder.Add(builder.Source[i] as ITrueEntity);
         }
     }
 }
Example #5
0
        public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
        {
            List <IEntityList <IEntity> > bigList = AddEntitiesToList(info.GetMatch(), 0, new EntityList <IEntity>());

            for (int i = 0; i < bigList.Count; i++)
            {
                IEntityList <ITrueEntity> oneList             = bigList[i].ConvertToTrueEntityList();
                SubpropertyRelationship   subpropertyRelation = new SubpropertyRelationship(oneList[0] as IPropertyEntity, oneList[1] as IPropertyEntity);
                builder.Add(subpropertyRelation);
            }
        }
Example #6
0
        public void ApplyTo(IEntityGraphBuilder builder)
        {
            EntityRegexMatchInfo info = MainRegex.Interpret(builder.Source.ToArray(), builder.Index);

            if (info.States != null && info.States.Count != 0)
            {
                foreach (IBaseHandler handler in Handlers)
                {
                    handler.Execute(builder, info);
                }
            }
        }
Example #7
0
        public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
        {
            List <IEntity>[] match          = info.GetMatch();
            PropertyEntity   propertyEntity = new PropertyEntity(EntitiesUtils.PrepareToHandle(match[Arguments[0]][0]).Value);

            propertyEntity.Range = new CustomRange(ArgumentsDescription[2]);
            builder.Add(propertyEntity);

            ClassEntity classEntity = match[Arguments[1]][0] as ClassEntity;

            PropertyRelationship propertyRelation = new PropertyRelationship(propertyEntity, classEntity);

            builder.Add(propertyRelation);
        }
Example #8
0
 /// <summary>
 /// Convert all IRelationshipEntity to corresponding IRelationship.
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static void UseConvertRelationshipEntityToRelationshipRule(IEntityGraphBuilder builder)
 {
     foreach (IEntityList <IEntity> sentence in builder.Source.Split(new IEntity[] { SeparatorEntity.Dot, SeparatorEntity.Comma }))
     {
         IEntity[] relationshipEntities = sentence.FindAllByType(typeof(RelationshipEntity));
         if (relationshipEntities != null && relationshipEntities.Length == 1)
         {
             IEntity[] leftClassEntities  = sentence.GetLeftPartFrom(relationshipEntities[0]).FindAllByType(typeof(IClassEntity));
             IEntity[] rightClassEntities = sentence.GetRightPartFrom(relationshipEntities[0]).FindAllByType(typeof(IClassEntity));
             if (leftClassEntities != null && leftClassEntities.Length == 1 &&
                 rightClassEntities != null && rightClassEntities.Length == 1)
             {
                 //Add Relationship
                 IRelationship relation = RelationshipAdapter.CreateRelationship(relationshipEntities[0] as RelationshipEntity);
                 relation.Entities.Add(TrueEntity.ToTrueEntity(leftClassEntities[0]));
                 relation.Entities.Add(TrueEntity.ToTrueEntity(rightClassEntities[0]));
                 builder.Add(relation);
             }
         }
     }
 }
 public void Execute(IEntityGraphBuilder builder, EntityRegexMatchInfo info)
 {
     builder.Replace(info.StartIndex + From, PositionType.Absolute, CreateHandler.Create(info), Count);
 }
Example #10
0
 /// <summary>
 /// Apply templates corresponded to specified language.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="language"></param>
 public void ApplyTemplates(IEntityGraphBuilder builder, ILanguage language)
 {
     ApplyTemplates(builder, LanguageTemplatesCache.GetItem(language));
 }