Skip to content

Instantly share code, notes, and snippets.

@sailro
Last active November 9, 2017 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sailro/3ac44787050b66160bcd50cc328be1b4 to your computer and use it in GitHub Desktop.
Save sailro/3ac44787050b66160bcd50cc328be1b4 to your computer and use it in GitHub Desktop.
var referencePoint = (ISourceLocation) InsertionPoints.SelectedItem;
var context = _languageService.CurrentContext;
var scope = UnityPackage.Settings.UnityMessageScope.ToScope();
var generateComment = GenerateComment.IsChecked.HasValue && GenerateComment.IsChecked.Value;
UnityPackage.DTE.UnderUndoContext("MonoBehaviour Wizard", () =>
{
foreach (CheckedMethodInfoItem node in MonoBehaviourTree.Items)
{
if (!node.IsChecked.HasValue || !node.IsChecked.Value)
continue;
// Refresh insertionPoint to get up-to-date codemodel and line numbers
var insertionPoint = context.GetInsertionPoints().FirstOrDefault(p => p.Caption == referencePoint.Caption);
if (insertionPoint == null)
continue;
var method = node.Method;
var comment = generateComment ? UnityMessageHelper.GetHelp(method) : string.Empty;
context.InsertMethod(method, insertionPoint, comment, scope);
}
});
throttledTextBoxChanges = Observable
.FromEventPattern<TextChangedEventArgs>(TextBox, "TextChanged")
.Select(e => ((TextBox) e.Sender).Text.Trim())
.Throttle(TimeSpan.FromMilliseconds(200))
.DistinctUntilChanged()
.ObserveOn(SynchronizationContext.Current)
.Subscribe(ApplyFilter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment