Debugging setup in VB.Net Visual Studio 2019 Community edition - visual-studio-2019

This is going to sound silly but here it goes. For quite some time, while debugging in VS 2019, when you hover your mouse over a dictionary(of string, String), you see a little arrow pointing right, when you over over that, the contents would be displayed in array order, showing:
(0) Key = "Key", Value = "Value"
(1) Key = "Key", Value = "Value"
(2) Key = "Key", Value = "Value"
Now, somehow it's been reversed, it's showing :
(0) Value = "Value", Key = "Key"
(1) Value = "Value", Key = "Key"
(2) Value = "Value", Key = "Key"
Can someone please point me to where I can set it back to showing the key's first instead of the values?
Thanks!

Related

Processing json string in mql4

I have received the following string:
{"records":[{"id":"rec4haaOncoQniu8U","fields":{"orders1":5},"createdTime":"2020-02-08T09:08:22.000Z"}]}
I am not understanding how I can process and separate the values of the json in mql4 using the "JAson.mqh " library, located here: https://www.mql5.com/en/code/13663
I need the values of "orders" located under "fields" , value = 5.
the only "KEYS" that changes are the keys within the "fields" values.
i would like to be able to get the values with something like this:
string value1 = Result[0].["fields"].["orders1"]; //5
string value2 = Result[0].["fields"].["orders2"];
Please let me know what I can do.
You can get the value using the following format. Note that it has to be casted to a type. (I have casted it to int as it is the type it is in the JSON, but you can cast it to string as well)
int value1 = json["records"][0]["fields"]["orders1"].ToInt(); // if you want to make it a string use ToStr() instead of ToInt()
Here is a full example of what I did
string jsonString = "{\"records\": [{\"id\": \"rec4haaOncoQniu8U\",\"fields\": {\"orders1\": 5 }\"createdTime\": \"2020-02-08T09:08:22.000Z\"}]}";
if(json.Deserialize(jsonString))
Alert(json["records"][0]["fields"]["orders1"].ToInt());
Hope it helped.

QBCOCustomObject fields property returning nil for key

I am surprised by this behaviour or i do not know confidently that its might be my mistake.The problem is when i am retrieving records from Quickblox API which are QBCOCustomObject instances.I am getting the instance properties in debugger console but when accessing those values using keys i am getting nil and crashing as with the Swift force wrapping feature.
This is my console output for QuickBlox API.
{
"class_name" = PLProjectMember;
items = (
{
"_id" = 57177bd263f2d26030d616a0;
"_parent_id" = 57177bd2a0eb47c43b000019;
"created_at" = 1461156818;
name = "Ajay Babu";
"updated_at" = 1461156818;
"user_id" = 11736197;
},
{
"_id" = 57177bd263f2d26030d616a1;
"_parent_id" = 57177bd2a0eb47c43b000019;
"created_at" = 1461156818;
name = "Ajay Nath";
"updated_at" = 1461156818;
"user_id" = 11736197;
}
);
limit = 0;
skip = 0;
}
I am accessing values like this,once i get the QBCOCustomObject instance.For example say my instance is firstCustomObject after parsing the result.Here is the code for getting vales,
firstCustomObject.fields?.valueForKey("name") // Worked Great
firstCustomObject.fields?.valueForKey("_id")//Crash as its giving nil
firstCustomObject.fields?.valueForKey("_parent_id")//Crash
firstCustomObject.fields?.valueForKey("updated_at")//Crash
I have also used objectForKey() method also, but the same is happening Crash. Other than name key all are giving me back nil and leading app to crash. Can any one come across this problem, please give me suggestion for getting resolved.
i never though that i would get the answer and give it back this much early.The solution is here,
https://sdk.quickblox.com/ios/documentation/Classes/QBCOCustomObject.html#//api/name/customObject
QBCOCustomObject having properties ID,parentID,userID.we can directly access the values from thee instance.Like,
firstCustomObject.ID
firstCustomObject.userID
firstCustomObject.parentID.

DynamoDB how to use a filter expression on a bool value

