Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to convert the text to bsondocument and inverse with C#?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
沉渔涧  
View profile  
 More options May 21 2012, 10:58 am
From: 沉渔涧 <iamnortheast...@gmail.com>
Date: Mon, 21 May 2012 22:58:11 +0800
Local: Mon, May 21 2012 10:58 am
Subject: How to convert the text to bsondocument and inverse with C#?

I'm trying to offer some functions that allow the user to modify the
existing bsondocument through the GUI, currently I'm in this phase:

I show the whole hierarchy of the bsondocument in a treeview.

and my questions is :

1. if I  allow user to only to modify the node and its value that he
selects, how should I find the correponding bson element in the
bsondocument?

2, if I offer some text edting GUI that allow user to modify any part of
the bsondocument, and my software should deal with both how bsondocument
converted into a well indented text format, and how read the modified text
back so that I can serialize it inversely as a updated bsondocument.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options May 21 2012, 3:43 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Mon, 21 May 2012 12:43:37 -0700 (PDT)
Local: Mon, May 21 2012 3:43 pm
Subject: Re: How to convert the text to bsondocument and inverse with C#?

1) So, this is fairly unrelated to the driver itself and really more
dependent upon the GUI piece and what technology you are using.  If you are
using the built-in Windows Forms TreeView control, then there is a Tag
property on each node.  You can assign the BsonElement to this Tag property
so that when the user edits it, you know exactly what to apply the changes
to.  A deletion would mean you'd need to move to the node's parent and
remove the element referenced by the subnode's Tag.  e.g.
node.Parent.Tag.Remove(node.Tag).  

There are a gillion ways of doing this, and none really relate to the
driver itself.

2) You are going to need a JSON parser to get the object into a form you
can use. We have a JsonReader that can read a string of json and convert it
into a document.  This may take some work and some looking into as I'm
unfamiliar with how to accomplish this yet.  I'll try and follow up later
with an example.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options May 22 2012, 9:55 am
From: craiggwilson <craiggwil...@gmail.com>
Date: Tue, 22 May 2012 06:55:37 -0700 (PDT)
Local: Tues, May 22 2012 9:55 am
Subject: Re: How to convert the text to bsondocument and inverse with C#?

As for #2: this is accomplished with this code:

  BsonSerializer.Deserialize<BsonDocument>(json);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
trypsin  
View profile  
 More options May 23 2012, 7:47 am
From: trypsin <iamnortheast...@gmail.com>
Date: Wed, 23 May 2012 04:47:38 -0700 (PDT)
Local: Wed, May 23 2012 7:47 am
Subject: Re: How to convert the text to bsondocument and inverse with C#?
@ craiggwilson
So, the process goes as following : general text -> json ->
bsondocument ?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
craiggwilson  
View profile  
 More options May 23 2012, 6:24 pm
From: craiggwilson <craiggwil...@gmail.com>
Date: Wed, 23 May 2012 15:24:36 -0700 (PDT)
Local: Wed, May 23 2012 6:24 pm
Subject: Re: How to convert the text to bsondocument and inverse with C#?

Yes.  But if "general text" is json, then you don't need to parse it first.

var json = textbox.Text;
var document = BsonSerializer.Deserialize<BsonDocument>(json);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »