DocSpace-buildtools/common/ASC.Textile/TextileFormatterBlocks.cs

54 lines
1.5 KiB
C#
Raw Normal View History

2019-08-19 12:35:39 +00:00
#region License Statement
// Copyright (c) L.A.B.Soft. All rights reserved.
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.
#endregion
2022-02-17 09:08:01 +00:00
namespace Textile;
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
public partial class TextileFormatter
{
#region Block Modifiers Registration
2019-08-19 12:35:39 +00:00
private static readonly List<BlockModifier> _blockModifiers = new List<BlockModifier>();
private static readonly List<Type> _blockModifiersTypes = new List<Type>();
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
public static void RegisterBlockModifier(BlockModifier blockModifer)
{
_blockModifiers.Add(blockModifer);
_blockModifiersTypes.Add(blockModifer.GetType());
2022-02-17 09:08:01 +00:00
}
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
#endregion
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
#region Block Modifiers Management
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
private readonly List<Type> _disabledBlockModifiers = new List<Type>();
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
public bool IsBlockModifierEnabled(Type type)
{
return !_disabledBlockModifiers.Contains(type);
}
2019-08-19 12:35:39 +00:00
2022-02-17 09:08:01 +00:00
public void SwitchBlockModifier(Type type, bool onOff)
{
if (onOff)
2022-03-17 15:01:39 +00:00
{
2022-02-17 09:08:01 +00:00
_disabledBlockModifiers.Remove(type);
2022-03-17 15:01:39 +00:00
}
2022-02-17 09:08:01 +00:00
else if (!_disabledBlockModifiers.Contains(type))
2022-03-17 15:01:39 +00:00
{
2022-02-17 09:08:01 +00:00
_disabledBlockModifiers.Add(type);
2022-03-17 15:01:39 +00:00
}
2019-08-19 12:35:39 +00:00
}
2022-02-17 09:08:01 +00:00
#endregion
2019-08-19 12:35:39 +00:00
}