Filter content of inherited param comments - xml-documentation

I have comments like this:
/// <summary>some summary</summary>
/// <param name="a">
/// <para id="0">Comment 0</para>
/// <para id="1">Comment 1</para>
/// <para id="2">Comment 2</para>
/// </param>
/// <param name="b">
/// <para id="1">Comment 3</para>
/// <para id="0">Comment 4</para>
/// </param>
void InterfaceMethod(int a, int b);
For the implementing method, I'd like to have the same documentation, but without those paragraphs having id="0", using inheritdoc.
How can I author the inheritdoc element?
The uncommon use of the id attributes in this context shall add the flexibility of not being tied to the order of the paragraphs as they appear in the documentation.

I found a solution, but it looks cumbersome.
/// <summary><inheritdoc/></summary>
/// <param name="a"><inheritdoc select="node()[parent::node()[#name='a'] and #id>0]"/></param>
/// <param name="b"><inheritdoc select="node()[parent::node()[#name='b'] and #id>0]"/></param>
public void InterfaceMethod(int a, int b) { }
As it is not possible to use XPath expressions as a filter, the param elements must be repeated.
The expression #id>0 (the > needed to be escaped) now selects the intended paragraphs only.
But what about the other markup?
The nested inheritdoc element will select the content of all param nodes, so we must add a condition on the parent's name attribute.
Finally, the inheritdoc tag within the summary tag will copy the summary. If we placed a inheritdoc on root level, this would again select the param, as described here.

Related

BottomAppBar hides part of the TransportControls of a full window MediaElement

When a MediaElement switches to FullWindow mode, the internal FullWindowMediaRoot becomes its temporary host. When visible, FullWindowMediaRoot sits on top of the normal RootScrollViewer, i.e. it is displayed as an overlay over the current page, which is the expected behaviour.
My problem was with the BottomAppBar. Its host is the internal PopupRoot, which unfortunately sits on top of the FullWindowMediaRoot. So when I use a BottomAppBar on a page that allows a user to switch a MediaElement to FullWindow, the user cannot use the MediaElement's controls since these elements are almost completely hidden by the still visible BottomAppBar.
I have pulled my hair out over this problem for nearly a day and have found a solution that works for me. If someone has a better answer, I would be grateful for sharing. Until then, I am documenting my current working solution below for anyone running into the same issue.
My solution uses a class implementing IValueConverter, which raises an event whenever the IsFullWindow property of a MediaElement changes value.
The page initialiser adds an event handler to the converter's FullWindowStateChanged event:
this.isFullWindowConverter.FullWindowStateChanged += this.OnFullWindowStateChanged;
and handles it like this:
/// <summary>
/// Handles the FullWindowStateChanged event of IsFullWindowConverter by adjusting the visibility of the BottomAppBar to the full window
/// state of this page's MediaElement.
/// </summary>
/// <param name="sender">The instance of IsFullWindowConverter raising the event.</param>
/// <param name="e">The parameter is not used.</param>
private void OnFullWindowStateChanged(object sender, EventArgs e)
{
this.BottomAppBar.Visibility = ((IsFullWindowConverter)sender).IsFullWindow ? Visibility.Collapsed : Visibility.Visible;
}
Here the converter class:
namespace Filmit.Win
{
using System;
using Windows.UI.Xaml.Data;
/// <summary>
/// This converter raises an event when the IsFullWindow property of a MediaElement has changed. The converter is added to the resources of the page that hosts the MediaElement:
/// <code><local:IsFullWindowConverter x:Key="isFullWindowConverter" x:Name="isFullWindowConverter"/></code>
/// This converter resource is then bound to the IsFullWindow property of a MediaElement, solely for the event raising effects of the ConvertBack method this converter.
/// The actual value of the IsFullWindow property is returned as is.
/// <code><MediaElement IsFullWindow="{Binding RelativeSource={RelativeSource Self}, Path=IsFullWindow, Converter={StaticResource isFullWindowConverter}, Mode=TwoWay}"></code>
/// The subscriber to the FullWindowStateChanged event checks the IsFullWindow property to get the current full window state of the MediaElement.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1603:DocumentationMustContainValidXml", Justification = "XAML Page.Resources declaration.")]
public class IsFullWindowConverter : IValueConverter
{
/// <summary>
/// Raises the FullWindowStateChanged event. Subscribers check the IsFullWindow property to get the current full windows state.
/// </summary>
public event EventHandler<EventArgs> FullWindowStateChanged = null;
/// <summary>
/// Gets a value indicating whether the mode of the MediaElement is FullWindow.
/// </summary>
public bool IsFullWindow { get; private set; }
/// <summary>
/// Required implementation of IValueConverter.Convert, returning the passed in boolean object as a bool.
/// </summary>
/// <param name="value">The boolean object.</param>
/// <param name="targetType">The expected target type.</param>
/// <param name="parameter">The parameter is not used.</param>
/// <param name="language">The parameter is not used.</param>
/// <returns>The passed in boolean object as a bool.</returns>
public object Convert(object value, Type targetType, object parameter, string language)
{
bool? isFullWindow = value as bool?;
this.IsFullWindow = isFullWindow.HasValue ? isFullWindow.Value : false;
return this.IsFullWindow;
}
/// <summary>
/// This implementation of IValueConverter.ConvertBack is called when the IsFullWindow property of the MediaElement has changed its value.
/// It raises the FullWindowStateChanged event and returns the passed in boolean object as a bool.
/// </summary>
/// <param name="value">The boolean object.</param>
/// <param name="targetType">The expected target type.</param>
/// <param name="parameter">The parameter is not used.</param>
/// <param name="language">The parameter is not used.</param>
/// <returns>The passed in boolean object as a bool.</returns>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
bool? isFullWindow = value as bool?;
this.IsFullWindow = isFullWindow.HasValue ? isFullWindow.Value : false;
if (this.FullWindowStateChanged != null)
{
this.FullWindowStateChanged(this, new EventArgs());
}
return this.IsFullWindow;
}
}
}
If you are creating a UWP app, I think you can put a AppBar in the Grid, and locate it to the bottom of the page. And this will solve your porblem too. But if you are working on a windows 8.1 app, this method will not work.
XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<MediaElement x:Name="MyMedia" Source="Assets/Sofia Jannok-Liekkas.wma" AreTransportControlsEnabled="True" />
<AppBar VerticalAlignment="Bottom">
<CommandBar>
<CommandBar.Content>
<Grid/>
</CommandBar.Content>
<AppBarButton Icon="Accept" Label="appbarbutton"/>
<AppBarButton Icon="Cancel" Label="appbarbutton"/>
<AppBarButton Content="Maximize" VerticalAlignment="Center" HorizontalAlignment="Center" Click="maximize"/>
</CommandBar>
</AppBar>
</Grid>
C#:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
public void maximize(object sender, RoutedEventArgs e)
{
MyMedia.IsFullWindow = !MyMedia.IsFullWindow;
}
}
Any way, your solution will solve the problem. Thank you for sharing.

