qooxdoo : protected / private properties? - qooxdoo

I have an Object class that has a property called counter. Can I set it as private or protected, i.e. this._counter or this.__counter ?
qx.Class.define("myApp.model.MyClass",
{
extend : qx.core.Object,
construct : function() {
},
properties : {
counter : { init : '', check : 'Integer' }
}
});
Properties is good , as it enables automatic generation of getCounter() and setCounter(val).
But is there any disadvantage to set it as public properties ?

Sorry, but setting a property to private or protected is not possible. You have to use a member variable instead and either access it directly or write your own setter / getter.

Related

Azure Logic Apps can't programmatically build And / Or Condition using ASP.Net SDK

I'm programmatically building a Condition in a Logic App. If the user selects Or, I use the Or Condition. If the user selects And, I use the And Condition.
I can get Or to work by itself. I can also get And to work by itself.
public class Expression
{
public Or[] or { get; set; }
}
public class Expression
{
public And[] and { get; set; }
}
When I try to use the Expression class below, I get a "Condition has 2 top level properties. Only 1 is allowed." error.
public class Expression
{
public Or[] or { get; set; }
public And[] and { get; set; }
}
If I set one to null, I get the error. If I set one to an empty array, I get the error.
UPDATE 1
Here is the Logic App code view in Azure.
"expression": {
"and":
[
{
"contains": [
"#outputs('Compose_3')",
"foo"
]
},
{
"contains": [
"#outputs('Compose_3')",
"bar"
]
}
]
},
Does anyone know how to get this to work? Am I missing something simple here? Any help is much appreciated. Thanks in advance!
Logic App has a default AND / OR and other conditional operators. If you want to add a custom condition you can use an Azure Function. In the Azure Function, you can implement your custom requirement and it is the correct environment to implement your thoughts of logic.
You can include the Azure Function in a logic app to perform your task. Refer here
Or we have another option to implement a custom requirement which is Logic App Custom Connector. Please have a look here
I finally got this working. When you Serialize the JSON, use "IgnoreNullValues = true". This will ignore the null value this is present when you set the And or Or value in your Expression object. ReplaceFirst simply adds a "$" to the word "schema" on the first occurrence.
var options = new JsonSerializerOptions { WriteIndented = true, IgnoreNullValues = true};
string jsonString = ReplaceFirst(JsonSerializer.Serialize(myApp, options), "schema", "$schema").Replace("_else", "else").Replace("_foreach", "foreach");
string ReplaceFirst(string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}

Typescript and Angular Initialise objects in the constrcutror of the class, from other class type

