GhostDoc public const documentation - ghostdoc

When using ghostdoc on single line vars defs like
public const string DbCatName = "test";
ghostdoc adds a default header like :
/// <summary>
///
/// </summary>
but what I like to have is
/// <summary></summary>
Does anybody know how to do this?

What you need is GhostDoc Pro which has "XML Comment templates (T4) Total control over your XML documentation content and style"
From http://submain.com/products/ghostdoc.aspx

As far as I'm aware you can't get GhostDoc to do that for you - I believe the format it uses is pretty much fixed. [edit: It appears it may now be possible in GhostDoc Pro]
My addin, Atomineer Pro Documentation will do exactly what you want though - it has a lot of preferences to control almost every aspect of how comments are formatted, indented and word wrapped.

Related

Unable to override OnApplyTemplate

I'm trying to override the NavigationView behavior:
public partial class CustomizableNavigationView : NavigationView
{
public CustomizableNavigationView()
{
// This gets called
}
protected override void OnApplyTemplate()
{
// This doesn't
}
}
It works on UWP, but not on Android. On Android, it doesn't call OnApplyTemplate and the screen remains blank, there's not content. Questions:
Why doesn't OnApplyTemplate get called on Android? I see that here: https://platform.uno/docs/articles/implemented/windows-ui-xaml-frameworkelement.html it says OnApplyTemplate() is on all platforms
There's no error or anything displayed in the Output panne in VS while running with debugger. Should there be any in this case? Do I need to enable something to log errors?
I noticed that if I don't use partial it gaves me error saying partial is required. This is required only on Android, why is that? A more in-depth explanation would help a lot to understand how things work.
Once I figure out why OnApplyTemplate is not called, I want to do this:
base.OnApplyTemplate();
var settingsItem = (NavigationViewItem)GetTemplateChild("SettingsNavPaneItem");
settingsItem.Content = "Custom text";
My hunch is this won't work on Android. Am I correct? :)
Jerome's answer explains why OnApplyTemplate() was not getting called, to address your other questions:
You can configure logging filters for Uno, this is normally defined in App.xaml.cs. Warnings should be logged by default.
The partial is required because Uno does some code-gen behind the scenes to create plumbing methods used by the Xamarin runtime. Specifically because the control is ultimately inheriting from ViewGroup on Android, it's a native object, and requires special constructors that are used only by Xamarin's interop layer. There's some documentation in progress on this.
Try it and see. :) GetTemplateChild() is supported, and setting ContentControl.Content in this way is supported, so I would expect it to work.
At current version (1.45 and below), the application of styles is behaving differently from UWP. We're keeping track of this in this issue.
The gist of the issue is that Uno resolves the style using the current type and not DefaultStyleKey, and cannot find an implicit style for CustomizableNavigationView.
A workaround for this is to either create a named style from the default NavigationView style, or create an implicit style that uses CustomizableNavigationView as the TargetType instead of NavigationView.

How can I best use the Tridion Broker as the single source of content for multiple web sites?

