Wrong TypeName after obfuscation - vb.net

I have a problem with user controls:
My VB.Net application AppliTest uses a PlusMinus user control.
In the application, I need at some point to treat each control according to its TypeName.
This works fine before obfuscation with Obfuscar ( c.Name=PM_Large c.Type=PlusMinus ). c is the control.
After obfuscation, the instance name of my user control is correct, but the TypeName has been obfuscated ( c.Name=PM_Large c.Type=λΆ• ). Note that all is correct with windows controls like Label, TextBox ...
I searched in the Obfuscar configuration possibilities without success.
Here are my settings for Obfuscar:
SkipType name="AppliTest .PlusMinus"
Var name = "KeepPublicApi" value="false"
Var name = "HidePrivateApi" value="true"
Var name = "RenameProperties" value="true"
Var name = "RenameFields" value="true"
Var name = "UseUnicodeNames" value="true"
Var name = "HideStrings" value="true"
Var name = "OptimizeMethods" value="true"
Var name = "ReuseNames" value="true"
Var name = "UseKoreanNames" value="true"
Is there a solution, either to make the type name protected, or to prevent Obfuscar from obfuscating the type name?

Related

Localize strings in XAML UI in UWP

I have a resource entry named info_278 in the Resources.resw file on my UWP app. I have 3 scenarios where I need to use this resource but looks like I need to duplicate this to cater to different scenarios. Scenarios are as follows.
Error message content from code
var displayErrorOnPopup = ResourceHandler.Get("info_278");
TextBlock Text property from XAML (Looks like a new entry needed as info_278.Text)
<TextBlock x:Uid="info_278" Margin="10,0,0,0" />
Button Content property from XAML (Looks like a new entry needed as info_278.Content)
<Button x:Uid="info_278" Margin="10,0,0,0" />
How do I proceed without duplicating this resource in the .resw file?
The only way to avoid duplication is to set the string value in code-behind using ResourceLoader. Because you could direct access to the specific property of the target control. Like this:
var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
this.TextBlock.Text = resourceLoader.GetString("info_278");
If you are not going to do it in the code behind, then I have to say there is no way to avoid the duplication of the resource string. You should add info_278.Text and info_278.Content for different XAML scenarios.
You could create a markup extension. I've used this in WinUI 3, but should work in UWP too.
using Microsoft.UI.Xaml.Markup;
using Windows.ApplicationModel.Resources;
namespace MyApp;
[MarkupExtensionReturnType(ReturnType = typeof(string))]
public class StringResourceExtension : MarkupExtension
{
private static readonly ResourceLoader _resourceLoader = new();
public StringResourceExtension() { }
public string Key { get; set; } = "";
protected override object ProvideValue()
{
return _resourceLoader.GetString(Key);
}
}
Then in the XAML:
...
local="using:MyApp"
...
<TextBlock Text="{local:StringResource Key=info_278}" />
<Button Content="{local:StringResource Key=info_278}" />
The Content of Button can be a TextBlock:
<Button>
<TextBlock x:Uid="MyTextId" Style="{StaticResource MyTextBlockStyle}" />
</Button>

disable menu based on value of a preference variable

