Difference between Ti.App.VariableName & Ti.App.Properties - appcelerator

In Titanium, what is the differences between the following two lines of codes?
Ti.App.currentUser = "user1";
Ti.App.Properties.setString("currentUser", "user1");

Ti.App.Properties :
The App Properties module is used for storing application-related data in property/value pairs that persist beyond application sessions and device power cycles.
App Properties in the tiapp.xml file
App properties defined in the tiapp.xml file may be accessed using these APIs. An app property is defined inside the root-level <ti:app> element with the <property> element. Use the name attribute to define your property name and place the value inline with the <property> element. For example, to define an app property called foo with the value 42:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<property name="foo" type="string">42</property>
</ti:app>
Ref : http://docs.appcelerator.com/platform/latest/#!/api/Titanium.App.Properties
Ti.App.VariableName stores a variable not persistent and only for the App runtime.
The top-level App module is mainly used for accessing information about the application at runtime, and for sending or listening for system events.
The App module exposes a number of properties set in the tiapp.xml file.
Three of these properties, the application name, ID, and URL, must be specified when the application is created.
While most values may be changed by editing the tiapp.xml file after creating the project, the GUID is automatically generated and should not be changed.
More details Titanium.App
At the end if you want store and retrieve values in tiapp.xml file you should use Titanium.App.Properties

Abada does a great job explaining the difference, but let me emphasis that you should not add any custom properties to Titanium proxy objects like Ti.App. This is bad practice because it may lead to memory leaks and unpredictable behaviour. These objects are not 100% JS but bridge to Obj-C/JAVA/C+

Related

Extending Visual Studio 2017 XML editor