I am working on this Tridion implementation that has a bunch of very different websites, but some content (like news) is shared via the basic Tridion principle of blueprinting. Sites are all in the same language, so we are only dealing with branding differences.
Current situation: There is a publication called Global content in which this global content is created. In the schema there are some checkboxes where a child publication this content should appear can be selected. When the component is saved the event system kicks in and creates pages with the components on it, publishes it, etc... deletion of the components doesn't happen, only a resave with all checkboxes unchecked will eventually via a batch process remove pages.
Broker situation: I would like to start using the broker. More so, because in the future situation the website(s) will also start sharing more content to external websites, which I was going to do via RSS feeds or a basic API, which works best with content from the Broker.
The scenarios:
Allow this global content publication to publish dynamic content, and on the other sites pull that content straight from the Broker (with the Global Content Publication ID?)
Make a fake empty target in Global content so they can say "publish/unpublish to all child publications?" (You can still use the checkboxes to allow it to publish in certain publications)
Use a Global Content website for publishing dynamic content and create the API/RSS feeds for internal and external websites to use?
Something else?
My initial thought goes out to the first scenario, but I can see the main drawback that it would become more difficult to mix local(ized) news items and global news items.
The second scenario seems to be the second best chance. Anyone has experience with an implementation like that?
On the implementation I'm currently working on we are using something like the second solution. I added the website master publication (in which we create all pages) to the publication target we use for all the websites so we can use publish to all child publications from there. If it fits in your model I would prefer this option as it continues to give you the control over the items by localization in child publications.
Since we didn't feel like having the content rendered on the website master publication (as this isn't going anywhere and will just be a waste of my publisher processor time and then also a waste of broker storage when it gets deployed), we created a ChildOnlyPublicationResolver (SDL Tridion 2011). In this resolver we loop through all resolved items, and if the item comes from the website master publication, we remove it from the list.
The outcome is that you will see the website master publication appear in the publish queue, but it will be set to success almost instantaneously since there is nothing to render in it. So it doesn't take up any performance from the publisher nor is it deployed, but you keep the benefit of your child publications and have an easy way to publish them in one go.
If interested, here is an example for the resolver code:
using System.Collections.Generic;
using Tridion.ContentManager;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Resolving;
namespace SDL.Example.Resolvers
{
public class ChildOnlyPublicationResolver : IResolver
{
/// <summary>
/// Master Publication TCMURI
/// </summary>
private const string MasterPublicationTcmUri = "tcm:0-2-1";
/// <summary>
/// For publish and unpublish, remove all items from the master publication from the list.
/// </summary>
/// <param name="item">Item to be resolved (e.g. a page, structure group, template)</param>
/// <param name="instruction">Resolve instruction</param>
/// <param name="context">Publish context</param>
/// <param name="resolvedItems">List of items that are currently to be rendered and published (added by previous resolvers in the chain)</param>
public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, Tridion.Collections.ISet<ResolvedItem> resolvedItems)
{
List<ResolvedItem> itemsToRemove = new List<ResolvedItem>();
TcmUri masterPublicationUri = new TcmUri(MasterPublicationTcmUri);
// check for items from master publication (these do not need to be published or unpublished)
foreach (ResolvedItem resolvedItem in resolvedItems)
{
// mark all items from website structure publication for removal
if (resolvedItem.Item.Id.PublicationId == masterPublicationUri.ItemId)
{
itemsToRemove.Add(resolvedItem);
}
}
// remove all items that we need to discard
foreach (ResolvedItem itemToRemove in itemsToRemove)
{
resolvedItems.Remove(itemToRemove);
}
}
}
}
In a traditional Tridion architecture, your best bet might have been to inherit through the BluePrint. This would mean having the content available in all the broker in all publications, and determining which items to show from the metadata.
As Bart has suggested, there are some wasteful aspects to this design, so you might rather think in terms of the global content being "federated" from a single web site. This is what the Content Delivery web service is intended for. If you are on Tridion 2011, you can effectively choose your option 3, but with more out-of-the-box support than used to be present, so you wouldn't have to build the API, just consume it.

Initialization order of static variables in Flex causing bug

I've got a component written for my app by a third party developer and am trying to integrate it, but I've found a bug that seems like it's either a compiler bug, or there's something with how Flex and static variables work that I wasn't aware of.
Basically, I have this:
public class ModeChangeController {
public static const DISPLAY_MODE:String = "DisplayMode";
}
public class Events {
public static const DISPLAY_MODE:String = "DisplayMode";
public static function myStaticFunction( viewState:String = null):void {
//Empty
}
}
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer /*snip*/ >
<fx:Script><![CDATA[
import mypackage.sub1.ModeChangeController;
import mypackage.sub2.Events;
private function showInitialView():void {
// Variant 1
Events.myStaticFunction( Events.DISPLAY_MODE);
// Variant 2
Events.myStaticFunction( ModeChangeController.DISPLAY_MODE);
}
]]></fx:Script>
}
If I use //V2 (i.e. comment out V1), a bug occurs at the startup of the application (some TextFields are uneditable and contains no text), but with //V1 and not V2, it works fine. If I comment out both, that also works fine (I don't get the TextField bug).
It took me a while to figure out that it was that static const String that was causing the issue, but I'm still not sure why or if there's something I can do about it except for just moving the DISPLAY_MODE to Events (which is what I've done at the moment, but it's not a particularly nice solution).
There are no errors in the log. The order of the includes in my BorderContainer code doesn't matter. I've googled for "as3/flex static initialization order" but haven't found anything.
Does anyone know what the problem is?
Clarification: showInitialView() never gets called. It doesn't get there before the other bug shows up. Just having the V2 line there causes the problem.
Update: I've fixed my problem with the TextInput strings not showing: Turns out that adding the component caused the Tahoma font to not show up. However, setting the font-weight to bold fixed that problem, or switching to Arial. With that said, the original question still stands, because when I ran it without V2, it found Tahoma with normal font-weight.
It's not the static string. I tested it myself without a problem. I was skeptical of your issue since the flash static vars would get created when the application is loaded no matter what and the variable would be available.
I believe the problem has nothing to do with the static var but with something else causing an error. It seems that you don't have a version of Flash Player debug by your description. Get it, debug your application line by line and see what the problem is.

