{"QuestionId": 23605160, "AnswerCount": 1, "Tags": "<.net>", "CreationDate": "2014-05-12T09:14:29.240", "AcceptedAnswerId": "23605228", "Title": "Calling a property setter when changing a (nested) property inside the property object", "Body": "

insane title . . I know . . but bear with me . .

\n\n

consider the following case:

\n\n
a.ClassProperty.ValueProperty = 4;\n
\n\n

where:

\n\n
class A\n{\n    [...]\n    public PropertyClass ClassProperty\n    {\n        get { return new PropertyClass(m_someInformation); }\n        set { ComplexMultistepSetInformation(m_someInformation); }\n    }\n    [...]\n}\n
\n\n

and:

\n\n
class PropertyClass\n{\n    [...]\n    public int ValueProperty { get; set; }\n    [...]\n}\n
\n\n

My problem: when executing the first given statement the code will return a PropertyClass object and change the 'ValueProperty' in it, but the information itself for 'a' will remain the same.
\nWhat I would like to have is for the setter of 'ClassProperty' being called, after changing the information of the PropertyClass object retrieved via the 'ClassProperty' getter. Meaning, a way to make the first line accomplish the following:

\n\n
PropertyClass tmp = a.ClassProperty;\ntmp.ValueProperty = 4;\na.ClassProperty = tmp;\n
\n\n

Is there any way to change the getters and setters around to accomplish it.

\n\n

(Additional information: having a PropertyClass object in class A would not help. In the real use case PropertyClass is a wrapper around native code, simplifying access to variables and providing several extension methods, while information for a native object gets 'written' by the setter of property 'ClassProperty')

\n", "Lable": "No"} {"QuestionId": 23667069, "AnswerCount": 1, "Tags": "", "CreationDate": "2014-05-14T23:53:38.763", "AcceptedAnswerId": null, "Title": "Different viewmodel in partial view and rest of page?", "Body": "

I'm trying to figure out how i can use fully different data on my page compared to what i use in a partial view.

\n\n

I have a search bar at the top of my website, that top is a partial view that accepts a searchviewmodel and the bottom could be well, anything (search result, a blog, completely unrelated stuff).

\n\n

Obviously i don't want to \"mix\" viewmodels, each of them should be unaware of the other (i'm not going to create a class to host both the partial & main viewmodel for each different page).

\n\n

What is an appropriate way to handle this scenario?

\n\n

Scenario is

\n\n
  User fills search on the top\n => if model is invalid, redisplay current page with errors (current page could for \n    example be today's wether, requiring WeatherViewModel for main content and \n    SearchViewModel for partial view)\n => else display result page (still need SearchViewModel for top banner \n    and then SearchResultsViewModel for the page)\n
\n\n

I'm not finding any help online so far from googling (all i found was scenarios where it made sense to create a class to host both sub classes as they were functionally related, which isn't the case here).

\n\n

My SearchViewModel looks like this:

\n\n
    public class SearchViewModel\n{\n    [Required]\n    public string StartCity { get; set; }\n    [Required]\n    public string EndCity { get; set; }\n    [Required]\n    public DateTime Date { get; set; }\n    [Required]\n    public SearchType Type { get; set; }\n    [Required]\n    public SearchTimeType TimeType { get; set; }\n}\n
\n\n

It corresponds only to the top search and can be present on ANY page regardless of what viewmodel the REST OF THE PAGE uses.

\n", "Lable": "No"} {"QuestionId": 23730779, "AnswerCount": 2, "Tags": "", "CreationDate": "2014-05-19T06:12:47.290", "AcceptedAnswerId": "23731097", "Title": "Count Alphabet Characters from an array?", "Body": "

So, in this program we have to

\n\n
\n
\n

A. Count the number of each letter of the alphabet found in a character array and store these counts in an integer array

\n
\n
\n\n

I understand that part but then it says we have to use the ASCII values which confuses me.

\n\n

This is the file for reference:

\n\n
 \"   A frog walks into a bank and asks the teller, Miss Pattywack\n     for a loan.  Miss Pattywack tells the frog,\n     \"you must have collateral for the loan\".\n     The frog pulls out of his pouch his porcelain people collection\n     and offers them as collateral.\n     Miss Pattywack looks at the figurines and tells the frog that\n     the collection is not acceptable.\n     The bank manager overhears the conversation and yells to the\n     teller - \"It's a nick nack Pattywack, give the frog a loan!\"\n
