I googled a lot but i didn't find an exact answer.
I'm using Prism-Mef, i have RegionB which is nested inside RegionA
When i declare:
IRegion regionB= regionManager.Regions[RegionNames.RegionB];
i got the exception:
The region manager does not contain the RegionB region.
1-How i can access RegionB to Add view to it, knowing that i will use
it as a scoped region.
2-If i have a third level of nesting: for example RegionC which is
nested inside RegionB, how can use RegionC to add a View
Thanks in advance.
Assuming you created a scoped RegionManager - you need to use the scoped region manager of the view that contains the inner region.
var scopedRegionManager = RegionManager.GetRegionManager(view);
var regionB = scopedRegionManager.Regions[RegionNames.RegionB];
Related
I am programmatically setting up a cluster resource (specifically, a Generic Service), using the Windows MI API (Microsoft.Management.Infrastructure).
I can add the service resource just fine. However, my service requires the "Use Network Name for computer name" checkbox to be checked (this is available in the Cluster Manager UI by looking at the Properties for the resource).
I can't figure out how to set this using the MI API. I have searched MSDN and multiple other resources for this without luck. Does anybody know if this is possible? Scripting with Powershell would be fine as well.
I was able to figure this out, after a lot of trial and error, and the discovery of an API bug along the way.
It turns out cluster resource objects have a property called PrivateProperties, which is basically a property bag. Inside, there's a property called UseNetworkName, which corresponds to the checkbox in the UI (and also, the ServiceName property, which is also required for things to work).
The 'wbemtest' tool was invaluable in finding this out. Once you open the resource instance in it, you have to double-click the PrivateProperties property to bring up a dialog which has a "View Embedded" button, which is then what shows you the properties inside. Somehow I had missed this before.
Now, setting this property was yet another pain. Due to what looks like a bug in the API, retrieving the resource instance with CimSession.GetInstance() does not populate property values. This misled me into thinking I had to add the PrivateProperties property and its inner properties myself, which only resulted in lots of cryptic errors.
I finally stumbled upon this old MSDN post about it, where I realized the property is dynamic and automatically set by WMI. So, in the end, all you have to do is know how to get the property bag using CimSession.QueryInstances(), so you can then set the inner properties like any other property.
This is what the whole thing looks like (I ommitted the code for adding the resource):
using (var session = CimSession.Create("YOUR_CLUSTER", new DComSessionOptions()))
{
// This query finds the newly created resource and fills in the
// private props we'll change. We have to do a manual WQL query
// because CimSession.GetInstance doesn't populate prop values.
var query =
"SELECT PrivateProperties FROM MSCluster_Resource WHERE Id=\"{YOUR-RES-GUID}\"";
// Lookup the resource. For some reason QueryInstances does not like
// the namespace in the regular form - it must be exactly like this
// for the call to work!
var res = session.QueryInstances(#"root/mscluster", "WQL", query).First();
// Add net name dependency so setting UseNetworkName works.
session.InvokeMethod(
res,
"AddDependency",
new CimMethodParametersCollection
{
CimMethodParameter.Create(
"Resource", "YOUR_NET_NAME_HERE", CimFlags.Parameter)
});
// Get private prop bag and set our props.
var privProps =
(CimInstance)res.CimInstanceProperties["PrivateProperties"].Value;
privProps.CimInstanceProperties["ServiceName"].Value = "YOUR_SVC_HERE";
privProps.CimInstanceProperties["UseNetworkName"].Value = 1;
// Persist the changes.
session.ModifyInstance(#"\root\mscluster", res);
}
Note how the quirks in the API make things more complicated than they should be: QueryInstances expects the namespace in a special way, and also, if you don't add the network name dependency first, setting private properties fails silently.
Finally, I also figured out how to set this through PowerShell. You have to use the Set-ClusterParameter command, see this other answer for the full info.
I am trying to use the elements I made in Screen Painter in my source code but I am not quite sure how to link them. Can you provide steps how I can link my elements in Screen Painter with ABAP variables?
The connection is established via the name.
If you declare a variable in your report like this:
DATA foo TYPE c.
Then you can view it on your screen by adding a field called foo.
A useful feature of the screen painter is choosing dictionary/program fields. You can access it by pressing F6.
The reference is made by the name of global variables.
You may - as already mentioned - use a DATA matnr TYPE MATNR. to create a global variable matnr.
If you use DDIC-structures or tables you may also define them as
TABLES: MARA.
In screen painter you can reference the fields of the table/structure MARA.
(You can replace MARA with any table/structure).
Depending on the complexity of your program you may define your own structure, just as a interface between the report code and the screen-painter.
The variables used in screen painter should be declared in a TOP in order to be accessed from the includes in the program.
For example, in my screen I request for a Business Partner name and map it to GT_NAME. GT_NAME should be declared in the TOP with something like the code below:
DATA: GT_NAME type bu_first.
That automatically creates the link between the global variables and the input parameters in the screen.
I have been following Yannick Ongena's tutorial http://yonaweb.be/webcenter_tutorial/using_content_presenter_templates
I am looking to alter some code in the content presenter template "training-list-item.jsff" so that the region definition will have a dynamic value.
That is, rather than writing
<af:outputText value="#{node.propertyMap['RD_TRAINING:description'].asTextHtml}"
escape="false" id="ot5"/>
I am looking to write like
<af:outputText value="#{node.propertyMap['xRegionDefinition:description'].asTextHtml}"
escape="false" id="ot5"/>
Unfortunately, this does not work. If I write only "xRegionDefinition" within the propertyMap,it displays the region definition name in the portal, that is "RD_TRAINING". But I am looking to display the value of element definition within the region that is, the "description".
My objective is to display different region definitions at the portal rather than a hard coded fixed region. I have wrote some Java code also to dynamically change the CMIS query to supply a new value for the region definition:
if(news){
query = "SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition LIKE \'RD_TRAINING\'";
}
else
query = "SELECT * FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition LIKE \'RD_SWEDISH\'";
Please help. Hope I am clear in explaining the requirement.
Why don't you use ADF Switcher component if you only have 2 options!
Check this video to know how to use it
I get confused with Windows 8, as I get used to access a template that i had defined in page like this :
FrameworkElement element = container as FrameworkElement;
DataTemplate myTemplate = element.FindResource("myTemplate") as DataTemplate;
The problem is that in Windows 8 the FindResource method doesn't seem to exist anymore. I try to access the Resource Dictionnary but without any success.
Do you have any idea, or Should the previous example work?
Thank you
FrameworkElement has a Resources property that you can access through it's indexer like so:
var template = element.Resources["myTemplate"] as DataTemplate;
This property is only populated with the resources defined on that element and is not the full collection of resources in the Application. So whether that template will be found depends on where you've defined in.
You can find the resources defined in App.xaml (as well as it's merged resource dictionaries) like so:
var template = Application.Current.Resources["myTemplate"] as DataTemplate;
I want to create 2 delegates with the same name but different parameters (overloaded delegate). When I try to add a delegate I get an error on the second try due to a delegate already existing. I tried to add it first with a temp name then add the parameters and then change the name so the signuature would be different but I still get an error stating that an item already exists with that name.
How can I add an overloaded delegate?
The capabilities of the code model to generate code are limited. You can try the to use EditPoint.Insert(...) to insert the code instead of using AddDelegate() method.