I'm trying to improve our workflow with some XML-configuration files we use in a Visual Studio Solution. I figured I'll start with explaining what I'm trying to accomplish and then explain some of my ideas that I've tried for several hours without success.
The Problem
I'm working with a system where the data model is configured in a database, the models are also stored on disk using xml-files, these are then synced during startup of the app. Here's part of the stuff that are synced:
Data Types
All data types lives in one XML configuration file per data type and each has some properties like Name and Key. All data types are configured in the same folder, example: /config/dataTypes
Example
textString.config
<?xml version="1.0" encoding="UTF-8" ?>
<DataType Key="a45c9a94-09d7-4df9-85e6-d6930abc6c12" Name="Textstring">
textArea.config
<?xml version="1.0" encoding="UTF-8" ?>
<DataType Key="b104788f-4e2f-4592-9387-8b3861bd8046" Name="Textarea">
Entity Types
Think of these as models with X number of properties, each property is configured and connected to a Data Type.
Example
customer.config
<?xml version="1.0" encoding="UTF-8" ?>
<Entity>
<Properties>
<Property Name="Firstname" TypeKey="a45c9a94-09d7-4df9-85e6-d6930abc6c12" />
<Property Name="Lastname" TypeKey="a45c9a94-09d7-4df9-85e6-d6930abc6c12" />
<Property Name="Description" TypeKey="b104788f-4e2f-4592-9387-8b3861bd8046" />
</Properties>
</Entity>
My end goal is to provide intellisense when editing a Entity Type so that I'll get all the Data Types as suggestions when entering the "TypeKey" property of the Property element. Preferably showing the Name of the data type in the dropdown list and when choosing it adding the guid as value for the TypeKey-property. I would also like to show the Data Types name when hovering the GUID with the mouse (or in some other way).
As you can imagen during the process with a project new data types can be added so the intellisense needs to be dynamic based on the files in the data types-folder.
I should also mention that these configuration files also can be edited from a UI in the application and I don't have control over how they are serialized, hence - there is no XML namespace in the files, they look like in the examples above.
We also have multiple different VS-solutions with different setups of Data Types and Entity Types. So we need individual intellisense in each project.
What I've tried
My first idea was to create a VS-extension that creates a dynamic XML Schema XSD-file based on the files in the data types folder. The VS would then pick up and use the XSD for XML-files in the Project, turns out that this only works with a namespace configured (remember, I can't add namespaces since I don't control the external app).
To get around this it worked to manually add the schema-file to the XML file while editing the file. (Like this: https://learn.microsoft.com/en-us/visualstudio/xml-tools/how-to-select-the-xml-schemas-to-use?view=vs-2019). The problem with this is that it needs to be done for each xml-file and the setting is not stored.
I then started to play with the VS extension possibilities to try to automatically configure this Schema to a XML-file that is opened. Turns out I had a really hard time to get the "configuration object" that is pushed to the Properties Browser when the XML file is opened. I managed to get a event-handler setup that was triggered when the XML files as getting "focus" but I was stucked trying getting the properties from the Properties Browser.
I also tried another approach with a custom "code completion"-extension but it made the UI feel very "cluttered" while editing.
After spending about 10 hours playing around with this I feel I don't really have a good path to a solution as my experience with VS-extensions is not that extensive.
I would love to get some feedback and ideas on how to approach this problem, since the XSD is different from each project if I go down the "dynamic" path we can't use the global VS settings since each project has different data types hence needs different allowed values for the TypeKey property.
One approach that I'm thinking about is to use a generic XSD (allowing all values for the TypeKey) in the Global Schema Cache for Visual Studio and create a "code completion"-feature for just the TypeKeys.
Any thoughts and pointers in the right direction would be very much appreciated.

How to access web.config sections in a Web service called from another application?

I'm working on a Web service with Visual Studio, framework 4.7.1. One of its Web methods needs to call another Web service (provided by another company). It converts the parameters it receives (that are consistent with our main application's business logic) into values the other Web service can handle (according to it's own business logic). To do this, it relies heavily on data stored in the Web.config file.
I tested it directly (start the Web service and call the Web methods with automatically generated pages on a Web browser page) and everything worked fine.
Now, I need to build a test application (also in Visual Studio, framework 4.7.1) to call the same Web methods. On first testing it, I noticed that the Web service was trying to access the test application's config file instead of its own (as described in Can't read Web.config with ConfigurationManager.AppSettings ).
So I created an applicationSettings section in the Web.config and moved all the data from appSettings into it. It worked fine.
Now, however, I notice that the same thing happens with the custom sections. One of them looks like this:
<configSections>
<section name="jobTypeLists" type="AdelSoft_WS_FRA.JobTypesSection" />
</configSections>
<jobTypeLists>
<jobTypes>
<jobType codeCustomerType="A" codeJobType="JobForA" />
<jobType codeCustomerType="B" codeJobType="JobForB" />
</jobTypes>
</jobTypeLists>
I can see how such a structure could fit into its own .settings file, but I have another one that is much more complicated. (Like, the text nodes can have up to four ancestors.) To keep this short-ish, I'm not providing it now, but it can easily be arranged.
ConfigurationManager.GetSection("jobTypeLists") returns null when called from the test application. Same with WebConfigurationManager.GetSection("jobTypeLists").
I've also tried accessing the configuration file with ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), but I can't seem to find my sections in the Configuration object it returns.
I'm not sure it means anything, but the Configuration object's FilePath property contains "C:\Folder\InnerFolder\WebServiceFolder\web.config.config". Why this second ".config"? I tried passing the same string to ConfigurationManager.OpenExeConfiguration(), without the ".config" extension: it returned null. (As it should, I feel.)
The Configuration object has 10 section groups and 22 sections, which I can't make heads or tails from. Likewise, I can list them.
Actually, there are two ways for a Visual Studio project to reference a Web service: as a regular reference (like you would any other project) or as a Web reference.
I was using the former, and therein lay my mistake.
To reference the Web service, I started it, copied the URL from the browser window that it opened, and pasted it into the "URL" text box in the "Add a Web reference" window from my test application. From there on, it worked fine.
(By the way, I have kept the regular reference as well, because I'm using some constants from the Web service to handle return values.)

How to define composed id for an api resource in api-platform?

I made an API resource which is not connected to a database table. I have a custom item data provider for it. I need a composed identifier for that resource. In the resource's class, I set for 3 properties the #ApiProperty(identifier=true): platform, platform version, and app version. But the generated method for getting the item has only one id. The path generated for it is /versionInfos/{id}.
Do I have any solution to make a automatically generated path like:
/versionInfos/{platform}/{platformVersion}/{appVersion}?

Maintaining file of object properties in Watin + Visual Studio

I am working with Watin and maintaining excel file for listing object properties.
It takes lot of time to when I read object properties from excel file.
Is there any other way to store these object properties at centralised location so that we can refer object properties and change in any object will get reflected in all TCs using this object.
In short content of excel file is as follow:
Menu----------------------------id
username_txtfield------------uname
password_txtfield------------ pass
ok_webedit-------------------submit
You can use appSettings in App.config for managing key-value pairs - access is very fast.
You'll also want to create a data access class that abstracts away where the settings are actually being stored so that if (when?) you change where you properties are being stored you just change one class rather than going through your entire codebase making changes.

Visual studio 2010 - difference between Settings.settings and Resources.resx

simple question here. What is the difference between putting a string in Settings.settings and putting a string in Resources.resx ?
Regards
In Settings.setting the string will be placed in a config file, bassicaly a xml document which stores all kind of information your application needs to run. It's best practice to store configurable information in here. Also you can set the scope of the config value (application and user).
Application scoped config values will be shared among all users, while the user ones are limited to the current executing user of the application.
The .resx file is the place for storing all kinds of stuff your application needs to run, like images and so on. Files in here should be normally not editable by the user, its as the name states, a resource pool for your application. Also resources are also always global.

Resources