\n\n
\n
\n

Use a for loop to examine each character in the character array

\n \n
\n

i. Use toupper to case the letter, so you are only dealing with capital letters

\n \n

ii. If the character is a letter of the alphabet, increment the integer array in the position of the ASCII value of the character minus 65

\n \n
\n

1) 65 is the ASCII value of letter, 'A'

\n \n
\n

(1) If the character is A, 65-65 = 0 the position you want to increment for the character A

\n \n
\n

(2) If the character is C, 67-65 = 2 the position you want to increment for the character C

\n
\n
\n
\n
\n
\n
\n\n

I have this so far:

\n\n
void CountAlphabetCharacters(char chArray[MAX_CHARACTERS], int lengthOfArray)\n{\n        int index;\n\n        for(index = 0; index <= lengthOfArray; index++)\n        {\n            chArray[index] = toupper(chArray[index]);\n\n               static_cast<int>(index);\n\n        }   \n}\n
\n\n

That's all I have because that's all I understand. I mean, I understand how you get the ASCII value but I am so lost on how to actually make the for loop for this. Like I'm assuming you look at the characters from the file but I don't understand how you get that value you and keep going. I don't know if I make sense but I'm hoping I do and someone can help!! Thanks in advance.

\n", "Lable": "No"} {"QuestionId": 23735600, "AnswerCount": 2, "Tags": "", "CreationDate": "2014-05-19T10:38:29.057", "AcceptedAnswerId": "23739345", "Title": "Alternating rows with different values in SQL", "Body": "

Below is a table named Profile

\n\n
AutoId     | GroupId | ProfileId   | ProfileName\n-------------------------------------------------   \n239        |    54   | abcd        |  name1\n251        |    44   | efgh        |  name2 \n255        |    54   | ijkl        |  name3\n256        |    54   | mnop        |  name4\n237        |    44   | qrst        |  name5\n
\n\n

And below is a table named Group

\n\n
GroupId    | IsLive \n--------------------\n44         |  1\n54         |  0 \n
\n\n

I want to show on top those records whose IsLive is one and then the below records will be alternating between a record of IsLive 1 and 0. For eg.

\n\n
AutoId     | GroupId | ProfileId   | ProfileName    \n--------------------------------------------------\n237        |    44   | qrst        |  name5\n251        |    44   | efgh        |  name2 \n255        |    54   | ijkl        |  name3\n237        |    44   | qrst        |  name5\n239        |    54   | abcd        |  name1\n251        |    44   | efgh        |  name2 \n256        |    54   | mnop        |  name4\n237        |    44   | qrst        |  name5\n
\n\n

The records of IsLive = 1 should get repeated if it is more than IsLive = 0. So far my query has been

\n\n
select AutoId, GroupId, ProfileId, ProfileName\nfrom Profile\nwhere GroupId in (select GroupId from Group where isnull(IsLive,0) = 1)\nunion all\nselect AutoId, GroupId, ProfileId, ProfileName\nfrom Profile\nwhere GroupId in (select GroupId from Group where isnull(IsLive,0) <> 1)\n
\n\n

The above query gives me IsLive = 1 on top but I am not able to get the alternating rows. Any help would be appreciated

\n", "Lable": "No"} {"QuestionId": 23792004, "AnswerCount": 1, "Tags": "", "CreationDate": "2014-05-21T19:20:51.710", "AcceptedAnswerId": null, "Title": "TreeItem selection width in a TreeView", "Body": "

I'm using JavaFX 8 and I'm currently doing some GUI developments. I have a little problem with my TreeView and I need your help.

\n\n

Do you know if it is possible, in a TreeView, to select just the label and not the whole width of the TreeCell ?

\n\n

I mean (Netbeans example) :

\n\n

\"Good

\n\n

Instead of :

\n\n

\"Bad

\n\n

Thank you in advance.

\n", "Lable": "No"} {"QuestionId": 24085621, "AnswerCount": 1, "Tags": "", "CreationDate": "2014-06-06T15:33:31.723", "AcceptedAnswerId": null, "Title": "Celery / Django Single Tasks being run multiple times", "Body": "

I'm facing an issue where I'm placing a task into the queue and it is being run multiple times.\nFrom the celery logs I can see that the same worker is running the task ...

