예제 #1
0
            public pattern(XElement patternNode, RuleBase ownerRule)
            {
                if (patternNode.Elements().Count() != 1)
                {
                    throw (new ArgumentException("patternNode.Elements().Count() != 1 (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }

                #region [.First-child.]
                var first = patternNode.Elements().First();
                FirstName = first.Name.LocalName;

                switch (first.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = first.FirstAttribute;
                    FirstAttributeName = a.Name.LocalName;
                    switch (FirstAttributeName)
                    {
                    case "TYPE": FirstAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": FirstAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("first.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < first.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion
            }
예제 #2
0
        public static void InfoEx(this ILog log, string methodName, string clientRemoteAddress, TimeSpan tonalityElapsed, InputParamsBase inputParams)
        {
            var value = Interlocked.Increment(ref _TotalLogCount) + "]. " +
                        methodName + " => \r\n\t ClientRemoteAddress: " + clientRemoteAddress +
                        "\r\n\t Tonality processing time: " + tonalityElapsed +
                        "\r\n\t Input text (length: {0}): ".FormatEx(inputParams.InputText.Length) +
                        inputParams.InputText.Get4Log();

            log.Info(value);

        #if DEBUG
            lock ( _SynRoot )
            {
                var fc = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(Environment.NewLine + value);
                Console.ForegroundColor = fc;
                Console.WriteLine(RuleBase.GetDebugInfoOutput());
            }
        #endif
        }
예제 #3
0
        public static void ErrorEx(this ILog log, string methodName, Exception ex, string clientRemoteAddress, InputParamsBase inputParams, XContainer xcontainer)
        {
            var value = ("{0}]. ").FormatEx(Interlocked.Increment(ref _TotalLogCount)) +
                        ("{0} => '{1}': '{2}'").FormatEx(methodName, ex.GetType().Name, ex.Message) +
                        ("\r\n\t ClientRemoteAddress: {0}").FormatEx(clientRemoteAddress) +
                        ("\r\n\t Input text (length: {0}): ").FormatEx(inputParams.InputText.Length) +
                        inputParams.InputText.InSingleQuote() +
                        ((xcontainer != null) ? ("\r\n\t XML: [\r\n{0}\r\n]").FormatEx(xcontainer.ToString()) : string.Empty);

            log.Error(value, ex);

        #if DEBUG
            lock ( _SynRoot )
            {
                var fc = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(Environment.NewLine + value + Environment.NewLine + Environment.NewLine + ex.GetType().Name + " => " + ex.ToString());
                Console.ForegroundColor = fc;
                Console.WriteLine(RuleBase.GetDebugInfoOutput());
            }
        #endif
        }
예제 #4
0
            public pattern(XElement patternNode, RuleBase ownerRule)
            {
                if (patternNode.Elements().Count() != 1)
                {
                    throw (new ArgumentException("patternNode.Elements().Count() != 1 (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }

                #region [.Parent.]
                var parent = patternNode.Elements().First();
                ParentName = parent.Name.LocalName;

                switch (parent.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = parent.FirstAttribute;
                    ParentAttributeName = a.Name.LocalName;
                    switch (ParentAttributeName)
                    {
                    case "TYPE": ParentAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": ParentAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("parent.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < parent.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion

                if (parent.Elements().Count() != 4)
                {
                    throw (new ArgumentException("parent.Elements().Count() != 4 (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }

                #region [.First-child.]
                var first = parent.Elements().First();
                FirstName = first.Name.LocalName;

                switch (first.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = first.FirstAttribute;
                    FirstAttributeName = a.Name.LocalName;
                    switch (FirstAttributeName)
                    {
                    case "TYPE": FirstAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": FirstAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("first.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < first.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion

                #region [.Second-child.]
                var second = parent.Elements().Skip(1).First();
                SecondName = second.Name.LocalName;

                switch (second.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = second.FirstAttribute;
                    SecondAttributeName = a.Name.LocalName;
                    switch (SecondAttributeName)
                    {
                    case "TYPE": SecondAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": SecondAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("second.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < second.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion

                #region [.Three-child.]
                var three = parent.Elements().Skip(2).First();
                ThreeName = three.Name.LocalName;

                switch (three.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = three.FirstAttribute;
                    ThreeAttributeName = a.Name.LocalName;
                    switch (ThreeAttributeName)
                    {
                    case "TYPE": ThreeAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": ThreeAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("three.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < three.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion

                #region [.Four-child.]
                var four = parent.Elements().Skip(3).First();
                FourName = four.Name.LocalName;

                switch (four.Attributes().Count())
                {
                case 0: break;

                case 1:
                    var a = four.FirstAttribute;
                    FourAttributeName = a.Name.LocalName;
                    switch (FourAttributeName)
                    {
                    case "TYPE": FourAttributeValue = a.Value.ToEnum <TypeAttributeValue>().ToString(); break;

                    case "ROLE": FourAttributeValue = a.Value.ToEnum <RoleAttributeValue>().ToString(); break;

                    default:
                        throw (new ArgumentException("four.FirstAttribute.Name is " + a.Name.LocalName.InSingleQuote() + " (rule " + ownerRule.Id.InSingleQuote() + ')'));
                    }
                    break;

                default:
                    throw (new ArgumentException("1 < four.Attributes().Count() (rule " + ownerRule.Id.InSingleQuote() + ')'));
                }
                #endregion
            }