I have a menu item XYZ. I have a preference page MyPref which has a check box and a couple of text fields. When the check box in MyPref is check, I want menu XYZ to be enabled else it should be disabled. Is there a way to achieve this.
Yes, the way certainly exist.
1). Create an entry in your IPreferenceStore - just get the class which extends AbstractUIPlugin and do the following:
IPreferenceStore store = IExtendAbstractUIPlugin.getDefault()
.getPreferenceStore();
then store some value which will reflect your checkbox state:
preferenceStore.setValue("XYZMenuPreference", false); // if disabled
or
preferenceStore.setValue("XYZMenuPreference", true); // if enabled
2). Create a Property Tester extention to your plugin.xml:
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.xyz.PropertyTester"
id="org.xyz.PropertyTester"
type="java.lang.Object"
namespace="org.xyz"
properties="XYZmenu">
</propertyTester>
</extension>
3). When declaring your menu handler in plugin.xml you should add the following:
<handler
class="your-menu-handler-class"
commandId="your-command-id">
<enabledWhen>
<with variable="selection">
<test property="org.xyz.XYZmenu" value="true" forcePluginActivation="true"/>
</with>
</enabledWhen>
</handler>
4). Now you need a class "org.xyz.PropertyTester" (as defined in plugin.xml) which will extend the org.eclipse.core.expressions.PropertyTester and override method test(<some args>) where he must check the property value:
if (property.equals("XYZmenu"){
IPreferenceStore store = IExtendAbstractUIPlugin.getDefault()
.getPreferenceStore();
return store.getBoolean("XYZMenuPreference");
}
5). After that add a change listener to your checkbox and use it to re-evaluate a visibility of your menu item:
IEvaluationService service = (IEvaluationService) PlatformUI
.getWorkbench().getService(IEvaluationService.class);
service.requestEvaluation("org.xyz.XYZmenu");
it will force the method test() from your org.xyz.PropertyTester class to be called and will enable your menu item if preference
"XYZMenuPreference" is set to true.
upd.
namespace - a unique id determining the name space the properties are added to
properties - a comma separated list of properties provided by this property tester
this is from official eclipse tutorial so you can feel free to define any namespace and property name, but the you should use it like in point 5.

Add a key to ListPickerItem

