|
|
@ -19,7 +19,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// A code snippet.
|
|
|
|
/// A code snippet.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class CodeSnippet : INotifyPropertyChanged, IEquatable<CodeSnippet> |
|
|
|
public class CodeSnippet : AbstractFreezable, INotifyPropertyChanged |
|
|
|
{ |
|
|
|
{ |
|
|
|
string name = string.Empty, description = string.Empty, text = string.Empty, keyword = string.Empty; |
|
|
|
string name = string.Empty, description = string.Empty, text = string.Empty, keyword = string.Empty; |
|
|
|
|
|
|
|
|
|
|
@ -38,6 +38,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
public string Name { |
|
|
|
public string Name { |
|
|
|
get { return name; } |
|
|
|
get { return name; } |
|
|
|
set { |
|
|
|
set { |
|
|
|
|
|
|
|
CheckBeforeMutation(); |
|
|
|
if (name != value) { |
|
|
|
if (name != value) { |
|
|
|
name = value ?? string.Empty; |
|
|
|
name = value ?? string.Empty; |
|
|
|
OnPropertyChanged("Name"); |
|
|
|
OnPropertyChanged("Name"); |
|
|
@ -48,6 +49,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
public string Text { |
|
|
|
public string Text { |
|
|
|
get { return text; } |
|
|
|
get { return text; } |
|
|
|
set { |
|
|
|
set { |
|
|
|
|
|
|
|
CheckBeforeMutation(); |
|
|
|
if (text != value) { |
|
|
|
if (text != value) { |
|
|
|
text = value ?? string.Empty; |
|
|
|
text = value ?? string.Empty; |
|
|
|
OnPropertyChanged("Text"); |
|
|
|
OnPropertyChanged("Text"); |
|
|
@ -58,6 +60,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
public string Description { |
|
|
|
public string Description { |
|
|
|
get { return description; } |
|
|
|
get { return description; } |
|
|
|
set { |
|
|
|
set { |
|
|
|
|
|
|
|
CheckBeforeMutation(); |
|
|
|
if (description != value) { |
|
|
|
if (description != value) { |
|
|
|
description = value ?? string.Empty; |
|
|
|
description = value ?? string.Empty; |
|
|
|
OnPropertyChanged("Description"); |
|
|
|
OnPropertyChanged("Description"); |
|
|
@ -76,6 +79,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
public string Keyword { |
|
|
|
public string Keyword { |
|
|
|
get { return keyword; } |
|
|
|
get { return keyword; } |
|
|
|
set { |
|
|
|
set { |
|
|
|
|
|
|
|
CheckBeforeMutation(); |
|
|
|
if (keyword != value) { |
|
|
|
if (keyword != value) { |
|
|
|
keyword = value ?? string.Empty; |
|
|
|
keyword = value ?? string.Empty; |
|
|
|
OnPropertyChanged("Keyword"); |
|
|
|
OnPropertyChanged("Keyword"); |
|
|
@ -226,41 +230,12 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int hashCode = 0; |
|
|
|
|
|
|
|
unchecked { |
|
|
|
|
|
|
|
if (name != null) |
|
|
|
|
|
|
|
hashCode += 1000000007 * name.GetHashCode(); |
|
|
|
|
|
|
|
if (description != null) |
|
|
|
|
|
|
|
hashCode += 1000000009 * description.GetHashCode(); |
|
|
|
|
|
|
|
if (text != null) |
|
|
|
|
|
|
|
hashCode += 1000000021 * text.GetHashCode(); |
|
|
|
|
|
|
|
if (keyword != null) |
|
|
|
|
|
|
|
hashCode += 1000000033 * keyword.GetHashCode(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return hashCode; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CodeSnippet other = obj as CodeSnippet; |
|
|
|
|
|
|
|
return Equals(other); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(CodeSnippet other) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (other == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
return this.name == other.name && this.description == other.description && this.text == other.text && this.keyword == other.keyword; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Reports the snippet usage to UDC
|
|
|
|
/// Reports the snippet usage to UDC
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
internal void TrackUsage(string activationMethod) |
|
|
|
internal void TrackUsage(string activationMethod) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isUserModified = !SnippetManager.defaultSnippets.Any(g => g.Snippets.Contains(this)); |
|
|
|
bool isUserModified = !SnippetManager.Instance.defaultSnippets.Any(g => g.Snippets.Contains(this, CodeSnippetComparer.Instance)); |
|
|
|
Core.AnalyticsMonitorService.TrackFeature(typeof(CodeSnippet), isUserModified ? "usersnippet" : Name, activationMethod); |
|
|
|
Core.AnalyticsMonitorService.TrackFeature(typeof(CodeSnippet), isUserModified ? "usersnippet" : Name, activationMethod); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|