Display an HTML Code like &reg or &copy in an Html.ActionLink Text

unfortunately, I was not successful with my research for this topic.
With an anchor tag, I was able to do this:
My Link &reg
Now I want the same with an Html.Actionlink:
#Html.ActionLink("My Link &reg", "Action")
But the output is the same as the input and not a reg symbol as it is intended.
Any idea?
Thanks in advance!
#Html.ActionLink("My Link ®", "Action")
or
My Link &reg
ActionLink always use call of HttpUtility.Encode for the link text.
You can use UrlHelper Method like
My Link &reg
You can use an HtmlString (MvcHtmlString in .NET 2 / MVC 2) to indicate that you do not wish it to be re-encoded:
#Html.ActionLink(new HtmlString("My Link &reg"), "Action");
Here is how I solved this in MVC 2:
/// <summary>
/// Creates an anchor tag based on the passed in controller type and method.
/// Does NOT encode passed in link text.
/// </summary>
/// <typeparam name="TController">The controller type</typeparam>
/// <param name="htmlHelper">The HTML helper</param>
/// <param name="action">The method to route to</param>
/// <param name="linkText">The linked text to appear on the page</param>
/// <returns>A formatted anchor tag</returns>
public static MvcHtmlString ActionLink<TController>( this HtmlHelper htmlHelper,
Expression<Action<TController>> action,
HtmlString linkText ) where TController : Controller
{
return ActionLink( htmlHelper, action, linkText, null, null );
}
/// <summary>
/// Creates an anchor tag based on the passed in controller type and method.
/// Does NOT encode passed in link text.
/// </summary>
/// <typeparam name="TController">The controller type</typeparam>
/// <param name="htmlHelper">The HTML helper</param>
/// <param name="action">The method to route to</param>
/// <param name="linkText">The linked text to appear on the page</param>
/// <param name="routeValues">The route values</param>
/// <param name="htmlAttributes">The HTML attributes</param>
/// <returns>A formatted anchor tag</returns>
public static MvcHtmlString ActionLink<TController>( this HtmlHelper htmlHelper,
Expression<Action<TController>> action,
HtmlString linkText,
object routeValues,
object htmlAttributes ) where TController : Controller
{
var routingValues = GetRouteValuesFromExpression( action, routeValues );
var url = UrlHelper.GenerateUrl( null, //routeName
null, //actionName
null, //controllerName
routingValues,
htmlHelper.RouteCollection,
htmlHelper.ViewContext.RequestContext,
false ); //includeImplicitMvcValues
var tagBuilder = new TagBuilder("a")
{
InnerHtml = !String.IsNullOrEmpty( linkText.ToString() ) ? linkText.ToString() : String.Empty
};
tagBuilder.MergeAttributes( (IDictionary<string, object>)htmlAttributes );
tagBuilder.MergeAttribute( "href", url );
return MvcHtmlString.Create( tagBuilder.ToString( TagRenderMode.Normal ) );
}
It is strongly typed, as in the MVC futures NuGet package. So you can use it like this:
<%= Html.ActionLink<HomeController>( x => x.Index(),
new HtmlString( "Don't Encode Me!<sup>®</sup>" ) ) %>

