Пример #1
0
        private TriggerPatterns CreatePattern(ETriggerType triggerType)
        {
            (string specialIntiBodyFileName, string specialMainBodyFileName) = GetSpeciaBodyPartlFileNames(triggerType);

            string specialInitBody = _reader.ReadTriggerPart(specialIntiBodyFileName);
            string specialMainBody = _reader.ReadTriggerPart(specialMainBodyFileName);

            TriggerPatterns triggerPattern = new TriggerPatterns(triggerType.GetName(), MainBody, specialMainBody, specialInitBody);

            return(triggerPattern);
        }
        private static string CreateSpecificMainPart(Trigger trigger, TriggerPatterns triggerPattern)
        {
            StringBuilder builder = new StringBuilder();

            foreach (var atribute in trigger.Attributes)
            {
                string attribyteBody =
                    (triggerPattern.AttributeBody.Clone() as string)
                    .Replace(Attribute, atribute.Name);

                builder.Append(attribyteBody + Environment.NewLine);
            }

            builder.Replace(OrderAttribute, trigger.OrderAttribute.Name);

            return(builder.ToString());
        }
        public string CreateTrigger(Trigger trigger, TriggerPatterns triggerPattern)
        {
            string specificMainPart = CreateSpecificMainPart(trigger, triggerPattern);

            StringBuilder triggerBody = new StringBuilder(triggerPattern.MainBody.Clone() as string);

            PatternFormater patternFormater = new PatternFormater();

            string specificInitBody = patternFormater.FormatPart(SpecialInitBody, triggerBody.ToString(), triggerPattern.SpecificInitBody);

            triggerBody.Replace(SpecialInitBody, specificInitBody);

            string specificBody = patternFormater.FormatPart(SpecialMainBody, triggerBody.ToString(), specificMainPart);

            triggerBody.Replace(SpecialMainBody, specificBody);

            triggerBody.Replace(TableName, trigger.TableName);
            triggerBody.Replace(OperationType, triggerPattern.OperationName);

            return(triggerBody.ToString());
        }