In Windows RT and Universal Apps, Where Are StaticResource and ThemeResource Defined? - windows-runtime

I am looking in a WinRT/Universal Application Xaml file, and I see references to StaticResource and a new (in Windows 8.1) ThemeResource markup extension. Here is an example:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
</Grid>
I understand that the resource 'ApplicationPageBackgroundThemeBrush' is defined as a default resource brush. However, what I am looking for is where the ThemeResource markup extension as defined in a .winmd or .dll file so that I can see all of its properties and methods. It doesn't appear that I can access this type in a code-behind (or any other code file).
As an example, the Binding markup extension I can see is defined in Windows.UI.Xaml.Data.Binding in the resource file C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd.
However, I do not see any definition of StaticResource or ThemeResource. Where are these objects located and defined?

After digging around, the StaticResource and ThemeResource are not used at all in the provided APIs, but used automagically behind the scenes of the COM components when Xaml parsing and deserialization is performed.

Related

Where is the site.css file located for Identity?

I have an asp.net core 2.1 MVC application. I have ran the Scaffold Identity which has generated all the HTML and models used. I can't however find the css file that identity is using for its layouts?
In chrome developer tools it tells me site.css is being loaded from /Identity/css/site.css and bootstrap is being loaded from /Identity/lib/bootstrap/dist/css/bootstrap.css. These files don't seem to exist anywhere in my project. Am I missing something?
It's not using the site.css file that's located in wwwroot/css.
The Identity default UI is a Razor Class Library. The static resources are being embedded and loaded from the library. Specifically, the Static Files middleware is loading up the embedded resources as if they were on the filesystem, using a ManifestEmbeddedFileProvider.
Long and short, you can override those by simply creating files in the same location in your project. Then, your project's versions will take over. Unfortunately, the scaffold doesn't provide a way to scaffold static resources as well. However, you can simply view the source in your browser and then copy that into your project's version of the file.
You can also view the source of the RCL here. That way you can reference whatever code you need, without even needing the scaffold. Anything you add to your own project overrides what's coming from the RCL.

Servicestack Embedding Javascript Resources

I have been working on an MEF/Servicestack based framework for an SaaS product. I am compiling razor views into external modules that are loaded during runtime with MEF. I am struggling trying to embed javascript resources into the dlls and then referencing them successfully when the view is loaded. Has anyone had any success with this?
The section on Embedded Resources in Virtual File System wiki explains the Embedded Resources support in more detail where you just need to ensure the Assembly that contains your embedded resources is defined in either the Config.EmbeddedResourceSources Assembly list or Config.EmbeddedResourceBaseTypes types list, e.g:
SetConfig(new HostConfig {
EmbeddedResourceSources = { typeof(TypeInDllWithEmbeddedResources).Assembly },
EmbeddedResourceBaseTypes = { typeof(TypeInDllWithEmbeddedResources) }
});
However typically no configuration is needed as the top-level Assembly where your AppHost is defined is automatically pre-registered and as it's also typically the same Assembly where your Website resources are maintained, any embedded resources in that Assembly are automatically available. E.g. if you have an embedded resource in your project at /dir/file.js it would be available from the same path where ServiceStack is mounted, e.g http://localhost:1337/dir/file.js.
Specifying an Embedded Resource in VS.NET
You just need to make the file an Embedded Resource by setting the Build Action in the File property panel in VS.NET to Embedded Resource so that it gets compiled as an embedded resource in your Website .dll.

WinRT: What happens when file is shared via file extension?

I'm recently looking into the file-sharing features of Windows Phone 8.1. One possibility is, to do this via file extensions. My question is, how exactly my app gets access to a launched file that it registered to handle.
I know that in WP8 this was done with a URI and a file token (https://msdn.microsoft.com/en-us/library/windows/apps/jj206987%28v=vs.105%29.aspx), but since the SharedStorageAccessManager class is not available anymore, I guess that it must be done different in 8.1.
So: What happens on "OS-level" in Win8.1/WP8.1 when an app is launched via a file extension, and how does the target-app actually get the launched file?
Thanks in Advance!
The app can register as a file handler in its Package.appxmanifest. Openthe manifest designer in Visual Studio, go to the Declarations tab, and add a File Type Associations declaration. You'll be prompted to fill out the details.
The app's Application.OnFileActivated method will be called with the launched StorageFiles in the FileActivatedEventArgs.Files property.
See How to handle file activation and the Association Launching sample for documentation and walkthroughs.
At a system level this all gets stored in the registry and when the launcher is called on a file the shell looks up the association then uses COM (or historically command line parameters or DDE) to launch or connect to the app registered for the file type. The details are hidden from Windows Runtime apps but are more directly exposed to desktop apps on Windows. See File type and URI associations model Implementing a Custom File Format

What does static library and dynamic link library mean to WP8?

When reading about WP8 C++ project template, I see
Windows Phone Empty Dynamic Link Library
A project for creating a native dynamic-link library for a Windows
Phone app.
Windows Phone Empty Static Library
A project for creating a native static library for a Windows Phone
app.
What are static library and dynamic link library mean to WP8?
Supposed I have my Windows library source (openssl for example), do I need to convert to WP8 static library to be consumed by WP8 apps?
Whether I use WP8 static or dynamic link library, I must wrap them in WP8 runtime component in order for my app to consume, am I right ?
At the basic level, static and dynamic libraries are the same as any other Windows environment (so see this other SO question for more clarification).
For a WP8 app you will either need to produce:
A XAML .NET/Windows Runtime hybrid app.
A DirectX C++/C project (usually a game).
For 1. you would need to wrap up either your static .lib or .dll in a WP8 Runtime component, for your .NET side to consume.
For 2. it looks like you end up building a traditional .exe. In that case you would link directly to your .lib or .dll in the normal way. (I not so familiar with this one, so may be missing some subtleties here).
In any case it's easier to link everything if you have all the source code in VS and reference the projects that build .lib or .dll you need, rather than the referencing the binaries themselves.
That way you can ensure all the code is built to target the correct runtime environment (targetting the Phone APIs, using the correct CPU architecture). Also VS should then automatically add all dependencies into your final XAP package.

How can I use a console application with my website in Visual Studio?

Please read the following in the Visual Studio 2012 context:
I have two projects--one is a website (File --> New Website) and another is a console application (File --> New Project --> Windows --> Console Application). I am the author of the former.
The standalone app fakes the input by hardcoding it, runs through some code, and creates an output. It uses dlls from a local installation of software that I have installed on my machine to generate this output.
I read on MSDN that I cannot add a console app to a website solution in a useful manner. So, if I compile the console app to output a dll instead of an exe, can I reference that dll in my website? How can I do this exactly? I would need to pass the input value from the website to the dll, and return meaningful results from the dll. Is this possible?
Yes, you describe a feasible way to solve this. You need to create a class library project, add source code from console application to it, except the the class that has static Main method and modify (add to) that source code such that there is a class that you will be able instantiate from the code in your web application after you add the class library assembly to the web application as a reference. This class will have a method with appropriate parameters, that you will call. All this assuming that the task that console application code performs is fast and will not create noticeable delay in the web application response. If the task takes a long time, you will either have to run it in a background thread or move it outside the web application - the latter is significantly more involved.