Skip to content

Commit

Permalink
Smaple.cs LookForTypeByName(string) add assmbiles to search for types. (
Browse files Browse the repository at this point in the history
#3740)

<!-- 🚨 Please Do Not skip any instructions and information mentioned below as they are all required and essential to evaluate and test the PR. By fulfilling all the required information you will be able to reduce the volume of questions and most likely help merge the PR faster 🚨 -->

<!-- 📝 It is preferred if you keep the "☑️ Allow edits by maintainers" checked in the Pull Request Template as it increases collaboration with the Toolkit maintainers by permitting commits to your PR branch (only) created from your fork.  This can let us quickly make fixes for minor typos or forgotten StyleCop issues during review without needing to wait on you doing extra work. Let us help you help us! 🎉 -->


## Fixes #3739 #3735 
<!-- Add the relevant issue number after the "#" mentioned above (for ex: Fixes #1234) which will automatically close the issue once the PR is merged. -->

<!-- Add a brief overview here of the feature/bug & fix. -->
 Smaple.cs LookForTypeByName(string) add assmbiles to search in

- Microsoft.Toolkit.Uwp.UI.Controls -> Microsoft.Toolkit.Uwp.UI.Controls.Core
- Microsoft.Toolkit.Uwp.UI.Controls.Layout
- Microsoft.Toolkit.Uwp.UI.Controls.Media
- Microsoft.Toolkit.Uwp.UI.Controls.Media

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->

- Bugfix
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->


## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->


## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
    - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/windows-toolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [ ] Contains **NO** breaking changes

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. 
     Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->


## Other information
  • Loading branch information
msftbot[bot] authored Feb 9, 2021
2 parents 7a7ec26 + ba5f7ff commit be2ebd7
Showing 1 changed file with 20 additions and 98 deletions.
118 changes: 20 additions & 98 deletions Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,108 +629,30 @@ public async Task PreparePropertyDescriptorAsync()
private static Type LookForTypeByName(string typeName)
{
// First search locally
var result = System.Type.GetType(typeName);

if (result != null)
if (System.Type.GetType(typeName) is Type systemType)
{
return result;
return systemType;
}

// Search in Windows
var proxyType = VerticalAlignment.Center;
var assembly = proxyType.GetType().GetTypeInfo().Assembly;

foreach (var typeInfo in assembly.ExportedTypes)
var targets = new Type[]
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// Search in Microsoft.Toolkit.Uwp.UI.Controls
var controlsProxyType = GridSplitter.GridResizeDirection.Auto;
assembly = controlsProxyType.GetType().GetTypeInfo().Assembly;

foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// TODO Reintroduce graph controls
//// Search in Microsoft.Toolkit.Graph.Controls
//var graphControlsProxyType = typeof(UserToPersonConverter);
//assembly = graphControlsProxyType.GetTypeInfo().Assembly;

//foreach (var typeInfo in assembly.ExportedTypes)
//{
// if (typeInfo.Name == typeName)
// {
// return typeInfo;
// }
//}

// Search in Microsoft.Toolkit.Uwp.UI.Animations
var animationsProxyType = EasingType.Default;
assembly = animationsProxyType.GetType().GetTypeInfo().Assembly;
foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// Search in Microsoft.Toolkit.Uwp.UI
var uiProxyType = ImageBlendMode.Multiply;
assembly = uiProxyType.GetType().GetTypeInfo().Assembly;
foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// Search in Microsoft.Toolkit.Uwp.Input.GazeInteraction
var gazeType = Interaction.Enabled;
assembly = gazeType.GetType().GetTypeInfo().Assembly;
foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// Search in Microsoft.Toolkit.Uwp.UI.Controls.DataGrid
var dataGridProxyType = DataGridGridLinesVisibility.None;
assembly = dataGridProxyType.GetType().GetTypeInfo().Assembly;

foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

// Search in Microsoft.Toolkit.Uwp.UI.Controls.Markdown
var markdownTextBlockType = typeof(MarkdownTextBlock);
assembly = markdownTextBlockType.GetTypeInfo().Assembly;

foreach (var typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == typeName)
{
return typeInfo;
}
}

return null;
VerticalAlignment.Center.GetType(), // Windows
StackMode.Replace.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Core

// TODO Reintroduce graph controls
// typeof(UserToPersonConverter)) // Search in Microsoft.Toolkit.Graph.Controls
EasingType.Default.GetType(), // Microsoft.Toolkit.Uwp.UI.Animations
ImageBlendMode.Multiply.GetType(), // Search in Microsoft.Toolkit.Uwp.UI
Interaction.Enabled.GetType(), // Microsoft.Toolkit.Uwp.Input.GazeInteraction
DataGridGridLinesVisibility.None.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.DataGrid
GridSplitter.GridResizeDirection.Auto.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Layout
typeof(MarkdownTextBlock), // Microsoft.Toolkit.Uwp.UI.Controls.Markdown
BitmapFileFormat.Bmp.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Media
StretchChild.Last.GetType() // Microsoft.Toolkit.Uwp.UI.Controls.Primitivs
};

return targets.SelectMany(t => t.Assembly.ExportedTypes)
.FirstOrDefault(t => t.Name == typeName);
}

private static async Task<string> GetDocsSHA()
Expand Down

0 comments on commit be2ebd7

Please sign in to comment.