How do I filter a dynamoDB table with an expression on a bool value. I can filter successfully on an Int or String value. But even in the web console when trying to create a filter expression on a bool value it won't give any results back?
I'm trying this from Swift on iOS as well, but the fact that it doesn't even work int he web interface makes me wonder how to at all achieve this.
If I filter on an Int it works, i.e.
let queryExpression = AWSDynamoDBQueryExpression()
queryExpression.rangeKeyConditionExpression = "age = :val"
queryExpression.expressionAttributeValues = [":val": 30]
But if I try on an Bool it comes back with nothing.
let queryExpression = AWSDynamoDBQueryExpression()
queryExpression.rangeKeyConditionExpression = "enabled = :val"
queryExpression.expressionAttributeValues = [":val": true]
I've also tried a 0 or a 1 in place of true, or a string as in "true".
However, this filtering on an Bool doesn't even work in the AWS web interface. So it's not a Swift thing it seems. Maybe it's not possible, but seems odd.
Turns out I was confused here, filterExpression works fine.
let scanExpression = AWSDynamoDBScanExpression()
scanExpression.filterExpression = "disabled = :val"
scanExpression.expressionAttributeValues = [":val": false]
The documentation isn't very clear about this, but it is not possible to create a table in DynamoDB with a boolean hash or range key. The hash and range keys can only be of types string (S), numeric (N), or binary (B). If you try to create a table with a boolean (BOOL) range key such as:
create_table(
AttributeDefinitions=[
{'AttributeName': 'something', 'AttributeType': 'S'},
{'AttributeName': 'enabled', 'AttributeType': 'BOOL'}
],
TableName='example',
KeySchema=[
{'AttributeName': 'something', 'KeyType': 'HASH'},
{'AttributeName': 'enabled', 'KeyType': 'RANGE'},
]
...
)
the call will fail on the requirement that the 'enabled' range key be of type 'S', 'N' or 'B'.
If you want to effectively store a boolean in the range key, you should use the numeric type and assign 0 and 1 values, which can be filtered as you've already demonstrated.
If you have a boolean value that is not a hash or range key, you can filter it with a FilterExpression instead of a RangeKeyConditionExpression as described in the FilterExpression documentation.

Error get value null in Excel MVC ASP.NET

I am using the following:
using (ExcelPackage ExcelPackage p = new ())
To open the excel worksheet and getting the values ​​of the cells as follows
string ap = ws.Cells[Lin, 12].Value.ToString().Trim();
But when the cell is empty presenting me this error, as I do so that when the cell is empty it ternha the null value. Estrou needing grab values ​​from several cells having value or not.
You can test for a null value and substitute an empty string using code like this:
string strValue = Worksheets.Cells[2,5].value==null ? string.Empty : Worksheets.Cells[2,5].value.ToString();
example
string ap = (ws.Cells[Lin, 12].Value??"").ToString().Trim();

Assigning default values if NULL

I have an MVC app where a user can select company benfits, there are 10 different benefits and they can have none up to all 10 of these. In my view I have the ten listed with radio buttons to indicate whether they are required or not. There is also a calculation performed in the controller that adds all the values together to give a total.
As an example in my controller -
newuser.LifeAssurance.LifeAssuranceRequired = viewModel.LifeAssuranceRequired;
newuser.LifeAssurance.LifeAssuranceSchemeName = viewModel.LifeAssuranceSchemeName;
newuser.LifeAssurance.LifeAssuranceProviderName = viewModel.LifeAssuranceProviderName;
newuser.LifeAssurance.LifeAssuranceBenefitLevel = viewModel.LifeAssuranceBenefitLevel;
newuser.LifeAssurance.LifeAssuranceEmployerCost = viewModel.LifeAssuranceEmployerCost;
newuser.LifeAssurance.LifeAssuranceEmployeeCost = viewModel.LifeAssuranceEmployeeCost;
Since the user may decide not to choose this benefit is it possible to assign the cost as 0 if they have not made a selection in the view model? Can I check if it's null and add 0 in that case?
You can use the ?? operator (see here)
use it like this:
string someString = null;
string someOtherString = someString ?? "0";
if someString(or any other object) is not null use it, else use whatever is on the right of the ?? operator.
Maybe set your values as nullable by add ? to type, and then you can check it is null by:
var someValue = (nullableValue.HasValue) ? nullableValue.Value : 0;

Resources