Can I suppress the Restart request message when pushing a WAP provisioning update to a Windows Mobile device?

Our automatic maintenance procedure sends out provisioning updates like this to our devices overnight:
<wap-provisioningdoc>
<characteristic type="SoftwareDisable">
<characteristic type="DisabledSystemFiles">
<parm name="Labyrinth.exe" />
</characteristic>
</characteristic>
</wap-provisioningdoc>
This works fine, apart from it pops up a box asking the user if they want to restart now or later, specifically:
Restart
Recent changes to your device require a
restart. During this process you cannot make
or receive phone calls, including emergency
calls. Restart your device now?
Now Later
This is of course difficult to do because there is no user, just racks and racks of devices sitting there by themselves.
So, is there any way of not popping this message up and just restarting the device automatically? Possibly some registry setting or something?
You can soft reset your device via code.
Just need to p/invoke
public enum SystemPowerStates : uint
{
/// <summary>
/// On state.
/// </summary>
On = 0x00010000,
/// <summary>
/// No power, full off.
/// </summary>
Off = 0x00020000,
/// <summary>
/// Critical off.
/// </summary>
Critical = 0x00040000,
/// <summary>
/// Boot state.
/// </summary>
Boot = 0x00080000,
/// <summary>
/// Idle state.
/// </summary>
Idle = 0x00100000,
/// <summary>
/// Suspend state.
/// </summary>
Suspend = 0x00200000,
/// <summary>
/// Reset state.
/// </summary>
Reset = 0x00800000
}
[DllImport("coredll.dll")]
internal static extern int SetSystemPowerState(string psState, int StateFlags, int Options);
/// <summary>
/// Defines the System power requirement flags
/// </summary>
public enum PowerReqFlags : uint
{
POWER_NAME = 0x00000001,
POWER_FORCE = 0x00001000,
}
And call the function SetSystemPowerState, I use it enclosed in another method.
private static void DeviceReset()
{
SetSystemPowerState(
null,
(int)SystemPowerStates.Reset,
(int)PowerReqFlags.POWER_FORCE);
}

Transfer only a part of properties in a class in struts' json

Sorry, I really don't know how to summarize the title of this question. So, the title may not be clear.
I have an action class which performs some business logic.
in the Action Class:
class ActionClass extends ActionSupport{
private Merchandise merchandise;// I want to transfer it to the client
//setter and getter
}
in the Merchandise class:
class Merchandise{
private String name; // I want to transfer it
private String price; //I don't want to transfer it
private String description;//I don't want to transfer it
//setter and getter
}
Now, I need to transfer the merchandise property in ActionClass to the client.
However, in the merchandise property, I want to transfer only the name property while inhibiting the other two properties.
Then how to inhibit the transfer of the other two properties(price and description) in class Merchandise?
Try something like:
<!-- Result fragment -->
<result type="json">
<param name="root">merchandise</param>
<param name="excludeProperties">price,description</param>
</result>
See full documentation, other options and examples at http://struts.apache.org/2.2.3/docs/json-plugin.html
The easiest way is to create a Data Transfer Object in your action class that contains only the fields you want to send to the client and make that your root object
#nmc answer is correct another way you can try like:
<result type="json">
<param name="root">merchandise</param>
<param name="includeProperties">name</param>
</result>
Or
<result type="json">
<param name="includeProperties">
merchandise.name
</param>
<param name="root">
#action
</param>
</result>

XML Comments - How to comment multiple reasons for an exception?

Here's an example:
public void DoSomething(String param1, String param2)
{
if (param1 == null) throw new ArgumentNullException("param1");
if (param2 == null) throw new ArgumentNullException("param2");
}
2 different reasons for an ArgumentNullException. MSDNs String.Format Example shows 2 different reasons for the FormatException. So, is it done this way:
/// <exception cref="ArgumentNullException">
/// <paramref name="param1"/> is null.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="param2"/> is null.
/// </exception>
or some other way?
/// <exception cref="ArgumentNullException">
/// Some other way to show the 2 reasons with an "-or-" between them.
/// </exception>
If you think each of the rows of the docs as being one <exception cref=...> </exception>, then logically the correct way to do it is using your second alternative:
/// <exception cref="ArgumentNullException">
/// <p><paramref name="param1"/> is null. </p>
/// <p>- or - </p>
/// <p><paramref name="param2"/> is null. </p>
/// </exception>
You can use 'p' elements to denote the lines.