コード例 #1
0
        private static Either <Exception, string>?TryGetViewModelAssemblyName(
            XamlCode xamlCode,
            ParsedViewModelCode viewModelCode)
        {
            var namesOfAssembliesThatContainViewModelNamespaces = xamlCode.MentionedAssemblies
                                                                  .Where(kvp => kvp.Value.Intersect(viewModelCode.NamespaceNames).Any())
                                                                  .Select(kvp => kvp.Key)
                                                                  .AsImmutable();


            switch (namesOfAssembliesThatContainViewModelNamespaces.Count)
            {
            case 0:
                return(default);

            case 1:
                return(Right(namesOfAssembliesThatContainViewModelNamespaces.Single()));

            default:
                return(Left(
                           (Exception) new InvalidOperationException(
                               "XAML namespaces erroneousely mention ViewModel's namespaces belonging to the following assemblies: " +
                               string.Join(",", namesOfAssembliesThatContainViewModelNamespaces) +
                               ". Please use *single* assembly name for all ViewModel namespaces.")));
            }
        }
コード例 #2
0
        public static void WarmUp()
        {
            var parsedCode = ParsedViewModelCode.TryParseViewModelCode(WarmUpCsharpCode);

            if (parsedCode != null)
            {
                new ViewModelAssemblyBuilder(
                    "__" + Guid.NewGuid().ToString("N"),
                    parsedCode.Value.SyntaxTree)
                .Build();
            }
        }