コード例 #1
0
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;
            switch (style)
            {
                case SyntaxStyle.Added:
                    disposeAction = WriteColor("green");
                    break;

                case SyntaxStyle.Removed:
                    string extraStyle = this.StrikeOutRemoved ? " text-decoration:line-through;" : "";
                    disposeAction = WriteColor("red", extraStyle);
                    break;

                case SyntaxStyle.InheritedMember:
                case SyntaxStyle.InterfaceMember:
                case SyntaxStyle.Comment:
                    disposeAction = WriteColor("gray");
                    break;
                case SyntaxStyle.NotCompatible:
                    disposeAction = WriteBackground("yellow", context);
                    break;

                default:
                    throw new NotSupportedException("Style not supported!");
            }

            Contract.Assert(disposeAction != null);
            return new DisposeAction(() => disposeAction.Dispose());
        }
コード例 #2
0
ファイル: DiffRecorder.cs プロジェクト: layomia/dotnet_arcade
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            var convertedStyle = ConvertStyle(style);

            _styleStack.Push(convertedStyle);
            return(new DisposeAction(() => _styleStack.Pop()));
        }
コード例 #3
0
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;

            switch (style)
            {
            case SyntaxStyle.Added:
                disposeAction = WriteColor("green");
                break;

            case SyntaxStyle.Removed:
                string extraStyle = this.StrikeOutRemoved ? " text-decoration:line-through;" : "";
                disposeAction = WriteColor("red", extraStyle);
                break;

            case SyntaxStyle.InheritedMember:
            case SyntaxStyle.InterfaceMember:
            case SyntaxStyle.Comment:
                disposeAction = WriteColor("gray");
                break;

            case SyntaxStyle.NotCompatible:
                disposeAction = WriteBackground("yellow", context);
                break;

            default:
                throw new NotSupportedException("Style not supported!");
            }

            Contract.Assert(disposeAction != null);
            return(new DisposeAction(() => disposeAction.Dispose()));
        }
コード例 #4
0
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;

            switch (style)
            {
            case SyntaxStyle.Added:
                disposeAction = WriteVersion("2");
                break;

            case SyntaxStyle.Removed:
                disposeAction = WriteVersion("1");
                break;

            case SyntaxStyle.InterfaceMember:
            case SyntaxStyle.InheritedMember:
            case SyntaxStyle.Comment:
                disposeAction = null;
                break;

            case SyntaxStyle.NotCompatible:
                disposeAction = null;
                break;

            default:
                throw new NotSupportedException("Style not supported!");
            }

            if (disposeAction == null)
            {
                return(new DisposeAction(() => { }));
            }

            return(new DisposeAction(() => disposeAction.Dispose()));
        }
コード例 #5
0
ファイル: TextSyntaxWriter.cs プロジェクト: pgavlin/ApiTools
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;
            switch (style)
            {
                case SyntaxStyle.Added:
                    disposeAction = WriteVersion("2");
                    break;

                case SyntaxStyle.Removed:
                    disposeAction = WriteVersion("1");
                    break;

                case SyntaxStyle.InterfaceMember:
                case SyntaxStyle.InheritedMember:
                case SyntaxStyle.Comment:
                    disposeAction = null;
                    break;

                case SyntaxStyle.NotCompatible:
                    disposeAction = null;
                    break;

                default:
                    throw new NotSupportedException("Style not supported!");
            }

            if (disposeAction == null)
                return new DisposeAction(() => { });

            return new DisposeAction(() => disposeAction.Dispose());
        }
コード例 #6
0
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;
            switch (style)
            {
                case SyntaxStyle.Added:
                    disposeAction = _styles.SetColor("green");
                    break;

                case SyntaxStyle.Removed:
                    disposeAction = _styles.SetColor("red");
                    break;

                case SyntaxStyle.InheritedMember:
                case SyntaxStyle.InterfaceMember:
                case SyntaxStyle.Comment:
                    disposeAction = _styles.SetColor("gray");
                    break;
                case SyntaxStyle.NotCompatible:
                    disposeAction = _styles.SetBgColor("yellow");
                    break;

                default:
                    throw new NotSupportedException("Style not supported!");
            }

            Contract.Assert(disposeAction != null);
            return new DisposeAction(() => disposeAction.Dispose());
        }