\n\n
[2014-06-06 15:12:20,731: INFO/MainProcess] Received task: input.tasks.add_queue\n[2014-06-06 15:12:20,750: INFO/Worker-2] starting runner..\n[2014-06-06 15:12:20,759: INFO/Worker-2] collection started\n[2014-06-06 15:13:32,828: INFO/Worker-2] collection complete\n[2014-06-06 15:13:32,836: INFO/Worker-2] generation of steps complete\n[2014-06-06 15:13:32,836: INFO/Worker-2] update created\n[2014-06-06 15:13:33,655: INFO/Worker-2] email sent\n[2014-06-06 15:13:33,656: INFO/Worker-2] update created\n[2014-06-06 15:13:34,420: INFO/Worker-2] email sent\n[2014-06-06 15:13:34,421: INFO/Worker-2] FINISH - Success\n
\n\n

However when I view the actual logs of the application it is showing 5-6 log lines for each step (??).

\n\n

Im using Django 1.6 with RabbitMQ. The method for placing into the queue is via placing a delay on a function.

\n\n

This function (task decorator is added( then calls a class which is run.

\n\n

Has anyone any idea on the best way to troubleshoot this ?

\n\n

Edit : As requested heres the code,

\n\n

views.py

\n\n

In my view im sending my data to the queue via ...

\n\n
from input.tasks import add_queue_project\n\nadd_queue_project.delay(data)\n
\n\n

tasks.py

\n\n
from celery.decorators import task\n\n@task()\ndef add_queue_project(data):\n    \"\"\" run project \"\"\"\n    logger = logging_setup(app=\"project\")\n\n    logger.info(\"starting project runner..\")\n    f = project_runner(data)\n    f.main()\n\nclass project_runner():\n    \"\"\" main project runner \"\"\"\n\n    def __init__(self,data):\n        self.data = data\n        self.logger = logging_setup(app=\"project\")\n\n    def self.main(self):\n        .... Code\n
\n\n

settings.py

\n\n
THIRD_PARTY_APPS = (\n    'south',  # Database migration helpers:\n    'crispy_forms',  # Form layouts\n    'rest_framework',\n    'djcelery',\n)\n\nimport djcelery\ndjcelery.setup_loader()\n\nBROKER_HOST = \"127.0.0.1\"\nBROKER_PORT = 5672 # default RabbitMQ listening port\nBROKER_USER = \"test\"\nBROKER_PASSWORD = \"test\"\nBROKER_VHOST = \"test\"\nCELERY_BACKEND = \"amqp\" # telling Celery to report the results back to RabbitMQ\nCELERY_RESULT_DBURI = \"\"\n\nCELERY_IMPORTS = (\"input.tasks\", )\n
\n\n

celeryd

\n\n

The line im running is to start celery,

\n\n
python2.7 manage.py celeryd -l info\n
\n\n

Thanks,

\n", "Lable": "No"} {"QuestionId": 24098570, "AnswerCount": 1, "Tags": "", "CreationDate": "2014-06-07T15:06:31.533", "AcceptedAnswerId": "24098630", "Title": "UITextview shows text Arabic but numbers English", "Body": "

I want to show some Arabic text and the number of UISlider Value in a uitextview for example:

\n\n

\u0645\u0642\u062f\u0627\u0631= \u06f4\u06f0

\n\n

I am using this code:

\n\n
 self.MyTextView.text= [NSString stringWithFormat:@\"%f\", self.mySlider.value];\n
\n\n

UITextView shows the Arabic text correct but the value is adding with English characters. How can I concatenate the slider value so that uitextview show them with Arabic characters too.

\n", "Lable": "No"} {"QuestionId": 24165811, "AnswerCount": 4, "Tags": "", "CreationDate": "2014-06-11T14:39:54.403", "AcceptedAnswerId": "24166097", "Title": "SQL - Must there always be a primary key?", "Body": "

There are a couple of similar questions already out there and the consensus seemed to be that a primary key should always be created.

\n\n

But what if you have a single row table for storing settings (and let's not turn this into a discussion about why it might be good/bad to create a single row table please)?

\n\n

Surely having a primary key on a single row table becomes completely useless?

\n", "Lable": "No"} {"QuestionId": 24254874, "AnswerCount": 2, "Tags": "", "CreationDate": "2014-06-17T02:29:25.630", "AcceptedAnswerId": "24262588", "Title": "Getting basic input for ints", "Body": "

I'm quite surprised I can't seem to navigate rust's documentation to find any case that describes io, could someone please explain to me how to use basic io to get user input into say, an integer? And maybe where to find the io details in that accursed documentation? Thanks

\n", "Lable": "No"}