I have a simple case which just makes me nuts.
module PaymentType {
export interface IPaymentTypeScope extends ng.IScope {
PaymentTypeApprovals: PaymentTypeApproval[];
FormatDate: Function;
....
AuditTrailDialogObject: AuditTrailDialog;
.....
}
export class PaymentTypeController {
private _: UnderscoreStatic;
private _scope: IPaymentTypeScope;
private _log: ng.ILogService;
private _q: ng.IQService;
private _paymentTypeService: IPaymentTypeService;
private _sce: ng.ISCEService;
constructor($scope: IPaymentTypeScope, $log: ng.ILogService, paymentTypeService: PaymentType.IPaymentTypeService, $q: ng.IQService, $sce: ng.ISCEService) {
this._paymentTypeService = paymentTypeService;
this._scope = $scope;
this._log = $log;
this._q = $q;
this._sce = $sce;
....
this.InitialiseScope();
}
InitialiseScope = () => {
this._scope.AuditTrailDialogObject = new AuditTrailDialog();
}
.......
I am trying to have an object of type AuditTrailDialog inside a method in the class. In that method I plan to set some properties of that dialog and then use it for binding.
This code gives me an error - undefined is not a function in the point of initialising the object.
If I do not initialise the object, I got an error - Cannot set property 'Title' of undefined.
Please help what should I do so I can use the object of another class in my class and then use it for angular binding in the controller.
Thanks
This code gives me an error - undefined is not a function in the point of initialising the object.
This is a runtime error that has to do with how you load your JavaScript. This depends on additional context surrounding your code no presented in the answer. I recommend you use something like requirejs and compile typescript with --module amd instead of manually loading (seemingly incorrectly) the generated javascript. Also recommend against --out / the module keyword as documented here : https://github.com/TypeStrong/atom-typescript/blob/master/docs/out.md

Pass simple parameter to unity Container

I have a key "MyKey" It can have a value "Key1" or "Key2".
Now i need to pass to container "MyKey" and value "Key1".
Can this be done without creating a Interface object in Container??
Any methods to go about.
public class KeyMode:IKeyMode
{
private string keyMode;
public KeyMode(string keyMode)
{
this.keyMode= keyMode;
}
public string getKeyMode()
{
return keyMode;
}
}
public interface IKeyMode
{
string getKeyMode();
}
KeyMode rcm = new KeyMode("key1");
container.RegisterInstance<IKeyMode>(rcm);
I have created IUnityContainer object "container" and a class KeyMode and a interface...I am creating Keymode object and registering value to container to pass.
Instead of KeyMode object creation. Is there a method to directly pass to container object in key value pair
I guess something like below you after.
IUnityContainer container = new UnityContainer();
container.RegisterType<IKeyMode, KeyMode>(new InjectionConstructor("key1"));
var keyMode = container.Resolve<IKeyMode>();
Console.WriteLine(keyMode.GetKeyMode());
You can pass objects at resolve time by using ResolverOverrides. See Resolving Objects by Using Overrides.
Unity knows how to construct classes so you don't need to register the interface if you don't want to. You could do something like this:
IUnityContainer container = new UnityContainer();
KeyMode keyMode = container.Resolve<KeyMode>(
new ParameterOverride("keyMode", "Key1"));

Extjs Class System statics

I want to define a class with utility functions. I'm using Extjs class system.
I'm doing this in the following way:
Ext.ns('Controls.Plugins.Nzok')
Ext.define('Controls.Plugins.Nzok.XUtility', {
statics : {
getTest : function(test) { return test }
}
})
Now when I want to use getTest method I have to require the class and to write full class name
Ext.define('Controls.Plugins.Nzok', {
requires : ['Controls.Plugins.Nzok.XUtility'],
useTest : function() {
var testResult = Controls.Plugins.Nzok.XUtility.getTest(2);
}
})
My problem is that notation is too long. It's very inconvenient to write down every time Controls.Plugins.Nzok.XUtility. Are there any solution?
The alternateClassName config does the trick.
Ext.define('Controls.Plugins.Nzok.XUtility', {
alternateClassName: 'Controls.XUtil', // <--- this is your shorthand
statics : {
getTest : function(test) { return test }
}
});
As a side note, Ext.define will automatically create namespaces based on your class name, so Ext.define('Controls.Plugins.Nzok.XUtility' will generate the Controls.Plugins.Nzok namespace for you.

Register views with regions depending on the user rights

I have a TabControl as an ItemControl hosting a region, let's call it ContentRegion. Several modules register at least one view into the ContentRegion. But these registrations are made during module initialization.
I want to prohibit the registration of several views depending on the current user. But the user logs on after the module initialization and also can change during runtime.
Is there a way to provide a callback where prism can evaluate if the registration is active? Or do I have the chance to disable registrations of the region manager? Any other ideas?
The answer is quite simple: Implement a custom region behaviour. You just have to derive from the existing AutoPopulateRegionBehaviour:
public class SecurityEnabledAutoPopulateRegionBehaviour : AutoPopulateRegionBehavior
{
IUnityContainer container;
public SecurityEnabledAutoPopulateRegionBehaviour(IUnityContainer container, IRegionViewRegistry regionViewRegistry)
:base(regionViewRegistry)
{
this.container = container;
}
protected override void AddViewIntoRegion(object viewToAdd)
{
IRequiredAccessRight viewPermission = viewToAdd as IRequiredAccessRight;
if ( viewPermission != null )
{
ISessionManager sessionManager = container.Resolve<ISessionManager>( );
if ( sessionManager.AccessRights.IsGranted( viewPermission.RequiredAccessRight ) )
{
this.Region.Add( viewToAdd );
}
}
else
{
this.Region.Add( viewToAdd ); //The region does not require any permissions so we can proceed
}
}
}
The last step is to override all AutoPopulateRegionBehaviours or only on specific regions. How to achieve this is described in Appendix E of the Prism documentation in detail. What i did was to attach the behaviour only to a specific region and replace the AutoPopulateRegionBehaviour:
public partial class MyView : UserControl
{
public MainView( IUnityContainer container )
{
InitializeComponent( );
ObservableObject<IRegion> observableRegion = RegionManager.GetObservableRegion( ControlHostingTheRegion );
observableRegion.PropertyChanged += ( sender, args ) =>
{
IRegion region = ( (ObservableObject<IRegion>)sender ).Value;
region.Behaviors.Add( AutoPopulateRegionBehavior.BehaviorKey,
(SecurityEnabledAutoPopulateRegionBehaviour)container.Resolve( typeof( SecurityEnabledAutoPopulateRegionBehaviour ) ) );
};
}
}
You could bind the TabItem.Visibility to a variable that indicates if it should be shown or not. Once you checked the user rights, set this variable so that it hides unwanted tabs.
Another possibility would be to add the views to the regions after you checked the user rights, instead of registering the views with the regions.
IRegion detailsRegion = regionManager.Regions["DetailsRegion"];
detailsRegion.Add(view, viewName);
detailsRegion.Activate(view); // not sure if you need the Activate

Resources