Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First commit

  • Loading branch information...
commit 52a9adcd654fbbb5ce0685ba53136a1b49c9aec6 0 parents
Matthew Baxter-Reynolds (@mbrit) authored
16 .gitignore
@@ -0,0 +1,16 @@
+[Oo]bj
+[Bb]in
+*.user
+*.suo
+*.[Cc]ache
+*.bak
+*.ncb
+*.log
+*.DS_Store
+[Tt]humbs.db
+_ReSharper.*
+*.resharper
+Ankh.NoLoad
+*.mdb
+/TestResults
+/packages
20 XamlOrHtml.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlOrHtml", "XamlOrHtml\XamlOrHtml.csproj", "{FC06365C-B02B-48F2-B8A8-50B766F964AF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {FC06365C-B02B-48F2-B8A8-50B766F964AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FC06365C-B02B-48F2-B8A8-50B766F964AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FC06365C-B02B-48F2-B8A8-50B766F964AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FC06365C-B02B-48F2-B8A8-50B766F964AF}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
91 XamlOrHtml/PackageInfo.cs
@@ -0,0 +1,91 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace XamlOrHtml
+{
+ internal class PackageInfo
+ {
+ internal string PackageId { get; private set; }
+ internal string DisplayName { get; private set; }
+ internal string PackageRootFolder { get; private set; }
+ internal bool FoundStartPage { get; private set; }
+
+ internal List<string> XamlFiles { get; private set; }
+ internal List<string> JsFiles { get; private set; }
+
+ internal PackageInfo(RegistryKey key)
+ {
+ this.PackageId = Path.GetFileName(key.Name);
+ this.DisplayName = (string)key.GetValue("DisplayName");
+ this.PackageRootFolder = (string)key.GetValue("PackageRootFolder");
+
+ // walk the files...
+ this.XamlFiles = new List<string>();
+ this.JsFiles = new List<string>();
+ WalkFiles(new DirectoryInfo(this.PackageRootFolder));
+
+ // probe for a start page...
+ var appKey = key.OpenSubKey("Applications");
+ if (appKey != null)
+ {
+ using (appKey)
+ {
+ foreach(var subAppName in appKey.GetSubKeyNames())
+ {
+ using (var subAppKey = appKey.OpenSubKey(subAppName))
+ {
+ var start = (string)subAppKey.GetValue("DefaultStartPage");
+ if (!(string.IsNullOrEmpty(start)))
+ {
+ FoundStartPage = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void WalkFiles(DirectoryInfo folder)
+ {
+ foreach (var file in folder.GetFiles())
+ {
+ if (string.Compare(file.Extension, ".xaml", true) == 0)
+ this.XamlFiles.Add(file.FullName);
+ else if (string.Compare(file.Extension, ".js", true) == 0)
+ this.JsFiles.Add(file.FullName);
+ }
+
+ foreach (var child in folder.GetDirectories())
+ this.WalkFiles(child);
+ }
+
+ internal PackageType Type
+ {
+ get
+ {
+ if (this.FoundStartPage)
+ return PackageType.Html;
+
+ if (this.XamlFiles.Any())
+ return PackageType.Xaml;
+ else if (this.JsFiles.Any())
+ return PackageType.Html;
+ else
+ return PackageType.Unknown;
+ }
+ }
+
+ public bool IsMicrosoft
+ {
+ get
+ {
+ return this.PackageId.Contains("Microsoft");
+ }
+ }
+ }
+}
14 XamlOrHtml/PackageType.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace XamlOrHtml
+{
+ public enum PackageType
+ {
+ Xaml = 0,
+ Html = 1,
+ Unknown = 2
+ }
+}
153 XamlOrHtml/Program.cs
@@ -0,0 +1,153 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace XamlOrHtml
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ try
+ {
+ // walk...
+ string temp = null;
+ var packages = WalkPackages(ref temp);
+
+ // count...
+ int msXaml = 0;
+ int msHtml = 0;
+ int msUnknown = 0;
+ int nonMsXaml = 0;
+ int nonMsHtml = 0;
+ int nonMsUnknown = 0;
+ foreach (var package in packages)
+ {
+ if (package.IsMicrosoft)
+ {
+ if (package.Type == PackageType.Xaml)
+ msXaml++;
+ else if (package.Type == PackageType.Html)
+ msHtml++;
+ else if (package.Type == PackageType.Unknown)
+ msUnknown++;
+ }
+ else
+ {
+ if (package.Type == PackageType.Xaml)
+ nonMsXaml++;
+ else if (package.Type == PackageType.Html)
+ nonMsHtml++;
+ else if (package.Type == PackageType.Unknown)
+ nonMsUnknown++;
+ }
+ }
+
+ // render...
+ StringBuilder builder = new StringBuilder();
+ RenderResult(builder, "Microsoft", msXaml, msHtml, msUnknown);
+ builder.Append("\r\n");
+ RenderResult(builder, "Non-Microsoft", nonMsXaml, nonMsHtml, nonMsUnknown);
+ MessageBox.Show(builder.ToString());
+
+ // show...
+ Process.Start(temp);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
+ finally
+ {
+ if (Debugger.IsAttached)
+ Console.ReadLine();
+ }
+ }
+
+ private static void RenderResult(StringBuilder builder, string name, int xaml, int html, int unknown)
+ {
+ decimal total = (decimal)(xaml + html + unknown);
+ decimal percentageXaml = 0M;
+ decimal percentageHtml = 0M;
+ decimal percentageUnknown = 0M;
+ if(total > 0)
+ {
+ percentageXaml = (decimal)xaml / total;
+ percentageHtml = (decimal)html / total;
+ percentageUnknown = (decimal)unknown / total;
+ }
+
+ // ok...
+ builder.Append(name);
+ builder.Append(" --> ");
+ builder.Append("XAML: ");
+ builder.Append(xaml);
+ builder.Append(" (");
+ builder.Append((percentageXaml * 100).ToString("n0"));
+ builder.Append("%), ");
+ builder.Append("HTML: ");
+ builder.Append(html);
+ builder.Append(" (");
+ builder.Append((percentageHtml * 100).ToString("n0"));
+ builder.Append("%), ");
+ builder.Append("Unknown: ");
+ builder.Append(unknown);
+ builder.Append(" (");
+ builder.Append((percentageUnknown * 100).ToString("n0"));
+ builder.Append("%)");
+ }
+
+ private static List<PackageInfo> WalkPackages(ref string temp)
+ {
+ Console.WriteLine("Walking packages...");
+
+ // find...
+ var packages = new List<PackageInfo>();
+ using (var key = Registry.ClassesRoot.OpenSubKey(@"Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages"))
+ {
+ foreach (var packageName in key.GetSubKeyNames())
+ {
+ Console.WriteLine("..." + packageName);
+
+ using (var packageKey = key.OpenSubKey(packageName))
+ {
+ var package = new PackageInfo(packageKey);
+ packages.Add(package);
+ }
+ }
+ }
+
+ // sort...
+ packages.Sort(new DisplayNameComparer());
+
+ // csv...
+ temp = Path.GetTempFileName() + ".csv";
+ using(var writer = new StreamWriter(temp))
+ {
+ writer.WriteLine("PackageId,DisplayName,RootFolder,NumXaml,NumJs,FoundStartPage,Type");
+
+ foreach (var package in packages)
+ {
+ writer.WriteLine("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"", package.PackageId, package.DisplayName,
+ package.PackageRootFolder, package.XamlFiles.Count, package.JsFiles.Count, package.FoundStartPage, package.Type);
+ }
+ }
+
+ // return...
+ return packages;
+ }
+
+ private class DisplayNameComparer : IComparer<PackageInfo>
+ {
+ public int Compare(PackageInfo x, PackageInfo y)
+ {
+ return string.Compare(x.DisplayName, y.DisplayName, true);
+ }
+ }
+ }
+}
36 XamlOrHtml/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("XamlOrHtml")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("XamlOrHtml")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("8572f708-2d48-4355-97b0-b9510ce730e2")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
57 XamlOrHtml/XamlOrHtml.csproj
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{FC06365C-B02B-48F2-B8A8-50B766F964AF}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>XamlOrHtml</RootNamespace>
+ <AssemblyName>XamlOrHtml</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="PackageInfo.cs" />
+ <Compile Include="PackageType.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Please sign in to comment.
Something went wrong with that request. Please try again.