예제 #1
0
        public Column(PropertyInfo property, PropertyDefine propertyDefine)
        {
            Property       = property;
            PropertyDefine = propertyDefine;

            if (DataType.FullName != DataTypeNames.String && propertyDefine.Length > 0)
            {
                throw new SpiderException("Only string property can set length.");
            }
            DefaultValue = Property.PropertyType.IsValueType ? Activator.CreateInstance(Property.PropertyType) : null;
            Option       = propertyDefine.Option;
            Selector     = new BaseSelector
            {
                Expression = propertyDefine.Expression,
                Type       = propertyDefine.Type,
                Argument   = propertyDefine.Argument
            };
            NotNull     = propertyDefine.NotNull;
            IgnoreStore = propertyDefine.IgnoreStore;
            Length      = propertyDefine.Length;

            foreach (var formatter in property.GetCustomAttributes <Formatter.Formatter>(true))
            {
                Formatters.Add(formatter);
            }
        }
예제 #2
0
        public Column(PropertyInfo property, PropertyDefine propertyDefine)
        {
            Property       = property;
            PropertyDefine = propertyDefine;

            var type = Property.PropertyType;

            if (DataType.FullName != DataTypeNames.String && propertyDefine.Length > 0)
            {
                throw new SpiderException("Only string property can set length.");
            }

            Multi    = typeof(IList).IsAssignableFrom(type);
            Option   = propertyDefine.Option;
            Selector = new BaseSelector
            {
                Expression = propertyDefine.Expression,
                Type       = propertyDefine.Type,
                Argument   = propertyDefine.Argument
            };
            NotNull     = propertyDefine.NotNull;
            IgnoreStore = propertyDefine.IgnoreStore;
            Length      = propertyDefine.Length;

            foreach (var formatter in property.GetCustomAttributes <Formatter.Formatter>(true))
            {
                Formatters.Add(formatter);
            }
        }
예제 #3
0
        public Column <TRow, TProperty> BackColor(Func <TRow, TProperty, Color> backColor)
        {
            BackColor <TRow, TProperty> formatter = new BackColor <TRow, TProperty>(backColor);

            Formatters.Add(formatter);

            return(this);
        }
예제 #4
0
 public void AddFormatter(Formatter f)
 {
     if (!Formatters.ContainsKey(f.PropertyName))
     {
         Formatters.Add(f.PropertyName, new List <Formatter>());
     }
     Formatters[f.PropertyName].Add(f);
 }
예제 #5
0
        public Column <TRow, TProperty> NumberFormat(string formatString)
        {
            NumberFormat <TRow> formatter = new NumberFormat <TRow>(formatString);

            Formatters.Add(formatter);

            return(this);
        }
예제 #6
0
        public Column <TRow, TProperty> TextColor(Func <TRow, TProperty, Color> textColor)
        {
            TextColor <TRow, TProperty> formatter = new TextColor <TRow, TProperty>(textColor);

            Formatters.Add(formatter);

            return(this);
        }