コード例 #7
0
        public IDisposable StartStyle(SyntaxStyle style, object context)
        {
            IDisposable disposeAction = null;

            switch (style)
            {
            case SyntaxStyle.Added:
                disposeAction = _styles.SetColor("green");
                break;

            case SyntaxStyle.Removed:
                disposeAction = _styles.SetColor("red");
                break;

            case SyntaxStyle.InheritedMember:
            case SyntaxStyle.InterfaceMember:
            case SyntaxStyle.Comment:
                disposeAction = _styles.SetColor("gray");
                break;

            case SyntaxStyle.NotCompatible:
                disposeAction = _styles.SetBgColor("yellow");
                break;

            default:
                throw new NotSupportedException("Style not supported!");
            }

            Contract.Assert(disposeAction != null);
            return(new DisposeAction(() => disposeAction.Dispose()));
        }
コード例 #8
0
ファイル: Config.cs プロジェクト: AmadeusW/Codist
        public void SaveConfig(string path, bool stylesOnly = false)
        {
            path = path ?? ConfigPath;
            try {
                var d = Path.GetDirectoryName(path);
                if (Directory.Exists(d) == false)
                {
                    Directory.CreateDirectory(d);
                }
                object o;
                if (stylesOnly)
                {
                    o = new {
                        Version = CurrentVersion,
                        Styles  = GetCustomizedStyles()
                    };
                }
                else
                {
                    o       = this;
                    Version = CurrentVersion;
                    Styles  = GetCustomizedStyles().ToList();
                }
                File.WriteAllText(path, JsonConvert.SerializeObject(
                                      o,
                                      Formatting.Indented,
                                      new JsonSerializerSettings {
                    DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
                    NullValueHandling    = NullValueHandling.Ignore,
                    Converters           = { new Newtonsoft.Json.Converters.StringEnumConverter() }
                }));
                if (path == ConfigPath)
                {
                    _LastSaved = _LastLoaded = DateTime.Now;
                    //_ConfigManager?.MarkVersioned();
                    Debug.WriteLine("Config saved");
                }
            }
            catch (Exception ex) {
                Debug.WriteLine(ex.ToString());
            }
            finally {
                Styles = null;
            }

            IEnumerable <SyntaxStyle> GetCustomizedStyles()
            {
                return(FormatStore.GetStyles()
                       .Where(i => i.Value?.IsSet == true)
                       .Select(i => { var s = new SyntaxStyle(i.Key); i.Value.CopyTo(s); return s; }));
            }
        }
コード例 #9
0
        public static StyleBase GetOrCreateStyle(IClassificationType classificationType)
        {
            var c = classificationType.Classification;

            lock (_syncRoot) {
                if (_SyntaxStyleCache.TryGetValue(c, out var r))
                {
                    return(r);
                }
                else
                {
                    r = new SyntaxStyle(c);
                    _SyntaxStyleCache.Add(c, r);
                    return(r);
                }
            }
        }
コード例 #10
0
ファイル: DiffRecorder.cs プロジェクト: layomia/dotnet_arcade
        private static DiffStyle ConvertStyle(SyntaxStyle style)
        {
            switch (style)
            {
            case SyntaxStyle.Added:
                return(DiffStyle.Added);

            case SyntaxStyle.Removed:
                return(DiffStyle.Removed);

            case SyntaxStyle.InterfaceMember:
                return(DiffStyle.InterfaceMember);

            case SyntaxStyle.InheritedMember:
                return(DiffStyle.InheritedMember);

            case SyntaxStyle.NotCompatible:
                return(DiffStyle.NotCompatible);

            default:
                throw new ArgumentOutOfRangeException("style");
            }
        }
コード例 #11
0
 public static IDisposable StartStyle(this IStyleSyntaxWriter writer, SyntaxStyle style)
 {
     return writer.StartStyle(style, null);
 }
コード例 #12
0
 public IDisposable StartStyle(SyntaxStyle style, object context)
 {
     _currentStyle = style;
     return new DisposeAction(() => { });
 }
コード例 #13
0
 public static IDisposable StartStyle(this IStyleSyntaxWriter writer, SyntaxStyle style)
 {
     return(writer.StartStyle(style, null));
 }
コード例 #14
0
 public IDisposable StartStyle(SyntaxStyle style, object context)
 {
     _currentStyle = style;
     return(new DisposeAction(() => { }));
 }