示例#1
0
 public void Initialize()
 {
     _cssRegistrator = Substitute.For <ICssRegistrator>();
     _styleConveter  = Substitute.For <IStyleConverter>();
     _styleConveter.BuildRegistrator().Returns(_cssRegistrator);
     _config   = new StyleConfig();
     _instance = new StylePlugin(_styleConveter, _config);
     _css      = new StringBuilder();
     _state    = Substitute.For <IProcessingState>();
     _state.Css.Returns(_css);
     _state.Elements.Returns(_ => new ElementProcessingState[0]);
     _state.GetContext(out ICssRegistrator _)
     .Returns(x =>
     {
         x[0] = _cssRegistrator;
         return(true);
     });
     _parentVNode  = new VNode();
     _currentVNode = new VNode();
     _elemState    = Substitute.For <IElementProcessingState>();
     _elemState.ProcessingState.Returns(_state);
     _elemState
     .GetContext(out ParagraphContext _)
     .Returns(x =>
     {
         x[0] = new ParagraphContext {
             Parent = _parentVNode
         };
         return(true);
     });
     _elemState.CurrentVNode.Returns(_ => _currentVNode);
 }
示例#2
0
        public StyleProperty(string name, object defaultValue = null, bool transitionable = false, bool inherited = false, bool proxy = false, IStyleConverter converter = null)
        {
            this.type           = typeof(T);
            this.name           = name;
            this.defaultValue   = defaultValue;
            this.transitionable = transitionable;
            this.inherited      = inherited;
            this.proxy          = proxy;

            this.converter = converter ?? ParserMap.GetConverter(type);
        }
示例#3
0
        public LayoutProperty(string name, bool transitionable = false, T defaultValue = default)
        {
            this.name           = name;
            this.transitionable = transitionable;

            var ygType = typeof(YogaNode);

            propInfo = ygType.GetProperty(name, BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Instance);

            type      = propInfo.PropertyType;
            converter = ParserMap.GetConverter(type);

            if (converter == null)
            {
                UnityEngine.Debug.LogError("There is no converter for the type: " + type.Name);
            }

            this.defaultValue = defaultValue;
            setter            = (Action <YogaNode, T>)propInfo.GetSetMethod().CreateDelegate(typeof(Action <YogaNode, T>));
            getter            = (Func <YogaNode, T>)propInfo.GetGetMethod().CreateDelegate(typeof(Func <YogaNode, T>));
        }
示例#4
0
 public GeneralConverter(IStyleConverter baseConverter = null)
 {
     this.baseConverter = baseConverter;
 }
示例#5
0
 public StylePlugin(WordprocessingDocument wpDoc, StyleConfig config)
 {
     _styleConverter = StyleConverterFactory.Build(wpDoc, config);
     _config         = config;
 }
示例#6
0
 public StylePlugin(IStyleConverter styleConverter) : this(styleConverter, new StyleConfig())
 {
 }
示例#7
0
 public StylePlugin(IStyleConverter styleConverter, StyleConfig config)
 {
     _styleConverter = styleConverter;
     _config         = config;
 }