예제 #7
0
        public Column <TRow, TProperty> TextBold(Func <TRow, TProperty, bool> textBold)
        {
            TextBold <TRow, TProperty> formatter = new TextBold <TRow, TProperty>(textBold);

            Formatters.Add(formatter);

            return(this);
        }
        //private readonly Regex REGEX_BREAK = new Regex(@"(\r\n|\r|\n|\n\r)", RegexOptions.IgnoreCase);

        #endregion

        public WikiFormatterContainer(bool alternate       = false,
                                      bool embedStyleSheet = false,
                                      bool lineNumbers     = false,
                                      //bool enableTracing = false,
                                      string topicCssClass       = "",
                                      string topicCssClassPrefix = "")
            : base()
        {
            Alternate           = alternate;
            EmbedStyleSheet     = embedStyleSheet;
            LineNumbers         = lineNumbers;
            CssClass            = topicCssClass;
            TopicCssClassPrefix = topicCssClassPrefix;

            Formatters.Add(new WikiTocFormatter()
            {
                CssClass            = topicCssClass,
                TopicCssClassPrefix = topicCssClassPrefix
            });

            Formatters.Add(new WikiListFormatter());

            //Formatters.Add(new WikiCodeFormatterEx()
            //{
            //    Alternate = alternate,
            //    EmbedStyleSheet = embedStyleSheet,
            //    LineNumbers = lineNumbers
            //});

            Formatters.Add(new WikiCodeFormatter()
            {
                Alternate       = alternate,
                EmbedStyleSheet = embedStyleSheet,
                LineNumbers     = lineNumbers
            });

            Formatters.Add(new WikiTableFormatter());
            AddFormat(BoldRegex, Bold_Replacement, true);
            AddFormat(ItalicRegex, Italic_Replacement, true);
            AddFormat(UnderlineRegex, Underline_Replacement, true);
            AddFormat(StrikeThoughRegex, StrikeThough_Replacement, true);
            AddFormat(HorizontallineRegex, Horizontalline_Replacement, true);
            AddFormat(LineBreakRegex, LineBreak_Replacement, true);
            AddFormat(SuperscriptRegex, Superscript_Replacement, true);
            AddFormat(SubscriptRegex, Subscript_Replacement, true);
            AddFormat(LTRRegex, LTR_Replacement, true);
            AddFormat(RTLRegex, RTL_Replacement, true);
            AddFormat(LinkRegex, Link_Replacement, true);
            AddFormat(ImgRegex, Img_Replacement, true);
            AddFormat(H5Regex, H5_Replacement, true);
            AddFormat(H4Regex, H4_Replacement, true);
            AddFormat(H3Regex, H3_Replacement, true);
            AddFormat(H2Regex, H2_Replacement, true);
            AddFormat(H1Regex, H1_Replacement, true);
            AddFormat(REGEX_BREAK, "<br/>");
        }
