示例#1
0
 public ParagraphClassFactory(
     NameGenerator clsNameGenerator,
     IDefaultsProvider defaultsProvider,
     IStylePropsCache stylePropsCache,
     INumberingPropsCache numPropsCache,
     ICssPropertiesFactory propsFac)
 {
     _clsNameGenerator = clsNameGenerator;
     _propsFac         = propsFac;
     _stylePropsCache  = stylePropsCache;
     _numPropsCache    = numPropsCache;
     _defaultsProvider = defaultsProvider;
 }
示例#2
0
 public ParagraphClassFactory(
     StyleConfig config,
     ClsNameGenerator clsNameGenerator,
     IDefaultsProvider defaultsProvider,
     IStylePropsCache stylePropsCache,
     INumberingPropsCache numPropsCache,
     Func <CssPropertySource, ICssPropertiesFactory> _facBuiler)
 {
     _config           = config;
     _clsNameGenerator = clsNameGenerator;
     _propsFac         = _facBuiler(CssPropertySource.Paragraph);
     _stylePropsCache  = stylePropsCache;
     _numPropsCache    = numPropsCache;
     _defaultsProvider = defaultsProvider;
 }
示例#3
0
 public RunClassFactory(
     NameGenerator clsNameGenerator,
     IDefaultsProvider defaults,
     IStylePropsCache pStylePropsCache,
     INumberingPropsCache numPropsCache,
     IStylePropsCache rStylePropsCache,
     ICssPropertiesFactory propsFac)
 {
     _clsNameGenerator = clsNameGenerator;
     _defaults         = defaults;
     _pStylePropsCache = pStylePropsCache;
     _numPropsCache    = numPropsCache;
     _rStylePropsCache = rStylePropsCache;
     _propsFac         = propsFac;
 }
示例#4
0
        public CssPropertiesFactory(
            StyleConfig styleConfig,
            IThemeFontsProvider themeFontsProvider,
            IThemeColorsProvider themeColorProvider,
            INumberingProvider numberingProvider,
            IDefaultsProvider defaultsProvider)
        {
            _styleConfig        = styleConfig;
            _themeColorProvider = themeColorProvider;
            _themeFontsProvider = themeFontsProvider;
            _numberingProvider  = numberingProvider;
            _defaultsProvider   = defaultsProvider;

            Initialize();
        }
示例#5
0
 public RunClassFactory(
     StyleConfig config,
     ClsNameGenerator clsNameGenerator,
     IDefaultsProvider defaults,
     IStylePropsCache pStylePropsCache,
     INumberingPropsCache numPropsCache,
     IStylePropsCache rStylePropsCache,
     Func <CssPropertySource, ICssPropertiesFactory> factoryBuilder)
 {
     _config           = config;
     _clsNameGenerator = clsNameGenerator;
     _defaults         = defaults;
     _pStylePropsCache = pStylePropsCache;
     _numPropsCache    = numPropsCache;
     _rStylePropsCache = rStylePropsCache;
     _propsFac         = factoryBuilder(CssPropertySource.Run);
 }
        private static void ReadDefaults(Type t)
        {
            lock ( __defaults ) {
                string key = t.FullName;
                if (__defaults.ContainsKey(key))
                {
                    return;
                }

                IDefaultsProvider dp = GetDefaultsProvider(t);

                IEnumerable <Type> types = t.SelectManyRecursiveInclusive(
                    t2 => t2.GetInterfaces( ));

                // read default values
                List <PropertyInfo> props =
                    types.SelectMany(
                        t2 => t2.GetProperties( )
                        .Where(p => p.GetAttribute <ConfigValueAttribute>( ) != null)
                        )
                    .ToList( );
                Dictionary <string, Tuple <object, Type> > defaults =
                    new Dictionary <string, Tuple <object, Type> >(props.Count);
                props.ForEach(
                    pi =>
                    defaults[pi.Name] =
                        new Tuple <object, Type>(
                            pi.GetAttribute <ConfigValueAttribute>( ).Default ?? dp?.GetDefault(pi.Name),
                            pi.PropertyType));
                __defaults[key] = defaults;

                // get property infos
                Dictionary <string, PropertyInfo> propMap = new Dictionary <string, PropertyInfo>( );
                props.ForEach(
                    pi => {
                    propMap[pi.GetMethod.Name] = pi;
                    propMap[pi.SetMethod.Name] = pi;
                });
                __propMaps[key] = propMap;
            }
        }
示例#7
0
        public void Initialize()
        {
            _config   = new StyleConfig();
            _defaults = Substitute.For <IDefaultsProvider>();
            _defaults.Run.Returns(new CssPropertiesSet());
            _pStylePropsCache = Substitute.For <IStylePropsCache>();
            _numPropsCache    = Substitute.For <INumberingPropsCache>();
            _rStylePropsCache = Substitute.For <IStylePropsCache>();
            _rStylePropsCache.Get(Arg.Any <string>()).Returns(new CssPropertiesSet());
            _propsFac = Substitute.For <ICssPropertiesFactory>();
            _propsFac.Build(null).ReturnsForAnyArgs(x => new CssPropertiesSet());

            _instance = new RunClassFactory(
                _config,
                new ClsNameGenerator(_config),
                _defaults,
                _pStylePropsCache,
                _numPropsCache,
                _rStylePropsCache,
                FacBuilder);
        }
示例#8
0
 public void Initialize()
 {
     _propsFac = Substitute.For <ICssPropertiesFactory>();
     _propsFac
     .Build(Arg.Any <OpenXmlElement>())
     .ReturnsForAnyArgs(x => new CssPropertiesSet());
     _stylePropsCache = Substitute.For <IStylePropsCache>();
     _stylePropsCache.Get(Arg.Any <string>())
     .Returns(new CssPropertiesSet());
     _numPropsCache = Substitute.For <INumberingPropsCache>();
     _defaults      = Substitute.For <IDefaultsProvider>();
     _defaults.Paragraph.Returns(new CssPropertiesSet());
     _nameGen = new NameGenerator()
     {
         Prefix = "d"
     };
     _instance = new ParagraphClassFactory(
         _nameGen,
         _defaults,
         _stylePropsCache,
         _numPropsCache,
         _propsFac);
 }
示例#9
0
 public void Initialize()
 {
     _defaults = Substitute.For <IDefaultsProvider>();
     _defaults.Run.Returns(new CssPropertiesSet());
     _defaults.DefaultRunStyle.Returns(x => null);
     _defaults.DefaultParagraphStyle.Returns(x => null);
     _pStylePropsCache = Substitute.For <IStylePropsCache>();
     _numPropsCache    = Substitute.For <INumberingPropsCache>();
     _rStylePropsCache = Substitute.For <IStylePropsCache>();
     _rStylePropsCache.Get(Arg.Any <string>()).Returns(new CssPropertiesSet());
     _propsFac = Substitute.For <ICssPropertiesFactory>();
     _propsFac.Build(null).ReturnsForAnyArgs(x => new CssPropertiesSet());
     _nameGen = new NameGenerator()
     {
         Prefix = "d"
     };
     _instance = new RunClassFactory(
         _nameGen,
         _defaults,
         _pStylePropsCache,
         _numPropsCache,
         _rStylePropsCache,
         _propsFac);
 }
示例#10
0
 public static void OverrideDefault(IDefaultsProvider provider)
 {
     _Default = provider;
 }