Skip to content

Commit be2ebd7

Browse files
author
msftbot[bot]
authored
Smaple.cs LookForTypeByName(string) add assmbiles to search for types. (#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
2 parents 7a7ec26 + ba5f7ff commit be2ebd7

File tree

1 file changed

+20
-98
lines changed
  • Microsoft.Toolkit.Uwp.SampleApp/Models

1 file changed

+20
-98
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs

Lines changed: 20 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -629,108 +629,30 @@ public async Task PreparePropertyDescriptorAsync()
629629
private static Type LookForTypeByName(string typeName)
630630
{
631631
// First search locally
632-
var result = System.Type.GetType(typeName);
633-
634-
if (result != null)
632+
if (System.Type.GetType(typeName) is Type systemType)
635633
{
636-
return result;
634+
return systemType;
637635
}
638636

639-
// Search in Windows
640-
var proxyType = VerticalAlignment.Center;
641-
var assembly = proxyType.GetType().GetTypeInfo().Assembly;
642-
643-
foreach (var typeInfo in assembly.ExportedTypes)
637+
var targets = new Type[]
644638
{
645-
if (typeInfo.Name == typeName)
646-
{
647-
return typeInfo;
648-
}
649-
}
650-
651-
// Search in Microsoft.Toolkit.Uwp.UI.Controls
652-
var controlsProxyType = GridSplitter.GridResizeDirection.Auto;
653-
assembly = controlsProxyType.GetType().GetTypeInfo().Assembly;
654-
655-
foreach (var typeInfo in assembly.ExportedTypes)
656-
{
657-
if (typeInfo.Name == typeName)
658-
{
659-
return typeInfo;
660-
}
661-
}
662-
663-
// TODO Reintroduce graph controls
664-
//// Search in Microsoft.Toolkit.Graph.Controls
665-
//var graphControlsProxyType = typeof(UserToPersonConverter);
666-
//assembly = graphControlsProxyType.GetTypeInfo().Assembly;
667-
668-
//foreach (var typeInfo in assembly.ExportedTypes)
669-
//{
670-
// if (typeInfo.Name == typeName)
671-
// {
672-
// return typeInfo;
673-
// }
674-
//}
675-
676-
// Search in Microsoft.Toolkit.Uwp.UI.Animations
677-
var animationsProxyType = EasingType.Default;
678-
assembly = animationsProxyType.GetType().GetTypeInfo().Assembly;
679-
foreach (var typeInfo in assembly.ExportedTypes)
680-
{
681-
if (typeInfo.Name == typeName)
682-
{
683-
return typeInfo;
684-
}
685-
}
686-
687-
// Search in Microsoft.Toolkit.Uwp.UI
688-
var uiProxyType = ImageBlendMode.Multiply;
689-
assembly = uiProxyType.GetType().GetTypeInfo().Assembly;
690-
foreach (var typeInfo in assembly.ExportedTypes)
691-
{
692-
if (typeInfo.Name == typeName)
693-
{
694-
return typeInfo;
695-
}
696-
}
697-
698-
// Search in Microsoft.Toolkit.Uwp.Input.GazeInteraction
699-
var gazeType = Interaction.Enabled;
700-
assembly = gazeType.GetType().GetTypeInfo().Assembly;
701-
foreach (var typeInfo in assembly.ExportedTypes)
702-
{
703-
if (typeInfo.Name == typeName)
704-
{
705-
return typeInfo;
706-
}
707-
}
708-
709-
// Search in Microsoft.Toolkit.Uwp.UI.Controls.DataGrid
710-
var dataGridProxyType = DataGridGridLinesVisibility.None;
711-
assembly = dataGridProxyType.GetType().GetTypeInfo().Assembly;
712-
713-
foreach (var typeInfo in assembly.ExportedTypes)
714-
{
715-
if (typeInfo.Name == typeName)
716-
{
717-
return typeInfo;
718-
}
719-
}
720-
721-
// Search in Microsoft.Toolkit.Uwp.UI.Controls.Markdown
722-
var markdownTextBlockType = typeof(MarkdownTextBlock);
723-
assembly = markdownTextBlockType.GetTypeInfo().Assembly;
724-
725-
foreach (var typeInfo in assembly.ExportedTypes)
726-
{
727-
if (typeInfo.Name == typeName)
728-
{
729-
return typeInfo;
730-
}
731-
}
732-
733-
return null;
639+
VerticalAlignment.Center.GetType(), // Windows
640+
StackMode.Replace.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Core
641+
642+
// TODO Reintroduce graph controls
643+
// typeof(UserToPersonConverter)) // Search in Microsoft.Toolkit.Graph.Controls
644+
EasingType.Default.GetType(), // Microsoft.Toolkit.Uwp.UI.Animations
645+
ImageBlendMode.Multiply.GetType(), // Search in Microsoft.Toolkit.Uwp.UI
646+
Interaction.Enabled.GetType(), // Microsoft.Toolkit.Uwp.Input.GazeInteraction
647+
DataGridGridLinesVisibility.None.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.DataGrid
648+
GridSplitter.GridResizeDirection.Auto.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Layout
649+
typeof(MarkdownTextBlock), // Microsoft.Toolkit.Uwp.UI.Controls.Markdown
650+
BitmapFileFormat.Bmp.GetType(), // Microsoft.Toolkit.Uwp.UI.Controls.Media
651+
StretchChild.Last.GetType() // Microsoft.Toolkit.Uwp.UI.Controls.Primitivs
652+
};
653+
654+
return targets.SelectMany(t => t.Assembly.ExportedTypes)
655+
.FirstOrDefault(t => t.Name == typeName);
734656
}
735657

736658
private static async Task<string> GetDocsSHA()

0 commit comments

Comments
 (0)