예제 #9
0
파일: Logger.cs 프로젝트: ittaJ/Salem
        public Logger(string scope = "")
        {
            Scope = scope;

            Formatters.Add(new ExceptionFormatter(this));
            Formatters.Add(new IListFormatter(this));
            Formatters.Add(new IDictionaryFormatter(this));

            foreach (var logLevel in LogLevels)
            {
                if (BiggestLength < logLevel.Name.Length)
                {
                    BiggestLength = logLevel.Name.Length;
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Creates the formatters to be used when running this test.
        /// </summary>
        protected void CreateFormatters(NUnitTestData testData, string logPrefix, bool verbose)
        {
            // Now add the specified formatters
            foreach (FormatterData formatterData in testData.Formatters)
            {
                // determine file
                FileInfo         outFile   = GetOutput(formatterData, testData);
                IResultFormatter formatter = CreateFormatter(formatterData.Type, outFile);
                Formatters.Add(formatter);
            }
            // Add default formatter
            // The Log formatter is special in that it always writes to the
            // Log class rather than the TextWriter set in SetOutput().
            // HACK!
            LogFormatter logFormatter = new LogFormatter(logPrefix, verbose);

            Formatters.Add(logFormatter);
        }
        public override bool TryGet <T>(out IMessagePackFormatter <T> formatter)
        {
            if (!base.TryGet(out formatter))
            {
                global::MessagePack.Formatters.IMessagePackFormatter <T> formatterInner = Resolver.GetFormatter <T>();

                if (formatterInner != null)
                {
                    formatter = new MessagePackFormatterWrapper <T>(this, Context, formatterInner, Resolver);

                    Formatters.Add(typeof(T), formatter);

                    return(true);
                }
            }

            return(formatter != null);
        }
        //"([\r\n])[\s]+"
        #endregion

        public BBFormatterContainer(bool alternate       = false,
                                    bool embedStyleSheet = false,
                                    bool lineNumbers     = false)
        {
            Formatters.Add(new BBCodeFormatter()
            {
                Alternate       = alternate,
                EmbedStyleSheet = embedStyleSheet,
                LineNumbers     = lineNumbers
            });

            AddFormat(BoldRegex, Bold_Replacement, true);
            AddFormat(ItalicRegex, Italic_Replacement, true);
            AddFormat(UnderlineRegex, Underline_Replacement, true);
            AddFormat(StrikeThoughRegex, StrikeThough_Replacement, true);
            AddFormat(ColorRegex, Color_Replacement, true);
            AddFormat(CenterRegex, Center_Replacement, true);
            AddFormat(SizeRegex, Size_Replacement, true);
            AddFormat(MailRegex, Mail_Replacement, true);
            AddFormat(LinkRegex, Link_Replacement, true);
            AddFormat(Link2Regex, Link2_Replacement, true);
            AddFormat(QuoteRegex, Quote_Replacement, true);
            AddFormat(QuoteRegex2, Quote_Replacement2, true);
            AddFormat(ImgRegex, Img_Replacement, true);
            AddFormat(ImgRegex1, Img_Replacement1, true);
            AddFormat(ImgRegex2, Img_Replacement2, true);
            AddFormat(OrderListRegex, OrderList_Replacement, true);
            AddFormat(UnOrderListRegex, UnOrderList_Replacement, true);
            AddFormat(ListItemRegex, ListItem_Replacement, true);
            AddFormat(TableRegex, Table_Replacement, true);
            AddFormat(TableRowRegex, TableRow_Replacement, true);
            AddFormat(TableCellRegex, TableCell_Replacement, true);
            AddFormat(TableHeaderCellRegex, TableHeaderCell_Replacement, true);
            AddFormat(H5Regex, H5_Replacement, true);
            AddFormat(H4Regex, H4_Replacement, true);
            AddFormat(H3Regex, H3_Replacement, true);
            AddFormat(H2Regex, H2_Replacement, true);
            AddFormat(H1Regex, H1_Replacement, true);
            AddFormat(REGEX_BREAK, "<br/>", true);

            Alternate       = alternate;
            EmbedStyleSheet = embedStyleSheet;
            LineNumbers     = lineNumbers;
        }
        public override bool TryGet(Type type, out IMessagePackFormatter formatter)
        {
            if (!base.TryGet(type, out formatter))
            {
                Type formatterType = null;

                switch (type)
                {
                case Type collectionType when collectionType.IsArray:
                {
                    formatterType = typeof(CollectionFormatterArray <>).MakeGenericType(collectionType.GetElementType());
                    break;
                }

                case Type collectionType when collectionType.IsConstructedGenericType && collectionType.GetGenericTypeDefinition() == typeof(List <>):
                {
                    formatterType = typeof(CollectionFormatterList <>).MakeGenericType(collectionType.GenericTypeArguments[0]);
                    break;
                }

                case Type collectionType when collectionType.IsConstructedGenericType && collectionType.GetGenericTypeDefinition() == typeof(Dictionary <,>):
                {
                    Type[] arguments = collectionType.GenericTypeArguments;

                    formatterType = typeof(CollectionFormatterDictionary <,>).MakeGenericType(arguments[0], arguments[1]);
                    break;
                }
                }

                if (formatterType != null)
                {
                    formatter = (IMessagePackFormatter)Activator.CreateInstance(formatterType, Provider, Context);

                    Formatters.Add(type, formatter);
                }

                return(formatter != null);
            }

            formatter = null;
            return(false);
        }
        public override bool TryGet(Type type, out IMessagePackFormatter formatter)
        {
            if (!base.TryGet(type, out formatter))
            {
                object formatterInner = Resolver.GetFormatterDynamic(type);

                if (formatterInner != null)
                {
                    Type formatterType = typeof(MessagePackFormatterWrapper <>).MakeGenericType(type);

                    formatter = (IMessagePackFormatter)Activator.CreateInstance(formatterType, this, Context, formatterInner, Resolver);

                    Formatters.Add(type, formatter);

                    return(true);
                }
            }

            return(formatter != null);
        }
예제 #15
0
 private void ConfigureFormatters()
 {
     Formatters.Add(new Formatting.BsonMediaTypeFormatter());
 }
예제 #16
0
 /// <summary>
 /// Convenience method for adding an operation to formatter mapping.
 /// </summary>
 /// <param name="operation">The operation to map</param>
 /// <param name="formatter">The corresponding formatter</param>
 public void AddMap(string operation, AuditMapFunc formatter)
 {
     Formatters.Add(operation, formatter);
 }
 public ImsxXmlMediaTypeResult(imsx_POXEnvelopeType value) : base(value)
 {
     // This formatter produces an imsx_POXEnvelopeType with an imsx_POXEnvelopeResponse
     Formatters.Add(new ImsxXmlMediaTypeOutputFormatter());
 }
        public override bool TryGet <T>(out IMessagePackFormatter <T> formatter)
        {
            Type type = typeof(T);

            if (type.IsEnum)
            {
                if (!base.TryGet(out formatter))
                {
                    Type     underlyingType = type.GetEnumUnderlyingType();
                    TypeCode typeCode       = Type.GetTypeCode(underlyingType);

                    switch (typeCode)
                    {
                    case TypeCode.Byte:
                    {
                        formatter = new EnumFormatterByte <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.Int16:
                    {
                        formatter = new EnumFormatterInt16 <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.Int32:
                    {
                        formatter = new EnumFormatterInt32 <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.Int64:
                    {
                        formatter = new EnumFormatterInt64 <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.SByte:
                    {
                        formatter = new EnumFormatterSByte <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.UInt16:
                    {
                        formatter = new EnumFormatterUInt16 <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.UInt32:
                    {
                        formatter = new EnumFormatterUInt32 <T>(Provider, Context);
                        break;
                    }

                    case TypeCode.UInt64:
                    {
                        formatter = new EnumFormatterUInt64 <T>(Provider, Context);
                        break;
                    }

                    default: throw new ArgumentOutOfRangeException(nameof(type), $"The specified enum underlying type not supported: '{underlyingType}.'");
                    }

                    Formatters.Add(type, formatter);
                }

                return(true);
            }

            formatter = null;
            return(false);
        }
        public override bool TryGet(Type type, out IMessagePackFormatter formatter)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (type.IsEnum)
            {
                if (!base.TryGet(type, out formatter))
                {
                    Type     underlyingType = type.GetEnumUnderlyingType();
                    TypeCode typeCode       = Type.GetTypeCode(underlyingType);
                    Type     formatterType;

                    switch (typeCode)
                    {
                    case TypeCode.Byte:
                    {
                        formatterType = typeof(EnumFormatterByte <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.Int16:
                    {
                        formatterType = typeof(EnumFormatterInt16 <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.Int32:
                    {
                        formatterType = typeof(EnumFormatterInt32 <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.Int64:
                    {
                        formatterType = typeof(EnumFormatterInt64 <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.SByte:
                    {
                        formatterType = typeof(EnumFormatterSByte <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.UInt16:
                    {
                        formatterType = typeof(EnumFormatterUInt16 <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.UInt32:
                    {
                        formatterType = typeof(EnumFormatterUInt32 <>).MakeGenericType(type);
                        break;
                    }

                    case TypeCode.UInt64:
                    {
                        formatterType = typeof(EnumFormatterUInt64 <>).MakeGenericType(type);
                        break;
                    }

                    default: throw new ArgumentOutOfRangeException(nameof(type), $"The specified enum underlying type not supported: '{underlyingType}.'");
                    }

                    formatter = (IMessagePackFormatter)Activator.CreateInstance(formatterType, Provider, Context);

                    Formatters.Add(type, formatter);
                }

                return(true);
            }

            formatter = null;
            return(false);
        }