How to show a bold message with Seam 2 StatusMessages?

I have a seam component where I put a message using standard seam annotation:
#In
private StatusMessages statusMessages;
public void myMethod()
{
statusMessages.add("Welcome, #{user.getName()}, after confirmation you will be able to log in.");
}
and than in the xthml page to show this message:
<h:messages id="mensagensHome" globalOnly="true" styleClass="message"
errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg"
rendered="#{showGlobalMessages != 'false'}" />
This is working perfectly, but I have a requirement where the name should be Bold. Than I have already tryed placing standard html tags in my message like:
statusMessages.add("Welcome, <b> #{user.getName()} </b>, after confirmation you will be able to log in.");
But than it shows the tags on the page and does not turn the name bold.
I have also tried using unicode escape character to render the html tags, but again no success.
Is it possible to use standard html tags from code looking forward to format messages in Seam?
Tx in advance.
Actually you can't, unlike h:outputText h:messages don't have an escape property where you would be able to do escape="false".
In the link bellow you can find a sample on how to extend h:messages, actually it's not exactly h:messages that is extended but the end result is the same. So you can set escape="false" in h:messages and have the browser parse html tags.
http://balusc.blogspot.com/2010/07/using-html-in-jsf-messages.html
Be careful if you display something that the user inserted because this is is prone to html injection.
Note: The link is not mine, but it did work for me.

Formatting strings in ASP.NET Razor

I am currently writing a small templating system in ASP.NET to allow users to add content. For example, the user can enter the string (variable type is string).
topHeader[x] = "They think it's all over. It is now!";
However, one change that's needed is the ability to add some basic HTML tags within this content, so the following can be done
topHeader[x] = "They think it's all over. <strong>It is now!</strong>";
or
topHeader[x] = "They think it's all over. <a title="Football News" href="URL">It is now!</a>";
If you add such things into strings now they are not formatted as HTML, but I want to somehow escape them so that they can be. Naturally I've looked on the Internet for the answer, but as Razor is fairly new there's not much out there to help me out.
Anyone have an idea of how to do this?
You need to create an IHtmlString implementation holding your HTML source.
Razor plans to have a helper method to do this for you, but, AFAIK, it doesn't yet, so I believe you'll need to create your own class that implements the interface and returns your HTML from the GetHtmlString() method.
EDIT: You can use the HtmlString class.
You can either change your topHeader dictionary to hold IHtmlStrings instead of Strings, or you can leave your code as is, but wrap it in an HtmlString in the Razor view:
<tag>#new HtmlString(topHeader[x])</tag>
Make sure to correctly escape any non-HTML special characters.
The helper method they added is called Html.Raw() and it is much cleaner.
Here is an example:
#Html.Raw("Hello <a>World</a>!")
SLaks is right, but you don't need to write your own implementation of IHtmlString, there's one built in to System.Web called HtmlString. So:
topHeader[x] = new HtmlString("They think it's all over. <a title=\"Football News\" href=\"URL\">It is now!</a>");
Should do the trick.

Resources