<|start_filename|>templates/_composition/MVVMLight/Feature.ShareTarget/ViewModels/SharedDataViewModelBase_postaction.cs<|end_filename|>
﻿//{[{
using GalaSoft.MvvmLight;
//}]}

<|start_filename|>code/test/Core.Test/TestData/Templates/_catalog/en-US.frameworks.json<|end_filename|>
[
  {
    "name": "TestFramework",
    "displayName": "Test Framework",
    "summary": "Test Framework Summary"
  }
]

<|start_filename|>code/src/UI/Services/DragAndDropService/DragAndDropEventArgs`1.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.ObjectModel;
using System.Windows;

namespace Microsoft.Templates.UI.Services
{
    public class DragAndDropEventArgs<T> : EventArgs
        where T : class
    {
        public ObservableCollection<T> Items { get; }

        public T ItemData { get; }

        public int OldIndex { get; }

        public int NewIndex { get; }

        public DragDropEffects Effects { get; }

        public DragAndDropEventArgs(ObservableCollection<T> items, T dataItem, int oldIndex, int newIndex, DragDropEffects effects = DragDropEffects.None)
        {
            Items = items;
            ItemData = dataItem;
            OldIndex = oldIndex;
            NewIndex = newIndex;
            Effects = effects;
        }
    }
}


<|start_filename|>code/src/UI/Extensions/DependencyObjectExtensions.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Media;

namespace Microsoft.Templates.UI
{
    public static class DependencyObjectExtensions
    {
        public static IEnumerable<T> ChildrenOfType<T>(this DependencyObject dObject, bool includeInheritance = false)
            where T : DependencyObject
        {
            int count = VisualTreeHelper.GetChildrenCount(dObject);

            for (int i = 0; i < count; i++)
            {
                var current = VisualTreeHelper.GetChild(dObject, i);

                if (current.GetType().Equals(typeof(T)) || (includeInheritance && current.GetType().GetTypeInfo().IsSubclassOf(typeof(T))))
                {
                    yield return current as T;
                }

                foreach (var children in current.ChildrenOfType<T>(includeInheritance))
                {
                    yield return children;
                }
            }
        }
    }
}


<|start_filename|>code/src/Core/PostActions/Catalog/Merge/ResourceDictionaryWriter.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace Microsoft.Templates.Core.PostActions.Catalog.Merge
{
    public class ResourceDictionaryWriter : XmlTextWriter
    {
        private TextWriter writer;
        private const string Intend = "    ";

        public ResourceDictionaryWriter(TextWriter w)
            : base(w)
        {
            writer = w;
        }

        public ResourceDictionaryWriter(Stream w, Encoding encoding)
            : base(w, encoding)
        {
        }

        public ResourceDictionaryWriter(string filename, Encoding encoding)
            : base(filename, encoding)
        {
        }

        public override void WriteStartElement(string prefix, string localName, string ns)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                localName = prefix + ":" + localName;
                prefix = string.Empty;
            }

            base.WriteStartElement(prefix, localName, ns);
        }

        public new void WriteAttributeString(string prefix, string localName,  string value)
        {
            if (!string.IsNullOrEmpty(prefix))
            {
                localName = prefix + ":" + localName;
            }

            WriteAttributeString(localName, value);
        }

        public void WriteResourceDictionary(XElement e)
        {
            WriteStartElement(e.Name.LocalName);
            WriteNamespaceDeclaration("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            WriteNamespaceDeclaration("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml");
            WriteNewLine();
            WriteNewLine();
            foreach (var node in e.Elements())
            {
                WriteElement(node);
            }

            WriteFullEndElement();
            WriteNewLine();
        }

        private void WriteElement(XElement e)
        {
            WriteComments(e);
            WriteRaw(Intend);
            WriteStartElement(e.GetPrefixOfNamespace(e.Name.Namespace), e.Name.LocalName, string.Empty);
            WriteAttributes(e);
            if (e.Descendants().Count() > 0)
            {
                WriteChildElements(e);
            }
            else
            {
                WriteRaw(e.Value);
            }

            WriteEndElement();
            WriteNewLine();
            if (e.Name.LocalName == "Style")
            {
                WriteNewLine();
            }
        }

        private void WriteNewLine()
        {
            WriteRaw("\r\n");
        }

        private void WriteNamespaceDeclaration(string key, string value)
        {
            writer.WriteLine();
            WriteAttributeString("   " + key, value);
        }

        private void WriteComments(XElement e)
        {
            if (e.PreviousNode != null && e.PreviousNode.NodeType == XmlNodeType.Comment)
            {
                WriteRaw(Intend);
                WriteComment((e.PreviousNode as XComment).Value);
                WriteNewLine();
            }
        }

        private void WriteChildElements(XElement e)
        {
            WriteNewLine();
            foreach (var n in e.Descendants())
            {
                WriteRaw(Intend);
                WriteRaw(Intend);
                WriteStartElement(e.GetPrefixOfNamespace(n.Name.Namespace), n.Name.LocalName, string.Empty);
                WriteAttributes(n);
                WriteEndElement();
                WriteNewLine();
            }

            WriteRaw(Intend);
        }

        private void WriteAttributes(XElement e)
        {
            foreach (var a in e.Attributes())
            {
                WriteAttributeString(e.GetPrefixOfNamespace(a.Name.Namespace), a.Name.LocalName, a.Value);
            }
        }
    }
}


<|start_filename|>code/src/Core/Diagnostics/FormattedWriterMessages.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;

using Microsoft.Templates.Core.Resources;

namespace Microsoft.Templates.Core.Diagnostics
{
    public class FormattedWriterMessages
    {
        private static string exHeader = $"===================== {StringRes.ExceptionInfoString} =====================";

        public static string ExHeader
        {
            get { return exHeader; }
        }

        public const string ExFooter = "----------------------------------------------------------";

        public static string LogEntryStart
        {
            get
            {
                return $"[{DateTime.Now.FormatAsFullDateTime()}]\t{Environment.UserName}\t{Process.GetCurrentProcess().Id}({System.Threading.Thread.CurrentThread.ManagedThreadId})\t";
            }
        }
    }
}


<|start_filename|>templates/Features/BackgroundTaskVB/.template.config/de-DE.template.json<|end_filename|>
﻿{
    "author": "Microsoft Community",
    "name": "Background Task",
    "description": "Fügen Sie eine In-Process-Hintergrundaufgabe hinzu, um Code auszuführen, auch wenn die App nicht im Vordergrund ist.",
    "identity": "wts.Feat.BackgroundTask.VB"
}


<|start_filename|>code/test/Core.Test/TestData/Templates/_catalog/en-US.projectTypes.json<|end_filename|>
[
  {
    "name": "TestProjectType",
    "displayName": "Test Project Type",
    "summary": "Test Project Type Summary"
  }
]

<|start_filename|>samples/navigation/MixedNavigationSample.MVVMLight/MixedNavigationSample.MVVMLight/ViewModels/StartViewModel.cs<|end_filename|>
﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;

using MixedNavigationSample.MVVMLight.Services;

using System.Windows.Input;

using Windows.UI.Xaml;


namespace MixedNavigationSample.MVVMLight.ViewModels
{
    public class StartViewModel : ViewModelBase
    {
        private ViewModelLocator Locator => Application.Current.Resources["Locator"] as ViewModels.ViewModelLocator;
        private NavigationServiceEx NavigationService => Locator.NavigationService;
        public ICommand StartCommand { get; set; }

        public StartViewModel()
        {
            StartCommand = new RelayCommand(OnStart);
        }

        private void OnStart()
        {
            //Set Window.Current.Content to a new ShellPage, this will replace NavigationService frame for an inner frame to change navigation handling.
            Window.Current.Content = new Views.ShellPage();

            //Navigating now to a HomePage, this will be the first navigation on a NavigationPane menu
            NavigationService.Navigate(typeof(ViewModels.HomeViewModel).FullName);
        }
    }
}


<|start_filename|>samples/notifications/ToastNotificationSample/ToastNotificationSample/ViewModels/MainViewModel.cs<|end_filename|>
﻿using System;

using ToastNotificationSample.Helpers;

namespace ToastNotificationSample.ViewModels
{
    public class MainViewModel : Observable
    {
        public MainViewModel()
        {
        }
    }
}


<|start_filename|>templates/Pages/Map.CaliburnMicro/.template.config/pl-PL.template.json<|end_filename|>
﻿{
  "author": "Microsoft Community",
  "name": "Map",
  "description": "Strona mapy opiera się na kontrolce mapy systemu Windows. Kod obejmuje dodawanie ikony mapy i uzyskiwanie lokalizacji.",
  "identity": "wts.Page.Map.CaliburnMicro"
}

<|start_filename|>code/src/Core/Packaging/InvalidSignatureException.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace Microsoft.Templates.Core.Packaging
{
    [Serializable]
    public class InvalidSignatureException : Exception
    {
        public InvalidSignatureException()
        {
        }

        public InvalidSignatureException(string message)
            : base(message)
        {
        }

        public InvalidSignatureException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        protected InvalidSignatureException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
    }
}


<|start_filename|>code/test/Templates.Test/RunWackTest.bat<|end_filename|>
REM #Setup MsBuild context by brute force, restore packages and build the solution
IF EXIST "%ProgramFiles(x86)%\Windows Kits\10\App Certification Kit" (
	GOTO DEV15
)
ELSE (
	GOTO ERROR
)

:DEV15
	ECHO ON
	
	"%ProgramFiles(x86)%\Windows Kits\10\App Certification Kit\appcert.exe" reset
	"%ProgramFiles(x86)%\Windows Kits\10\App Certification Kit\appcert.exe" test -appxpackagepath "%~1" -reportoutputpath "%~2"

	IF %ERRORLEVEL% NEQ 0 (
		GOTO ERROR
	)
	ECHO OFF

GOTO END

:ERROR
	EXIT 1
:END


<|start_filename|>templates/Pages/ChartVB/.template.config/cs-CZ.template.json<|end_filename|>
﻿{
    "author": "Microsoft Community",
    "name": "Chart",
    "description": "Na této stránce se zobrazuje jednoduchý graf, který používá ovládací prvky uživatelského rozhraní Telerik pro UWP.",
    "identity": "wts.Page.Chart.VB"
}


<|start_filename|>code/test/VsEmulator/TemplatesContent/TemplatesContentView.xaml.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows;

namespace Microsoft.Templates.VsEmulator.TemplatesContent
{
    /// <summary>
    /// Interaction logic for TemplatesContentView.xaml
    /// </summary>
    public partial class TemplatesContentView : Window
    {
        public TemplatesContentViewModel ViewModel { get; set; }

        public TemplatesContentView(string wizardVersion, string templateVersion)
        {
            ViewModel = new TemplatesContentViewModel(this, wizardVersion, templateVersion);

            InitializeComponent();

            DataContext = ViewModel;

            Loaded += (o, e) =>
            {
                ViewModel.Initialize();
            };
        }
    }
}


<|start_filename|>code/src/Core/Composition/InvalidCompositionQueryException.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace Microsoft.Templates.Core.Composition
{
    [Serializable]
    public class InvalidCompositionQueryException : Exception
    {
        public InvalidCompositionQueryException()
        {
        }

        public InvalidCompositionQueryException(string message)
            : base(message)
        {
        }

        public InvalidCompositionQueryException(string message, Exception innerException)
            : base(message, innerException)
        {
        }

        protected InvalidCompositionQueryException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
    }
}


<|start_filename|>code/src/Core/Extensions/DateTimeExtensions.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Templates.Core
{
    public static class DateTimeExtensions
    {
        public static string FormatAsDateForFilePath(this DateTime date)
        {
            return date.ToString("yyyyMMdd");
        }

        public static string FormatAsFullDateTime(this DateTime date)
        {
            return date.ToString("yyyy-MM-dd HH:mm:ss.fff");
        }

        public static string FormatAsTime(this DateTime date)
        {
            return date.ToString("HH:mm:ss.fff");
        }

        public static string FormatAsShortDateTime(this DateTime date)
        {
            return date.ToString("yyyyMMdd_HHmmss");
        }

        public static string FormatAsDateHoursMinutes(this DateTime date)
        {
            return date.ToString("ddHHmmss");
        }
    }
}


<|start_filename|>templates/Features/SuspendAndResume/.template.config/de-DE.template.json<|end_filename|>
﻿{
  "author": "Microsoft",
  "name": "<NAME>",
  "description": "Ein einfacher Dienst, den Sie verwenden können, um den Fall zu verarbeiten, dass ein Benutzer die App verlässt und wieder zu ihr zurückkehrt.",
  "identity": "wts.Feat.SuspendAndResume"
}

<|start_filename|>templates/_composition/MVVMLight/Feature.ShareTarget/App_postaction.xaml.cs<|end_filename|>
﻿//{**
// This code block adds the OnShareTargetActivated event handler to the App class of your project.
//**}
namespace Param_RootNamespace
{
    public sealed partial class App : Application
    {
//^^
//{[{

        protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
        {
            await ActivationService.ActivateFromShareTargetAsync(args);
        }
//}]}
    }
}


<|start_filename|>code/src/Core/Extensions/DictionaryExtensions.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace Microsoft.Templates.Core
{
    public static class DictionaryExtensions
    {
        public static TValue SafeGet<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultResult = default(TValue))
        {
            if (dictionary.ContainsKey(key))
            {
                return dictionary[key];
            }

            return defaultResult;
        }
    }
}


<|start_filename|>templates/Pages/Map.CodeBehindVB/.template.config/tr-TR.template.json<|end_filename|>
﻿{
    "author": "Microsoft Community",
    "name": "Map",
    "description": "Harita sayfası, Harita Denetimi\u0027ni esas alır. Kod bir Harita Simgesi ekleme ve konumunuzu ayarlama işlevlerini içerir.",
    "identity": "wts.Page.Map.CodeBehind.VB"
}


<|start_filename|>code/test/Core.Test/Diagnostics/TestHealthWriter.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

using Microsoft.Templates.Core.Diagnostics;

namespace Microsoft.Templates.Core.Test.Diagnostics
{
    public class TestHealthWriter : IHealthWriter
    {
        public List<string> Events { get; set; } = new List<string>();

        public List<Exception> Exceptions { get; set; } = new List<Exception>();

        public async Task WriteTraceAsync(TraceEventType eventType, string message, Exception ex = null)
        {
            await Task.Run(() => Events.Add($"{eventType.ToString()};{message};{ex?.ToString()}"));
        }

        public async Task WriteExceptionAsync(Exception ex, string message = null)
        {
            await Task.Run(() => Exceptions.Add(ex));
        }

        public bool AllowMultipleInstances()
        {
            return true;
        }
    }
}


<|start_filename|>code/test/Core.Test/TestData/Templates/_catalog/es-ES.frameworks.json<|end_filename|>
[
  {
    "name": "TestFramework",
    "displayName": "Framework de prueba",
    "summary": "Resumen de Framework de prueba"
  }
]

<|start_filename|>templates/_composition/CaliburnMicro/Feature.ShareTarget/ViewModels/SharedDataViewModelBase_postaction.cs<|end_filename|>
﻿//{[{
using Caliburn.Micro;
//}]}

<|start_filename|>code/src/Core/PostActions/Catalog/SortNamespaces/UsingComparer.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.Templates.Core.PostActions.Catalog.SortNamespaces
{
    public class UsingComparer : NamespaceComparer
    {
        public override string Keyword => UsingComparer.UsingKeyword;

        public static string UsingKeyword => @"using";

        protected override string Pattern => Keyword + @"\s(?<Ns>.*?);";

        protected override bool StripTrailingCharacter => true;
    }
}


<|start_filename|>samples/navigation/MixedNavigationSample.MVVMBasic/MixedNavigationSample.MVVMBasic/ViewModels/StartViewModel.cs<|end_filename|>
﻿using System.Windows.Input;
using MixedNavigationSample.MVVMBasic.Helpers;
using MixedNavigationSample.MVVMBasic.Services;

namespace MixedNavigationSample.MVVMBasic.ViewModels
{
    public class StartViewModel : Observable
    {
        public ICommand StartCommand { get; set; }

        public StartViewModel()
        {
            StartCommand = new RelayCommand(OnStart);
        }

        private void OnStart()
        {
            //Navigating to a ShellPage, this will replaces NavigationService frame for an inner frame to change navigation handling.
            NavigationService.Navigate<Views.ShellPage>();

            //Navigating now to a HomePage, this will be the first navigation on a NavigationPane menu
            NavigationService.Navigate<Views.HomePage>();
        }
    }
}


<|start_filename|>templates/Features/SettingsStorage/.template.config/it-IT.template.json<|end_filename|>
﻿{
  "author": "Microsoft",
  "name": "Settings Storage",
  "description": "L'impostazione dell'archiviazione semplifica l'archiviazione dei dati all'interno della cartella dei dati dell'applicazione.",
  "identity": "wts.Feat.SettingsStorage"
}

<|start_filename|>samples/navigation/MixedNavigationSample.CodeBehind/MixedNavigationSample.CodeBehind/Views/StartPage.xaml.cs<|end_filename|>
﻿using MixedNavigationSample.CodeBehind.Services;

using System.ComponentModel;
using System.Runtime.CompilerServices;

using Windows.UI.Xaml.Controls;

namespace MixedNavigationSample.CodeBehind.Views
{
    public sealed partial class StartPage : Page, INotifyPropertyChanged
    {
        public StartPage()
        {
            InitializeComponent();
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void Set<T>(ref T storage, T value, [CallerMemberName]string propertyName = null)
        {
            if (Equals(storage, value))
            {
                return;
            }

            storage = value;
            OnPropertyChanged(propertyName);
        }

        private void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

        private void StartButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            //Navigating to a ShellPage, this will replaces NavigationService frame for an inner frame to change navigation handling.
            NavigationService.Navigate<Views.ShellPage>();

            //Navigating now to a HomePage, this will be the first navigation on a NavigationPane menu
            NavigationService.Navigate<Views.HomePage>();
        }
    }
}


<|start_filename|>code/src/Core/Gen/TempGenerationResult.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace Microsoft.Templates.Core.Gen
{
    public class TempGenerationResult
    {
        public List<string> NewFiles { get; } = new List<string>();

        public List<string> ModifiedFiles { get; } = new List<string>();

        public List<string> ConflictingFiles { get; } = new List<string>();

        public List<string> UnchangedFiles { get; } = new List<string>();

        public bool SyncGeneration { get; set; }
    }
}


<|start_filename|>code/test/Core.Test/TestData/Templates/_catalog/es-ES.projectTypes.json<|end_filename|>
[
  {
    "name": "TestProjectType",
    "displayName": "Proyecto de prueba",
    "summary": "Resumen del proyecto de prueba"
  }
]

<|start_filename|>code/test/Core.Test/TestData/Templates/ProjectTemplateVB/.template.config/Layout.json<|end_filename|>
[
  {
    "name": "Item1",
    "templateGroupIdentity": "Microsoft.UWPTemplates.Test.ProjectTemplate",
    "readonly": "true"
  },
  {
    "name": "Item2",
    "templateGroupIdentity": "Microsoft.UWPTemplates.Test.PageTemplate",
    "readonly": "false"
  }
]


<|start_filename|>templates/Pages/Map.CodeBehind/.template.config/fr-FR.template.json<|end_filename|>
﻿{
  "author": "Microsoft",
  "name": "Map",
  "description": "La page Plan s'appuie sur la commande Plan. Le code inclut l'ajout d'une icône Plan et la définition de votre emplacement.",
  "identity": "wts.Page.Map.CodeBehind"
}

<|start_filename|>code/src/Core/Diagnostics/ExceptionTracker.cs<|end_filename|>
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Threading.Tasks;

namespace Microsoft.Templates.Core.Diagnostics
{
    public class ExceptionTracker
    {
        public ExceptionTracker()
        {
        }

        public async Task TrackAsync(Exception ex, string message = null)
        {
            try
            {
                foreach (IHealthWriter writer in HealthWriters.Available)
                {
                    await writer.WriteExceptionAsync(ex, message).ConfigureAwait(false);
                }
            }
            catch (Exception exception)
            {
                Trace.TraceError($"Error writing exception data to listeners. Exception:\r\n{exception.ToString()}");
            }
        }
    }
}