XAML:
<toolkit:ListPicker x:Name="profession" SelectionChanged="ListPicker_SelectionChanged">
<toolkit:ListPickerItem Content="Value1" />
</toolkit:ListPicker>
How can I add a key to the ListPickerItem to be used in the C# code?
What I want is similar to HTML's value attribute for the option control.
Example of what I want: (C# code, OFC not working..)
int a = profession.SelectedItem.Key;
You can use the Tag property.
<toolkit:ListPickerItem Content="Value1" Tag="1"/>
var a = ((ListPickerItem)profession.SelectedItem).Tag;
If you are trying to do this when your app first loads, then in your MainPage.xaml.cs file, include this in your constructor:
public MainPage(){
InitializeComponent();
profession.Items.Add("Value2"); // Add this line here
}
Otherwise, put this line wherever you need it.

Add new object to domain data source

it drives me crazy. I'm working at a Silverlight 5 Business Application and using WCF Ria Services (Domain Data Source). In a simple ChildControl I load the defined (see code below) domain data source "ddsTerminKonfiguration". The query method returns a generic IQueryable<TerminKonfiguration> list. If this list has no items (...DataView.Count == 0) I want to add a new object of "TerminKonfiguration". When I try to execute ddsTerminKonfiguration.DataView.Add(new TerminKonfiguration()); I run into an error "'Add' isn't supported by this ICollectionView" (I only know the german error message ... so I hope everybody can understand my translation :-D). Comparable code snippets in this project (coded by other developers) are working properly ... and I don't know, how to solve this problem.
Does anyone have an idea or solution for my problem?
My domain data source ...
<riaControls:DomainDataSource Name="ddsTerminKonfiguration"
Width="0"
Height="0"
AutoLoad="False"
d:DesignData="{d:DesignInstance my1:TerminKonfiguration, CreateList=true}"
LoadedData="ddsTerminKonfiguration_LoadedData"
SubmittedChanges="ddsTerminKonfiguration_SubmittedChanges"
QueryName="GetTerminKonfigurationQuery">
<riaControls:DomainDataSource.DomainContext>
<my:RRPDomainContext />
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.QueryParameters>
<riaControls:Parameter ParameterName="param01" />
<riaControls:Parameter ParameterName="param02" />
<riaControls:Parameter ParameterName="param03" />
<riaControls:Parameter ParameterName="param04" />
</riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>
The namespace "my" references to "Project".Web.Services and "my1" to "Project".Web.Models.
The query method ...
public IQueryable<TerminKonfiguration> GetTerminKonfiguration(string param01, string param02, int param03, int param04) {
return this.ObjectContext.TerminKonfiguration.Where(d => (d.MandantenNr == param01) && (d.WorkflowNr == param02) && (d.WfAufgabeId == param03) && (d.WfAufgabeIdGlobal == param04));
}
The snippet, where I try to add the new object to the DataView ...
if (this.ddsTerminKonfiguration.DataView.Count == 0) {
TerminKonfiguration tmpConfig = new TerminKonfiguration();
/*
define the new object
*/
this.ddsTerminKonfiguration.DataView.Add(tmpConfig); // problematic line
}
this.ddsTerminKonfiguration.SubmitChanges();
DataView is a DataView this is the cause. DataView is the view of data.
With a datasource you can filter order etc then you see the effects on DataView.
this.ddsTerminKonfiguration.DataView.Add is not a valid operation.
http://msdn.microsoft.com/en-us/library/ee707363(v=vs.91).aspx
Basic usage is
<Grid x:Name="LayoutRoot" Background="White">
<riaControls:DomainDataSource x:Name="source" QueryName="GetProductsByColor" AutoLoad="true">
<riaControls:DomainDataSource.DomainContext>
<domain:ProductDomainContext />
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.QueryParameters>
<riaData:Parameter ParameterName="color" Value="Black" />
</riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>
<data:DataGrid ItemsSource="{Binding Data, ElementName=source}" />
</Grid>
As you notice it DataGrid bound to Data not DataView.
{Binding Data, ElementName=source}"

How do I show the correct Taxonomy control in a SharePoint 2010 EditModePanel?

We have a custom content type in our SharePoint 2010 build which includes a Managed Metadata field for keywords.
The field seems to have deployed OK because if I edit an item in the list in which it resides I get the correct Taxonomy picker control and my terms are retrieved from the term store.
However; we are using an EditModePanel on the PageLayout for the item to allow in-site editing of the items and I can't get the correct Taxonomy picker control to appear.
If I add a TaxonomyWebTaggingControl to the page layout and hardcode the SSPId etc then it works;
<TaxonomyControls:TaxonomyWebTaggingControl runat="server" SSPId="234234-234234-34341-343" TermSetId="234234-23342-34234-234-234"/>
However we can't hardcode the values as the term store will be created when the client deploys the site.
When we create the Content type we have an Event Receiver which binds the field to the correct Term Store/Set using their names but I don't understand how to get a field in the EditModePanel to get/set these.
What I really want is something like:
<TaxonomyControls:TaxonomyWebTaggingControl runat="server" TermStore="My term store name" TermSet="Keywords"/>
Am I missing something?
My event receiver looks like this:
try
{
SPSite site = ((SPWeb)properties.Feature.Parent).Site as SPSite;
Guid fieldId = new Guid("3211B052-5332-424C-A066-BBE21AEAB878");
if (site.RootWeb.Fields.Contains(fieldId))
{
TaxonomySession session = new TaxonomySession(site);
if (session.TermStores.Count != 0)
{
var termStore = session.TermStores["Managed Metadata Service"];
var group = termStore.Groups.GetByName("My Client");
var termSet = group.TermSets["Keywords"];
TaxonomyField field = site.RootWeb.Fields[fieldId] as TaxonomyField;
field.SspId = termSet.TermStore.Id;
field.TermSetId = termSet.Id;
field.AnchorId = Guid.Empty;
field.AllowMultipleValues = true;
field.TextField = fieldId;
field.TextField = new Guid("{574C5BCE-74E8-40C8-BE90-C9338135D491}");
field.Update();
Log.Logger.LogEvent("ContentType Activation", "Updated keywords field with MMS details");
}
}
}
catch (Exception ex)
{
Log.Logger.LogException(ex, "Content Type Activation", ex.Message);
}
You should use the TaxonomyFieldControl for this:
<%# Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<Taxonomy:TaxonomyFieldControl FieldName="My Field Name" runat="server" id="myField"/>