~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/core/CollectionStore/.svn/text-base/Property.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 |
3
 
 | Copyright (c) 2007 Novell, Inc.
4
 
 | All Rights Reserved.
5
 
 |
6
 
 | This program is free software; you can redistribute it and/or
7
 
 | modify it under the terms of version 2 of the GNU General Public License as
8
 
 | published by the Free Software Foundation.
9
 
 |
10
 
 | This program is distributed in the hope that it will be useful,
11
 
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 | GNU General Public License for more details.
14
 
 |
15
 
 | You should have received a copy of the GNU General Public License
16
 
 | along with this program; if not, contact Novell, Inc.
17
 
 |
18
 
 | To contact Novell about this file by physical or electronic mail,
19
 
 | you may find current contact information at www.novell.com 
20
 
 |
21
 
 |  Author: Mike Lasky <mlasky@novell.com>
22
 
 |***************************************************************************/
23
 
 
24
 
 
25
 
using System;
26
 
using System.Collections;
27
 
using System.Xml;
28
 
 
29
 
namespace Simias.Storage
30
 
{
31
 
        /// <summary>
32
 
        /// Defines a relationship between Node objects.
33
 
        /// </summary>
34
 
        public class Relationship
35
 
        {
36
 
                #region Class Members
37
 
                /// <summary>
38
 
                /// Well known identifier that represents the root directory relationship in a dirNode.
39
 
                /// </summary>
40
 
                private const string RootID = "a9d9a742-fd42-492c-a7f2-4ec4f023c625";
41
 
 
42
 
                /// <summary>
43
 
                /// Collection that reference belongs to.
44
 
                /// </summary>
45
 
                private string collectionID;
46
 
 
47
 
                /// <summary>
48
 
                /// Node object that is the reference.
49
 
                /// </summary>
50
 
                private string nodeID;
51
 
                #endregion
52
 
 
53
 
                #region Properties
54
 
                /// <summary>
55
 
                /// Gets the Collection identifier for the relationship.
56
 
                /// </summary>
57
 
                public string CollectionID
58
 
                {
59
 
                        get { return collectionID; }
60
 
                }
61
 
 
62
 
                /// <summary>
63
 
                /// Gets whether this object is the root relationship.
64
 
                /// </summary>
65
 
                public bool IsRoot
66
 
                {
67
 
                        get { return ( nodeID == RootID ) ? true : false; }
68
 
                }
69
 
 
70
 
                /// <summary>
71
 
                /// Gets the Node identifier for the relationship.
72
 
                /// </summary>
73
 
                public string NodeID
74
 
                {
75
 
                        get { return nodeID; }
76
 
                }
77
 
                #endregion
78
 
 
79
 
                #region Constructor
80
 
                /// <summary>
81
 
                /// Constructor for the Relationship object that creates a root relationship object.
82
 
                /// </summary>
83
 
                /// <param name="collection">Collection for the relationship.</param>
84
 
                public Relationship( Collection collection ) :
85
 
                        this ( collection.ID, null )
86
 
                {
87
 
                }
88
 
 
89
 
                /// <summary>
90
 
                /// Constructor for the Relationship object.
91
 
                /// </summary>
92
 
                /// <param name="collectionID">Collection identifier for the relationship.</param>
93
 
                /// <param name="nodeID">Node identifier for the relationship. If this parameter is null,
94
 
                /// this object is the root of the relationship.</param>
95
 
                public Relationship( string collectionID, string nodeID )
96
 
                {
97
 
                        this.collectionID = collectionID.ToLower();
98
 
                        this.nodeID = ( nodeID != null ) ? nodeID.ToLower() : RootID;
99
 
                }
100
 
 
101
 
                /// <summary>
102
 
                /// Constructs the Relationship object from its internal representation.
103
 
                /// </summary>
104
 
                /// <param name="relationString">Internal representation of relationship.</param>
105
 
                internal Relationship( string relationString )
106
 
                {
107
 
                        int index = relationString.IndexOf( ':' );
108
 
                        if ( index == -1 )
109
 
                        {
110
 
                                throw new CollectionStoreException( String.Format( "Invalid relationship format: {0}.", relationString ) );
111
 
                        }
112
 
 
113
 
                        nodeID = relationString.Substring( 0, index );
114
 
                        collectionID = relationString.Substring( index + 1 );
115
 
                }
116
 
                #endregion
117
 
 
118
 
                #region Internal Methods
119
 
                /// <summary>
120
 
                /// Returns internal representation of relationship.
121
 
                /// </summary>
122
 
                /// <returns>A string containing the internal representation of the relationship.</returns>
123
 
                internal new string ToString()
124
 
                {
125
 
                        return nodeID + ":" + collectionID;
126
 
                }
127
 
                #endregion
128
 
        }
129
 
 
130
 
        /// <summary>
131
 
        /// Represents a property name/value pair for a node.  Properties have
132
 
        /// well-defined syntax types.
133
 
        /// </summary>
134
 
        public class Property
135
 
        {
136
 
                #region Class Members
137
 
                /// <summary>
138
 
                /// Property operations that are recorded so properties can be merged at object commit time.
139
 
                /// </summary>
140
 
                internal enum Operation
141
 
                {
142
 
                        /// <summary>
143
 
                        /// No operation or change.
144
 
                        /// </summary>
145
 
                        None,
146
 
 
147
 
                        /// <summary>
148
 
                        /// New property value added.
149
 
                        /// </summary>
150
 
                        Add,
151
 
 
152
 
                        /// <summary>
153
 
                        /// Property value was deleted.
154
 
                        /// </summary>
155
 
                        Delete,
156
 
 
157
 
                        /// <summary>
158
 
                        /// Property value was modified.
159
 
                        /// </summary>
160
 
                        Modify,
161
 
 
162
 
                        /// <summary>
163
 
                        /// The name of the Node object was changed.
164
 
                        /// </summary>
165
 
                        NameChange
166
 
                };
167
 
 
168
 
                /// <summary>
169
 
                /// Types of flags that are defined on the property.
170
 
                /// </summary>
171
 
                internal const uint Hidden      = 0x00010000;
172
 
                internal const uint Local       = 0x00020000;
173
 
                internal const uint MultiValued = 0x00040000;
174
 
 
175
 
                /// <summary>
176
 
                ///  Mask used to get just the system flags.
177
 
                /// </summary>
178
 
                private const uint SystemFlagMask = 0xFFFF0000;
179
 
 
180
 
                /// <summary>
181
 
                /// This XmlElement contains all the information about the property.
182
 
                /// </summary>
183
 
                private XmlElement xmlProperty;
184
 
 
185
 
                /// <summary>
186
 
                /// The property list where this property is stored.
187
 
                /// </summary>
188
 
                private PropertyList propertyList = null;
189
 
 
190
 
                /// <summary>
191
 
                /// Member used to keep track of property additions, deletions and modifications.
192
 
                /// </summary>
193
 
                private Operation operation = Operation.None;
194
 
 
195
 
                /// <summary>
196
 
                /// Member used to store the old value of the property, if it was modified.
197
 
                /// </summary>
198
 
                private string oldValue = null;
199
 
 
200
 
                /// <summary>
201
 
                /// Member used to indicate if the oldFlags value contains a changed value.
202
 
                /// </summary>
203
 
                private bool flagsModified = false;
204
 
 
205
 
                /// <summary>
206
 
                /// Member used to store the old flag value, if it was modified.
207
 
                /// </summary>
208
 
                private uint oldFlags = 0;
209
 
                #endregion
210
 
 
211
 
                #region Properties
212
 
                /// <summary>
213
 
                /// Gets or sets a string representation of the property value.
214
 
                /// </summary>
215
 
                internal string ValueString
216
 
                {
217
 
                        get { return ( Type == Syntax.XmlDocument ) ? xmlProperty.InnerXml : xmlProperty.InnerText; }
218
 
                        set
219
 
                        {
220
 
                                if ( Type == Syntax.XmlDocument )
221
 
                                {
222
 
                                        xmlProperty.InnerXml = value;
223
 
                                }
224
 
                                else
225
 
                                {
226
 
                                        xmlProperty.InnerText = value;
227
 
                                }
228
 
                        }
229
 
                }
230
 
 
231
 
                /// <summary>
232
 
                /// Gets a search string representation of the property value.
233
 
                /// </summary>
234
 
                internal string SearchString
235
 
                {
236
 
                        get { return xmlProperty.InnerXml; }
237
 
                }
238
 
 
239
 
                /// <summary>
240
 
                /// Gets the owning document for this xml node.
241
 
                /// </summary>
242
 
                internal XmlDocument OwnerDocument
243
 
                {
244
 
                        get { return xmlProperty.OwnerDocument; }
245
 
                }
246
 
 
247
 
                /// <summary>
248
 
                /// Allows the corresponding XML element to be set into the object when this property
249
 
                /// has been added to the property list.
250
 
                /// </summary>
251
 
                internal XmlElement XmlProperty
252
 
                {
253
 
                        get { return xmlProperty; }
254
 
                        set { xmlProperty = value; }
255
 
                }
256
 
 
257
 
                /// <summary>
258
 
                /// Allows the property list to be set into the object when this property has been
259
 
                /// added to the property list.
260
 
                /// </summary>
261
 
                internal PropertyList XmlPropertyList
262
 
                {
263
 
                        get { return propertyList; }
264
 
                        set { propertyList = value; }
265
 
                }
266
 
 
267
 
                /// <summary>
268
 
                /// Gets and sets the hidden status of a property.
269
 
                /// </summary>
270
 
                internal bool HiddenProperty
271
 
                {
272
 
                        get { return ( PropertyFlags & Hidden ) == Hidden ? true : false; }
273
 
 
274
 
                        set
275
 
                        {
276
 
                                if ( value )
277
 
                                {
278
 
                                        PropertyFlags |= Hidden;
279
 
                                }
280
 
                                else
281
 
                                {
282
 
                                        PropertyFlags &= ~Hidden;
283
 
                                }
284
 
                        }
285
 
                }
286
 
 
287
 
                /// <summary>
288
 
                /// Gets and sets all of the flags for the property object.
289
 
                /// </summary>
290
 
                internal uint PropertyFlags
291
 
                {
292
 
                        get
293
 
                        {
294
 
                                // Check to see if this property contains any flags.
295
 
                                uint propertyFlags = 0;
296
 
                                if ( xmlProperty.HasAttribute( XmlTags.FlagsAttr ) )
297
 
                                {
298
 
                                        propertyFlags = Convert.ToUInt32( xmlProperty.GetAttribute( XmlTags.FlagsAttr ) );
299
 
                                }
300
 
 
301
 
                                return propertyFlags;
302
 
                        }
303
 
 
304
 
                        set
305
 
                        {
306
 
                                // Save the current flags value.
307
 
                                uint currentFlags = PropertyFlags;
308
 
                                xmlProperty.SetAttribute( XmlTags.FlagsAttr, value.ToString() );
309
 
                                SaveMergeInformation( propertyList, Operation.Modify, null, true, currentFlags );
310
 
                        }
311
 
                }
312
 
 
313
 
                /// <summary>
314
 
                /// Gets the name of this property.
315
 
                /// </summary>
316
 
                public string Name
317
 
                {
318
 
                        get { return xmlProperty.GetAttribute( XmlTags.NameAttr ); }
319
 
                }
320
 
 
321
 
                /// <summary>
322
 
                /// Gets and sets the syntax type of this property.
323
 
                /// </summary>
324
 
                public Syntax Type
325
 
                {
326
 
                        get { return ( Syntax )Enum.Parse( typeof( Syntax ), xmlProperty.GetAttribute( XmlTags.TypeAttr ) ); }
327
 
                }
328
 
 
329
 
                /// <summary>
330
 
                /// Gets and sets the flags for this property.
331
 
                /// </summary>
332
 
                public ushort Flags
333
 
                {
334
 
                        get { return ( ushort )PropertyFlags; }
335
 
                        set { PropertyFlags = ( PropertyFlags & SystemFlagMask ) | ( uint )value; }
336
 
                }
337
 
 
338
 
                /// <summary>
339
 
                /// Gets and sets the value of this property as an object.
340
 
                /// </summary>
341
 
                public object Value
342
 
                {
343
 
                        get { return GetValue(); }
344
 
                        set { SetValue( value ); }
345
 
                }
346
 
 
347
 
                /// <summary>
348
 
                /// Gets whether this property is associated with a node or if it is a new property object.
349
 
                /// </summary>
350
 
                public bool IsAssociatedProperty
351
 
                {
352
 
                        get { return ( propertyList == null ) ? false : true; }
353
 
                }
354
 
 
355
 
                /// <summary>
356
 
                /// Gets and sets the transient status of a property.  If this flag is false, this property will
357
 
                /// synchronize to other stores.  If it is true, it is a property local to this store only.  This
358
 
                /// flag is set to false by default.
359
 
                /// </summary>
360
 
                public bool LocalProperty
361
 
                {
362
 
                        get { return ( PropertyFlags & Local ) == Local ? true : false; }
363
 
 
364
 
                        set
365
 
                        {
366
 
                                if ( value )
367
 
                                {
368
 
                                        PropertyFlags |= Local;
369
 
                                }
370
 
                                else
371
 
                                {
372
 
                                        PropertyFlags &= ~Local;
373
 
                                }
374
 
                        }
375
 
                }
376
 
 
377
 
                /// <summary>
378
 
                /// Gets and sets the multivalued status of a property.
379
 
                /// </summary>
380
 
                public bool MultiValuedProperty
381
 
                {
382
 
                        get { return ( PropertyFlags & MultiValued ) == MultiValued ? true : false; }
383
 
 
384
 
                        set
385
 
                        {
386
 
                                if ( value )
387
 
                                {
388
 
                                        PropertyFlags |= MultiValued;
389
 
                                }
390
 
                                else
391
 
                                {
392
 
                                        PropertyFlags &= ~MultiValued;
393
 
                                }
394
 
                        }
395
 
                }
396
 
                #endregion
397
 
 
398
 
                #region Constructors
399
 
                /// <summary>
400
 
                /// Constructor used by the PropertyList.IEnumerable interface to create property objects.
401
 
                /// </summary>
402
 
                /// <param name="propertyList">The property list where this property is stored.</param>
403
 
                /// <param name="xmlProperty">An XML element object that contains the name and value for this property.</param>
404
 
                internal Property( PropertyList propertyList, XmlElement xmlProperty )
405
 
                {
406
 
                        this.propertyList = propertyList;
407
 
                        this.xmlProperty = xmlProperty;
408
 
                }
409
 
 
410
 
                /// <summary>
411
 
                /// Constructs a property object.
412
 
                /// </summary>
413
 
                /// <param name="name">Name of the property to construct.</param>
414
 
                /// <param name="syntax">Syntax type of the value.</param>
415
 
                /// <param name="propertyValue">Value of the property.</param>
416
 
                public Property( string name, Syntax syntax, string propertyValue )
417
 
                {
418
 
                        XmlDocument propDoc = new XmlDocument();
419
 
                        xmlProperty = propDoc.CreateElement( XmlTags.PropertyTag );
420
 
 
421
 
                        xmlProperty.SetAttribute( XmlTags.NameAttr, name );
422
 
                        xmlProperty.SetAttribute( XmlTags.TypeAttr, syntax.ToString() );
423
 
                        ValueString = propertyValue;
424
 
                }
425
 
 
426
 
                /// <summary>
427
 
                /// Constructs a property.
428
 
                /// </summary>
429
 
                /// <param name="property">PropertyTags.</param>
430
 
                public Property( Property property )
431
 
                {
432
 
                        XmlDocument propDoc = new XmlDocument();
433
 
                        xmlProperty = ( XmlElement )propDoc.ImportNode( property.xmlProperty, true );
434
 
                        propDoc.AppendChild( xmlProperty );
435
 
                }
436
 
 
437
 
                /// <summary>
438
 
                /// Constructs a property.
439
 
                /// </summary>
440
 
                /// <param name="name">Name of the property.</param>
441
 
                /// <param name="propertyValue">Object representation of the value.</param>
442
 
                public Property( string name, object propertyValue )
443
 
                {
444
 
                        Syntax syntax = GetSyntaxType( propertyValue );
445
 
 
446
 
                        XmlDocument propDoc = new XmlDocument();
447
 
                        xmlProperty = propDoc.CreateElement( XmlTags.PropertyTag );
448
 
                        xmlProperty.SetAttribute( XmlTags.NameAttr, name );
449
 
                        xmlProperty.SetAttribute( XmlTags.TypeAttr, syntax.ToString() );
450
 
 
451
 
                        ValueString = GetValueFromPropertyObject( syntax, propertyValue );
452
 
                }
453
 
 
454
 
                /// <summary>
455
 
                /// Constructs a property
456
 
                /// </summary>
457
 
                /// <param name="name">Name of the property.</param>
458
 
                /// <param name="propertyValue">String value of the property.</param>
459
 
                public Property( string name, string propertyValue ) :
460
 
                        this( name, Syntax.String, propertyValue )
461
 
                {
462
 
                }
463
 
 
464
 
                /// <summary>
465
 
                /// Constructs a property.
466
 
                /// </summary>
467
 
                /// <param name="name">Name of the property.</param>
468
 
                /// <param name="propertyValue">Signed 8-bit value of the property.</param>
469
 
                public Property( string name, sbyte propertyValue ) :
470
 
                        this ( name, Syntax.SByte, propertyValue.ToString() )
471
 
                {
472
 
                }
473
 
 
474
 
                /// <summary>
475
 
                /// Constructs a property.
476
 
                /// </summary>
477
 
                /// <param name="name">Name of the property.</param>
478
 
                /// <param name="propertyValue">Unsigned 8-bit value of the property.</param>
479
 
                public Property( string name, byte propertyValue ) :
480
 
                        this( name, Syntax.Byte, propertyValue.ToString() )
481
 
                {
482
 
                }
483
 
 
484
 
                /// <summary>
485
 
                /// Constructs a property.
486
 
                /// </summary>
487
 
                /// <param name="name">Name of the property.</param>
488
 
                /// <param name="propertyValue">Signed 16-bit value of the property.</param>
489
 
                public Property( string name, short propertyValue ) :
490
 
                        this( name, Syntax.Int16, propertyValue.ToString() )
491
 
                {
492
 
                }
493
 
 
494
 
                /// <summary>
495
 
                /// Constructs a property.
496
 
                /// </summary>
497
 
                /// <param name="name">Name of the property.</param>
498
 
                /// <param name="propertyValue">Unsigned 16-bit value of the property.</param>
499
 
                public Property( string name, ushort propertyValue ) :
500
 
                        this( name, Syntax.UInt16, propertyValue.ToString() )
501
 
                {
502
 
                }
503
 
 
504
 
                /// <summary>
505
 
                /// Constructs a property.
506
 
                /// </summary>
507
 
                /// <param name="name">Name of the property.</param>
508
 
                /// <param name="propertyValue">Signed 32-bit value of the property.</param>
509
 
                public Property( string name, int propertyValue ) :
510
 
                        this( name, Syntax.Int32, propertyValue.ToString() )
511
 
                {
512
 
                }
513
 
 
514
 
                /// <summary>
515
 
                /// Constructs a property.
516
 
                /// </summary>
517
 
                /// <param name="name">Name of the property.</param>
518
 
                /// <param name="propertyValue">Unsigned 32-bit value of the property.</param>
519
 
                public Property( string name, uint propertyValue ) :
520
 
                        this( name, Syntax.UInt32, propertyValue.ToString() )
521
 
                {
522
 
                }
523
 
 
524
 
                /// <summary>
525
 
                /// Constructs a property.
526
 
                /// </summary>
527
 
                /// <param name="name">Name of the property.</param>
528
 
                /// <param name="propertyValue">Signed 64-bit value of the property.</param>
529
 
                public Property( string name, long propertyValue ) :
530
 
                        this( name, Syntax.Int64, propertyValue.ToString() )
531
 
                {
532
 
                }
533
 
 
534
 
                /// <summary>
535
 
                /// Constructs a property.
536
 
                /// </summary>
537
 
                /// <param name="name">Name of the property.</param>
538
 
                /// <param name="propertyValue">Unsigned 64-bit value of the property.</param>
539
 
                public Property( string name, ulong propertyValue ) :
540
 
                        this( name, Syntax.UInt64, propertyValue.ToString() )
541
 
                {
542
 
                }
543
 
 
544
 
                /// <summary>
545
 
                /// Constructs a property.
546
 
                /// </summary>
547
 
                /// <param name="name">Name of the property.</param>
548
 
                /// <param name="propertyValue">Unicode character value of the property.</param>
549
 
                public Property( string name, char propertyValue ) :
550
 
                        this( name, Syntax.Char, ( ( ushort )propertyValue ).ToString() )
551
 
                {
552
 
                }
553
 
 
554
 
                /// <summary>
555
 
                /// Constructs a property.
556
 
                /// </summary>
557
 
                /// <param name="name">Name of the property.</param>
558
 
                /// <param name="propertyValue">Single precision 32-bit value of the property.</param>
559
 
                public Property( string name, float propertyValue ) :
560
 
                        this( name, Syntax.Single, propertyValue.ToString() )
561
 
                {
562
 
                }
563
 
 
564
 
                /// <summary>
565
 
                /// Constructs a property.
566
 
                /// </summary>
567
 
                /// <param name="name">Name of the property.</param>
568
 
                /// <param name="propertyValue">Boolean value of the property.</param>
569
 
                public Property( string name, bool propertyValue ) :
570
 
                        this( name, Syntax.Boolean, propertyValue ? "1" : "0" )
571
 
                {
572
 
                }
573
 
 
574
 
                /// <summary>
575
 
                /// Constructs a property.
576
 
                /// </summary>
577
 
                /// <param name="name">Name of the property.</param>
578
 
                /// <param name="propertyValue">DateTime object of the property.</param>
579
 
                public Property( string name, DateTime propertyValue ) :
580
 
                        this( name, Syntax.DateTime, propertyValue.Ticks.ToString() )
581
 
                {
582
 
                }
583
 
 
584
 
                /// <summary>
585
 
                /// Constructs a property.
586
 
                /// </summary>
587
 
                /// <param name="name">Name of the property.</param>
588
 
                /// <param name="propertyValue">Uri object of the property.</param>
589
 
                public Property( string name, Uri propertyValue ) :
590
 
                        this( name, Syntax.Uri, propertyValue.ToString() )
591
 
                {
592
 
                }
593
 
 
594
 
                /// <summary>
595
 
                /// Constructs a property.
596
 
                /// </summary>
597
 
                /// <param name="name">Name of the property.</param>
598
 
                /// <param name="propertyValue">XmlDocument object of the property.</param>
599
 
                public Property( string name, XmlDocument propertyValue ) :
600
 
                        this( name, Syntax.XmlDocument, propertyValue.InnerXml )
601
 
                {
602
 
                }
603
 
 
604
 
                /// <summary>
605
 
                /// Constructs a property.
606
 
                /// </summary>
607
 
                /// <param name="name">Name of the property.</param>
608
 
                /// <param name="propertyValue">TimeSpan object of the property.</param>
609
 
                public Property( string name, TimeSpan propertyValue ) :
610
 
                        this( name, Syntax.TimeSpan, propertyValue.Ticks.ToString() )
611
 
                {
612
 
                }
613
 
 
614
 
                /// <summary>
615
 
                /// Constructs a property.
616
 
                /// </summary>
617
 
                /// <param name="name">Name of the property.</param>
618
 
                /// <param name="relationship">Relationship object.</param>
619
 
                public Property( string name, Relationship relationship ) :
620
 
                        this( name, Syntax.Relationship, relationship.ToString() )
621
 
                {
622
 
                }
623
 
                #endregion
624
 
 
625
 
                #region Private Methods
626
 
                /// <summary>
627
 
                /// Returns an object containing the value of this property.
628
 
                /// </summary>
629
 
                /// <returns>An object that contains the value of the property.</returns>
630
 
                private object GetValue()
631
 
                {
632
 
                        object propertyValue;
633
 
 
634
 
                        // Based on the syntax type, create an object and stuff in the property value.
635
 
                        switch ( Type )
636
 
                        {
637
 
                                case Syntax.String:
638
 
                                        propertyValue = xmlProperty.InnerText;
639
 
                                        break;
640
 
 
641
 
                                case Syntax.SByte:
642
 
                                        propertyValue = SByte.Parse( xmlProperty.InnerText );
643
 
                                        break;
644
 
 
645
 
                                case Syntax.Byte:
646
 
                                        propertyValue = Byte.Parse( xmlProperty.InnerText );
647
 
                                        break;
648
 
 
649
 
                                case Syntax.Int16:
650
 
                                        propertyValue =  Int16.Parse( xmlProperty.InnerText );
651
 
                                        break;
652
 
 
653
 
                                case Syntax.UInt16:
654
 
                                        propertyValue =  UInt16.Parse( xmlProperty.InnerText );
655
 
                                        break;
656
 
 
657
 
                                case Syntax.Int32:
658
 
                                        propertyValue =  Int32.Parse( xmlProperty.InnerText );
659
 
                                        break;
660
 
 
661
 
                                case Syntax.UInt32:
662
 
                                        propertyValue =  UInt32.Parse( xmlProperty.InnerText );
663
 
                                        break;
664
 
 
665
 
                                case Syntax.Int64:
666
 
                                        propertyValue =  Int64.Parse( xmlProperty.InnerText );
667
 
                                        break;
668
 
 
669
 
                                case Syntax.UInt64:
670
 
                                        propertyValue =  UInt64.Parse( xmlProperty.InnerText );
671
 
                                        break;
672
 
 
673
 
                                case Syntax.Char:
674
 
                                        propertyValue =  ( Char )UInt16.Parse( xmlProperty.InnerText );
675
 
                                        break;
676
 
                                        
677
 
                                case Syntax.Single:
678
 
                                        propertyValue =  Single.Parse( xmlProperty.InnerText );
679
 
                                        break;
680
 
 
681
 
                                case Syntax.Boolean:
682
 
                                        propertyValue =  Boolean.Parse( ( xmlProperty.InnerText == "0" ) ? Boolean.FalseString : Boolean.TrueString );
683
 
                                        break;
684
 
 
685
 
                                case Syntax.DateTime:
686
 
                                        long timeValue = Int64.Parse( xmlProperty.InnerText );
687
 
                                        propertyValue = new DateTime( timeValue );
688
 
                                        break;
689
 
 
690
 
                                case Syntax.Uri:
691
 
                                        propertyValue = new Uri( xmlProperty.InnerText );
692
 
                                        break;
693
 
 
694
 
                                case Syntax.XmlDocument:
695
 
                                        propertyValue =  new XmlDocument();
696
 
                                        ( ( XmlDocument )propertyValue ).LoadXml( xmlProperty.InnerXml );
697
 
                                        break;
698
 
 
699
 
                                case Syntax.TimeSpan:
700
 
                                        long tickValue = Int64.Parse( xmlProperty.InnerText );
701
 
                                        propertyValue = new TimeSpan( tickValue );
702
 
                                        break;
703
 
 
704
 
                                case Syntax.Relationship:
705
 
                                        propertyValue = new Relationship( xmlProperty.InnerText );
706
 
                                        break;
707
 
 
708
 
                                default:
709
 
                                        throw new SyntaxException( Type );
710
 
                        }
711
 
 
712
 
                        return propertyValue;
713
 
                }
714
 
 
715
 
                /// <summary>
716
 
                /// Returns a string value representing the property value.
717
 
                /// </summary>
718
 
                /// <param name="syntax">Syntax type of propertyValue parameter.</param>
719
 
                /// <param name="propertyValue">Object that containst the propertyValue and syntax type.</param>
720
 
                /// <returns>A string object representing the property value.</returns>
721
 
                private string GetValueFromPropertyObject( Syntax syntax, object propertyValue )
722
 
                {
723
 
                        string valueString;
724
 
 
725
 
                        // Convert the propertyValue object type to a supported property syntax type.
726
 
                        switch ( syntax )
727
 
                        {
728
 
                                case Syntax.String:
729
 
                                        valueString = ( String )propertyValue;
730
 
                                        break;
731
 
 
732
 
                                case Syntax.SByte:
733
 
                                        valueString = ( ( SByte )propertyValue ).ToString();
734
 
                                        break;
735
 
 
736
 
                                case Syntax.Byte:
737
 
                                        valueString = ( ( Byte )propertyValue ).ToString();
738
 
                                        break;
739
 
 
740
 
                                case Syntax.Int16:
741
 
                                        valueString = ( ( Int16 )propertyValue ).ToString();
742
 
                                        break;
743
 
 
744
 
                                case Syntax.UInt16:
745
 
                                        valueString = ( ( UInt16 )propertyValue ).ToString();
746
 
                                        break;
747
 
 
748
 
                                case Syntax.Int32:
749
 
                                        valueString = ( ( Int32 )propertyValue ).ToString();
750
 
                                        break;
751
 
 
752
 
                                case Syntax.UInt32:
753
 
                                        valueString = ( ( UInt32 )propertyValue ).ToString();
754
 
                                        break;
755
 
 
756
 
                                case Syntax.Int64:
757
 
                                        valueString = ( ( Int64 )propertyValue ).ToString();
758
 
                                        break;
759
 
 
760
 
                                case Syntax.UInt64:
761
 
                                        valueString = ( ( UInt64 )propertyValue ).ToString();
762
 
                                        break;
763
 
 
764
 
                                case Syntax.Char:
765
 
                                        valueString = ( ( UInt16 )( ( char )propertyValue )).ToString();
766
 
                                        break;
767
 
                                
768
 
                                case Syntax.Single:
769
 
                                        valueString = ( ( Single )propertyValue ).ToString();
770
 
                                        break;
771
 
 
772
 
                                case Syntax.Boolean:
773
 
                                        valueString = ( ( Boolean )propertyValue == true ) ? "1" : "0";
774
 
                                        break;
775
 
 
776
 
                                case Syntax.DateTime:
777
 
                                        valueString = ( ( DateTime ) propertyValue ).Ticks.ToString();
778
 
                                        break;
779
 
 
780
 
                                case Syntax.Uri:
781
 
                                        valueString = ( ( Uri )propertyValue ).ToString();
782
 
                                        break;
783
 
 
784
 
                                case Syntax.XmlDocument:
785
 
                                        valueString = ( ( XmlDocument )propertyValue ).InnerXml;
786
 
                                        break;
787
 
 
788
 
                                case Syntax.TimeSpan:
789
 
                                        valueString = ( ( TimeSpan ) propertyValue ).Ticks.ToString();
790
 
                                        break;
791
 
 
792
 
                                case Syntax.Relationship:
793
 
                                        valueString = ( ( Relationship ) propertyValue ).ToString();
794
 
                                        break;
795
 
 
796
 
                                default:
797
 
                                        // There is no top level type that matches this object.  Check for an enumerated type.
798
 
                                        if ( propertyValue.GetType().BaseType.Name == "System.Enum" )
799
 
                                        {
800
 
                                                valueString = ( ( Int32 )propertyValue ).ToString();
801
 
                                        }
802
 
                                        else
803
 
                                        {
804
 
                                                throw new SyntaxException( syntax );
805
 
                                        }
806
 
                                        break;
807
 
                        }
808
 
 
809
 
                        return valueString;
810
 
                }
811
 
 
812
 
                /// <summary>
813
 
                /// Returns if specified state is valid state to save property merge information.
814
 
                /// </summary>
815
 
                /// <param name="state">Current property state.</param>
816
 
                /// <returns>True if valid state, otherwise false.</returns>
817
 
                private bool ValidSaveMergeInfoState( PropertyList.PropertyListState state )
818
 
                {
819
 
                        return ( ( state != PropertyList.PropertyListState.Add ) &&
820
 
                                         ( state != PropertyList.PropertyListState.Abort ) &&
821
 
                                         ( state != PropertyList.PropertyListState.Import)  &&
822
 
                                         ( state != PropertyList.PropertyListState.Disposed ) &&
823
 
                                         ( state != PropertyList.PropertyListState.Proxy ) &&
824
 
                                         ( state != PropertyList.PropertyListState.Restore ) ) ? true : false;
825
 
                }
826
 
                #endregion
827
 
 
828
 
                #region Internal Methods
829
 
                /// <summary>
830
 
                /// Restores the old state of the Node object.
831
 
                /// </summary>
832
 
                /// <param name="node">Node object to restore previous state for.</param>
833
 
                internal void AbortMergeInformation( Node node )
834
 
                {
835
 
                        // If there is no PropertyList object associated with this property or it is a new object,
836
 
                        // we don't need to track it.
837
 
                        if ( IsAssociatedProperty && ( node.Properties.State == PropertyList.PropertyListState.Abort ) )
838
 
                        {
839
 
                                // Operation is the current state of the property.
840
 
                                switch ( operation )
841
 
                                {
842
 
                                        case Operation.Add:
843
 
                                                // Remove the property from the PropertyList object.
844
 
                                                DeleteProperty();
845
 
 
846
 
                                                // Restore its in-memory state.
847
 
                                                operation = Operation.None;
848
 
                                                oldValue = null;
849
 
                                                flagsModified = false;
850
 
                                                oldFlags = 0;
851
 
                                                break;
852
 
 
853
 
                                        case Operation.Delete:
854
 
                                                // Add the property back to the PropertyList.
855
 
                                                node.Properties.AddNodeProperty( this );
856
 
 
857
 
                                                // Restore its in-memory state.
858
 
                                                operation = Operation.None;
859
 
                                                oldValue = null;
860
 
                                                flagsModified = false;
861
 
                                                oldFlags = 0;
862
 
                                                break;
863
 
 
864
 
                                        case Operation.Modify:
865
 
                                                // Restore its in-memory state.
866
 
                                                operation = Operation.None;
867
 
 
868
 
                                                // Has the value changed?
869
 
                                                if ( oldValue != null )
870
 
                                                {
871
 
                                                        // Set the value back into the property.
872
 
                                                        ValueString = oldValue;
873
 
                                                        oldValue = null;
874
 
                                                }
875
 
 
876
 
                                                // Have the flags changed?
877
 
                                                if ( flagsModified )
878
 
                                                {
879
 
                                                        PropertyFlags = oldFlags;
880
 
                                                        flagsModified = false;
881
 
                                                        oldFlags = 0;
882
 
                                                }
883
 
                                                break;
884
 
 
885
 
                                        case Operation.NameChange:
886
 
                                                // Restore the name the Node object.
887
 
                                                node.BaseName = oldValue;
888
 
 
889
 
                                                // Restore its in-memory state.
890
 
                                                operation = Operation.None;
891
 
                                                oldValue = null;
892
 
                                                break;
893
 
                                }
894
 
                        }
895
 
                }
896
 
 
897
 
                /// <summary>
898
 
                /// Applies the merge information contained in this property to the specified node.
899
 
                /// </summary>
900
 
                /// <param name="node">Node to merge property on to.</param>
901
 
                internal void ApplyMergeInformation( Node node )
902
 
                {
903
 
                        switch ( operation )
904
 
                        {
905
 
                                case Operation.Add:
906
 
                                {
907
 
                                        XmlNode xmlNode = node.Properties.PropertyDocument.ImportNode( xmlProperty, true );
908
 
                                        node.Properties.PropertyRoot.AppendChild( xmlNode );
909
 
                                        break;
910
 
                                }
911
 
 
912
 
                                case Operation.Delete:
913
 
                                {
914
 
                                        // Get the current value of this property.
915
 
                                        string currentValue = ValueString;
916
 
 
917
 
                                        // Find the property that matches the one to delete.
918
 
                                        MultiValuedList mvlDelete = node.Properties.FindValues( Name, true );
919
 
                                        foreach ( Property p in mvlDelete )
920
 
                                        {
921
 
                                                // Does the value match?
922
 
                                                if ( p.ValueString == currentValue )
923
 
                                                {
924
 
                                                        // Remove all the children of this xml property node and remove this node
925
 
                                                        // from its parent.
926
 
                                                        p.xmlProperty.RemoveAll();
927
 
                                                        p.xmlProperty.ParentNode.RemoveChild( p.xmlProperty );
928
 
                                                        break;
929
 
                                                }
930
 
                                        }
931
 
                                        break;
932
 
                                }
933
 
 
934
 
                                case Operation.Modify:
935
 
                                {
936
 
                                        Property modifyProperty = null;
937
 
 
938
 
                                        // Get the current value of the property.
939
 
                                        string currentValue = ValueString;
940
 
 
941
 
                                        // If the value has been modified used the oldValue.
942
 
                                        string matchValue = ( oldValue != null ) ? oldValue : currentValue;
943
 
 
944
 
                                        // Find the property that matches the one to modify.
945
 
                                        MultiValuedList mvlModify = node.Properties.FindValues( Name, true );
946
 
                                        if ( mvlModify.Count > 1 )
947
 
                                        {
948
 
                                                // Search through all of the properties to find a match.
949
 
                                                foreach ( Property p in mvlModify )
950
 
                                                {
951
 
                                                        // Are the values equal?
952
 
                                                        if ( p.ValueString == matchValue )
953
 
                                                        {
954
 
                                                                // Set the new value.
955
 
                                                                p.ValueString = currentValue;
956
 
 
957
 
                                                                // If the flags have changed, update the flags.
958
 
                                                                if ( flagsModified )
959
 
                                                                {
960
 
                                                                        p.xmlProperty.SetAttribute( XmlTags.FlagsAttr, PropertyFlags.ToString() );
961
 
                                                                }
962
 
 
963
 
                                                                modifyProperty = p;
964
 
                                                                break;
965
 
                                                        }
966
 
                                                }
967
 
 
968
 
                                                // Check if a match was found.
969
 
                                                if ( modifyProperty == null )
970
 
                                                {
971
 
                                                        // A matching property was not found and this is a multivalued property.
972
 
                                                        // Add this property as a multivalued property.
973
 
                                                        XmlNode xmlNode = node.Properties.PropertyDocument.ImportNode( xmlProperty, true );
974
 
                                                        node.Properties.PropertyRoot.AppendChild( xmlNode );
975
 
                                                }
976
 
                                        }
977
 
                                        else
978
 
                                        {
979
 
                                                // See if there is at least one value or this property is marked to be a multivalued
980
 
                                                // property. If neither of these cases are true, then assume that another process
981
 
                                                // has deleted the property and deletes always win.
982
 
                                                if ( mvlModify.Count == 1 )
983
 
                                                {
984
 
                                                        // Get the single property and see if either is marked as multivalued.
985
 
                                                        modifyProperty = mvlModify[ 0 ];
986
 
 
987
 
                                                        // Is it a match?
988
 
                                                        if ( ( modifyProperty.ValueString != matchValue ) && ( modifyProperty.MultiValuedProperty || MultiValuedProperty ) )
989
 
                                                        {
990
 
                                                                // The property is multivalued.  Add it to the node.
991
 
                                                                XmlNode xmlNode = node.Properties.PropertyDocument.ImportNode( xmlProperty, true );
992
 
                                                                node.Properties.PropertyRoot.AppendChild( xmlNode );
993
 
                                                        }
994
 
                                                        else
995
 
                                                        {
996
 
                                                                // Assume that this is a single-valued property and that it has been changed
997
 
                                                                // since the last time it was read.  Modify the value.
998
 
                                                                modifyProperty.ValueString = currentValue;
999
 
 
1000
 
                                                                // If the flags have changed, update the flags.
1001
 
                                                                if ( flagsModified )
1002
 
                                                                {
1003
 
                                                                        modifyProperty.xmlProperty.SetAttribute( XmlTags.FlagsAttr, PropertyFlags.ToString() );
1004
 
                                                                }
1005
 
                                                        }
1006
 
                                                }
1007
 
                                                else
1008
 
                                                {
1009
 
                                                        // The property is multivalued.  Add it to the node.
1010
 
                                                        XmlNode xmlNode = node.Properties.PropertyDocument.ImportNode( xmlProperty, true );
1011
 
                                                        node.Properties.PropertyRoot.AppendChild( xmlNode );
1012
 
                                                }
1013
 
                                        }
1014
 
                                        break;
1015
 
                                }
1016
 
 
1017
 
                                case Operation.NameChange:
1018
 
                                {
1019
 
                                        // Set the name in the new Node object.
1020
 
                                        node.BaseName = ValueString;
1021
 
                                        break;
1022
 
                                }
1023
 
                        }
1024
 
                }
1025
 
 
1026
 
                /// <summary>
1027
 
                /// Deletes this property from the property list.
1028
 
                /// </summary>
1029
 
                public void DeleteProperty()
1030
 
                {
1031
 
                        // Only delete if the property is attached to a list.
1032
 
                        if ( IsAssociatedProperty )
1033
 
                        {
1034
 
                                // Create a detached property since this is being removed from the list.
1035
 
                                XmlDocument tempDoc = new XmlDocument();
1036
 
                                tempDoc.AppendChild( tempDoc.ImportNode( xmlProperty, true ) );
1037
 
 
1038
 
                                // Save the property merge information before all the pertinent info is destroyed.
1039
 
                                SaveMergeInformation( propertyList, Operation.Delete, null, false, 0 );
1040
 
 
1041
 
                                // Remove all the children of this xml property node.
1042
 
                                xmlProperty.RemoveAll();
1043
 
 
1044
 
                                // Remove this node from its parent.
1045
 
                                xmlProperty.ParentNode.RemoveChild( xmlProperty );
1046
 
                                xmlProperty = ( XmlElement )tempDoc.FirstChild;
1047
 
 
1048
 
                                // Setup the now detached property.
1049
 
                                propertyList = null;
1050
 
                        }
1051
 
                }
1052
 
 
1053
 
                /// <summary>
1054
 
                /// Returns the syntax type from a C# object.
1055
 
                /// </summary>
1056
 
                /// <param name="propertyValue">Value type</param>
1057
 
                /// <returns>The syntax type that represents the property value.</returns>
1058
 
                static internal Syntax GetSyntaxType( object propertyValue )
1059
 
                {
1060
 
                        Syntax syntax;
1061
 
 
1062
 
                        // Get the type of object from propertyValue.
1063
 
                        // There is no top level type that matches this object.  Check for an enumerated type.
1064
 
                        if ( propertyValue.GetType().BaseType.Name == "Enum" )
1065
 
                        {
1066
 
                                syntax = ( Syntax )Enum.Parse( typeof( Syntax ),  Enum.GetUnderlyingType( propertyValue.GetType() ).Name );
1067
 
                        }
1068
 
                        else
1069
 
                        {
1070
 
                                syntax = ( Syntax )Enum.Parse( typeof( Syntax ), propertyValue.GetType().Name );
1071
 
                        }
1072
 
 
1073
 
                        return syntax;
1074
 
                }
1075
 
 
1076
 
                /// <summary>
1077
 
                /// Saves the old state of the object so it can be merged at object commit time.
1078
 
                /// </summary>
1079
 
                /// <param name="propertyList">PropertyList object that this property is associated with.</param>
1080
 
                /// <param name="op">Operation being performed on this property.</param>
1081
 
                /// <param name="priorValue">Previous value of the property, may be null.</param>
1082
 
                /// <param name="priorFlagsModified">Set to true if property flags have been modified.</param>
1083
 
                /// <param name="priorFlags">Previous flag value, may be zero.</param>
1084
 
                internal void SaveMergeInformation( PropertyList propertyList, Operation op, string priorValue, bool priorFlagsModified, uint priorFlags )
1085
 
                {
1086
 
                        // If there is no PropertyList object associated with this property or it is a new object, or
1087
 
                        // if it is currently being aborted, we don't need to track it.
1088
 
                        if ( IsAssociatedProperty && ValidSaveMergeInfoState( propertyList.State ) )
1089
 
                        {
1090
 
                                // Operation is the current state of the property.
1091
 
                                switch ( operation )
1092
 
                                {
1093
 
                                                // When the current state is Add the new state should act as follows:
1094
 
                                                //
1095
 
                                                // Add: Illegal state.  An added value cannot be added again.  The add code will
1096
 
                                                // report that the new state is Modify.
1097
 
                                                //
1098
 
                                                // Delete: A delete after an add is basically a NOP.  Just return the property
1099
 
                                                // back to it's pre-add state. Set current state to None and remove from mergeList.
1100
 
                                                //
1101
 
                                                // Modify: Do nothing. This is a new value.  It can be modified over and over,
1102
 
                                                // but the it is still an add operation.
1103
 
                                        case Operation.Add:
1104
 
                                                if ( op == Operation.Delete )
1105
 
                                                {
1106
 
                                                        // Set back to pre-add state.
1107
 
                                                        operation = Operation.None;
1108
 
                                                        propertyList.RemoveFromChangeList( this );
1109
 
                                                }
1110
 
 
1111
 
                                                break;
1112
 
 
1113
 
                                                // When the current state is Delete the new state should act as follows:
1114
 
                                                //
1115
 
                                                // Add: An add after a delete is basically a NOP.  Just return the property
1116
 
                                                // back to it's pre-delete state. Set current state to None and remove from mergeList.
1117
 
                                                //
1118
 
                                                // Delete: Do nothing. Deleting a property that has already been deleted does nothing.
1119
 
                                                //
1120
 
                                                // Modify: Illegal state. A deleted property cannot be modified. The modify code will
1121
 
                                                // report that the new state is add.
1122
 
                                        case Operation.Delete:
1123
 
                                                if ( op == Operation.Add )
1124
 
                                                {
1125
 
                                                        // Set back to pre-delete state.
1126
 
                                                        operation = Operation.None;
1127
 
                                                        propertyList.RemoveFromChangeList( this );
1128
 
                                                }
1129
 
 
1130
 
                                                break;
1131
 
 
1132
 
                                                // When the current state is Modify the new state should act as follows:
1133
 
                                                //
1134
 
                                                // Add: Illegal state.  An existing value cannot be added. The add code will report
1135
 
                                                // that the new state is modify.
1136
 
                                                //
1137
 
                                                // Delete: Set the current state to delete.  Set the current value to oldValue, if not
1138
 
                                                // null.  Set current flags to oldFlags, if they have been modified.  Set oldValue
1139
 
                                                // to null.  Set modifiedFlags to false.
1140
 
                                                // Leave in the mergeList.
1141
 
                                                //
1142
 
                                                // Modify: Do nothing. The property can be modified over and over again and it is still
1143
 
                                                // a modify operation. However a check needs to be made to see if a different part of
1144
 
                                                // the property was modified and its original value needs to be saved.
1145
 
                                        case Operation.Modify:
1146
 
                                                if ( op == Operation.Delete )
1147
 
                                                {
1148
 
                                                        // Set the new state to delete.
1149
 
                                                        operation = Operation.Delete;
1150
 
 
1151
 
                                                        // Has the value changed?
1152
 
                                                        if ( oldValue != null )
1153
 
                                                        {
1154
 
                                                                // Set the value back into the property.
1155
 
                                                                ValueString = oldValue;
1156
 
                                                                oldValue = null;
1157
 
                                                        }
1158
 
 
1159
 
                                                        // Have the flags changed?
1160
 
                                                        if ( flagsModified )
1161
 
                                                        {
1162
 
                                                                PropertyFlags = oldFlags;
1163
 
                                                                flagsModified = false;
1164
 
                                                                oldFlags = 0;
1165
 
                                                        }
1166
 
                                                }
1167
 
                                                else if ( op == Operation.Modify )
1168
 
                                                {
1169
 
                                                        // Don't ever overwrite a saved old value.
1170
 
                                                        if ( ( oldValue == null ) && ( priorValue != null ) )
1171
 
                                                        {
1172
 
                                                                oldValue = priorValue;
1173
 
                                                        }
1174
 
 
1175
 
                                                        if ( ( flagsModified == false )  && ( priorFlagsModified == true ) )
1176
 
                                                        {
1177
 
                                                                oldFlags = priorFlags;
1178
 
                                                                flagsModified = true;
1179
 
                                                        }
1180
 
                                                }
1181
 
 
1182
 
                                                break;
1183
 
 
1184
 
                                                // When the current state is None the new state should act as follows:
1185
 
                                                //
1186
 
                                                // Add: Set the current state to add and add the new property to the mergeList.
1187
 
                                                //
1188
 
                                                // Delete: Set the current state to delete and add the deleted property to the
1189
 
                                                // mergeList.
1190
 
                                                //
1191
 
                                                // Modify: Set the current state to modify. Save the oldValue if not null. Save
1192
 
                                                // the old flags if modified. Add the modified property to the mergeList.
1193
 
                                                //
1194
 
                                                // NameChange: Set the current state to name changed. Save the oldValue. Add the modified
1195
 
                                                // property to the mergeList.
1196
 
                                        case Operation.None:
1197
 
                                                // This is a normal node property.
1198
 
                                                if ( op == Operation.Modify )
1199
 
                                                {
1200
 
                                                        if ( priorValue != null )
1201
 
                                                        {
1202
 
                                                                oldValue = priorValue;
1203
 
                                                        }
1204
 
 
1205
 
                                                        if ( priorFlagsModified )
1206
 
                                                        {
1207
 
                                                                oldFlags = priorFlags;
1208
 
                                                                flagsModified = true;
1209
 
                                                        }
1210
 
                                                }
1211
 
                                                else if ( op == Operation.NameChange )
1212
 
                                                {
1213
 
                                                        oldValue = priorValue;
1214
 
                                                }
1215
 
 
1216
 
                                                operation = op;
1217
 
                                                propertyList.AddToChangeList( this );
1218
 
                                                break;
1219
 
 
1220
 
                                                // When the current state is NameChange the new state should act as follows:
1221
 
                                                //
1222
 
                                                // NameChange: Do nothing. The property can be modified over and over again and it is still
1223
 
                                                // a name change operation.
1224
 
                                        case Operation.NameChange:
1225
 
                                                break;
1226
 
                                }
1227
 
                        }
1228
 
                }
1229
 
 
1230
 
                /// <summary>
1231
 
                /// Sets the value of this property.
1232
 
                /// </summary>
1233
 
                /// <param name="propertyValue">Property value to set.</param>
1234
 
                internal void SetPropertyValue( object propertyValue )
1235
 
                {
1236
 
                        // Based on the syntax type, create an object and stuff in the property value.
1237
 
                        switch ( GetSyntaxType( propertyValue ) )
1238
 
                        {
1239
 
                                case Syntax.String:
1240
 
                                        SetPropertyValue( ( string )propertyValue );
1241
 
                                        break;
1242
 
 
1243
 
                                case Syntax.SByte:
1244
 
                                        SetPropertyValue( ( sbyte )propertyValue );
1245
 
                                        break;
1246
 
 
1247
 
                                case Syntax.Byte:
1248
 
                                        SetPropertyValue( ( byte )propertyValue );
1249
 
                                        break;
1250
 
 
1251
 
                                case Syntax.Int16:
1252
 
                                        SetPropertyValue( ( short )propertyValue );
1253
 
                                        break;
1254
 
 
1255
 
                                case Syntax.UInt16:
1256
 
                                        SetPropertyValue( ( ushort )propertyValue );
1257
 
                                        break;
1258
 
 
1259
 
                                case Syntax.Int32:
1260
 
                                        SetPropertyValue( ( int )propertyValue );
1261
 
                                        break;
1262
 
 
1263
 
                                case Syntax.UInt32:
1264
 
                                        SetPropertyValue( ( uint )propertyValue );
1265
 
                                        break;
1266
 
 
1267
 
                                case Syntax.Int64:
1268
 
                                        SetPropertyValue( ( long )propertyValue );
1269
 
                                        break;
1270
 
 
1271
 
                                case Syntax.UInt64:
1272
 
                                        SetPropertyValue( ( ulong )propertyValue );
1273
 
                                        break;
1274
 
 
1275
 
                                case Syntax.Char:
1276
 
                                        SetPropertyValue( ( char )propertyValue );
1277
 
                                        break;
1278
 
                                        
1279
 
                                case Syntax.Single:
1280
 
                                        SetPropertyValue( ( float )propertyValue );
1281
 
                                        break;
1282
 
 
1283
 
                                case Syntax.Boolean:
1284
 
                                        SetPropertyValue( ( bool )propertyValue );
1285
 
                                        break;
1286
 
 
1287
 
                                case Syntax.DateTime:
1288
 
                                        SetPropertyValue( ( DateTime )propertyValue );
1289
 
                                        break;
1290
 
 
1291
 
                                case Syntax.Uri:
1292
 
                                        SetPropertyValue( ( Uri )propertyValue );
1293
 
                                        break;
1294
 
 
1295
 
                                case Syntax.XmlDocument:
1296
 
                                        SetPropertyValue( ( XmlDocument )propertyValue );
1297
 
                                        break;
1298
 
 
1299
 
                                case Syntax.TimeSpan:
1300
 
                                        SetPropertyValue( ( TimeSpan )propertyValue );
1301
 
                                        break;
1302
 
 
1303
 
                                case Syntax.Relationship:
1304
 
                                        SetPropertyValue( ( Relationship )propertyValue );
1305
 
                                        break;
1306
 
 
1307
 
                                default:
1308
 
                                        throw new CollectionStoreException( new ArgumentException( "Invalid object", "propertyValue" ) );
1309
 
                        }
1310
 
                }
1311
 
 
1312
 
                /// <summary>
1313
 
                /// Sets a property value into the property.
1314
 
                /// </summary>
1315
 
                /// <param name="propertyValue">Property value to set in property.</param>
1316
 
                internal void SetPropertyValue( Property propertyValue )
1317
 
                {
1318
 
                        if ( Type != propertyValue.Type )
1319
 
                        {
1320
 
                                throw new SyntaxException( propertyValue.Type );
1321
 
                        }
1322
 
 
1323
 
                        // Remember the old value before overwriting it with the new value.
1324
 
                        string currentValue = ValueString;
1325
 
                        ValueString = propertyValue.ValueString;
1326
 
 
1327
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1328
 
                }
1329
 
 
1330
 
                /// <summary>
1331
 
                /// Sets a string value into the property.
1332
 
                /// </summary>
1333
 
                /// <param name="propertyValue">string value to set in property.</param>
1334
 
                internal void SetPropertyValue( string propertyValue )
1335
 
                {
1336
 
                        if ( Type != Syntax.String )
1337
 
                        {
1338
 
                                throw new SyntaxException( Type );
1339
 
                        }
1340
 
 
1341
 
                        // Remember the old value before overwriting it with the new value.
1342
 
                        string currentValue = ValueString;
1343
 
                        ValueString = propertyValue;
1344
 
 
1345
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1346
 
                }
1347
 
 
1348
 
                /// <summary>
1349
 
                /// Sets an sbyte value into the property.
1350
 
                /// </summary>
1351
 
                /// <param name="propertyValue">sbyte value to set in property.</param>
1352
 
                internal void SetPropertyValue( sbyte propertyValue )
1353
 
                {
1354
 
                        if ( Type != Syntax.SByte )
1355
 
                        {
1356
 
                                throw new SyntaxException( Type );
1357
 
                        }
1358
 
 
1359
 
                        // Remember the old value before overwriting it with the new value.
1360
 
                        string currentValue = ValueString;
1361
 
                        ValueString = propertyValue.ToString();
1362
 
 
1363
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1364
 
                }
1365
 
 
1366
 
                /// <summary>
1367
 
                /// Sets a byte value into the property.
1368
 
                /// </summary>
1369
 
                /// <param name="propertyValue">byte value to set in property.</param>
1370
 
                internal void SetPropertyValue( byte propertyValue )
1371
 
                {
1372
 
                        if ( Type != Syntax.Byte )
1373
 
                        {
1374
 
                                throw new SyntaxException( Type );
1375
 
                        }
1376
 
 
1377
 
                        // Remember the old value before overwriting it with the new value.
1378
 
                        string currentValue = ValueString;
1379
 
                        ValueString = propertyValue.ToString();
1380
 
 
1381
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1382
 
                }
1383
 
 
1384
 
                /// <summary>
1385
 
                /// Sets a short value into the property.
1386
 
                /// </summary>
1387
 
                /// <param name="propertyValue">short value to set in property.</param>
1388
 
                internal void SetPropertyValue( short propertyValue )
1389
 
                {
1390
 
                        if ( Type != Syntax.Int16 )
1391
 
                        {
1392
 
                                throw new SyntaxException( Type );
1393
 
                        }
1394
 
 
1395
 
                        // Remember the old value before overwriting it with the new value.
1396
 
                        string currentValue = ValueString;
1397
 
                        ValueString = propertyValue.ToString();
1398
 
 
1399
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1400
 
                }
1401
 
 
1402
 
                /// <summary>
1403
 
                /// Sets a ushort value into the property.
1404
 
                /// </summary>
1405
 
                /// <param name="propertyValue">ushort value to set in property.</param>
1406
 
                internal void SetPropertyValue( ushort propertyValue )
1407
 
                {
1408
 
                        if ( Type != Syntax.UInt16 )
1409
 
                        {
1410
 
                                throw new SyntaxException( Type );
1411
 
                        }
1412
 
 
1413
 
                        // Remember the old value before overwriting it with the new value.
1414
 
                        string currentValue = ValueString;
1415
 
                        ValueString = propertyValue.ToString();
1416
 
 
1417
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1418
 
                }
1419
 
 
1420
 
                /// <summary>
1421
 
                /// Sets an int value into the property.
1422
 
                /// </summary>
1423
 
                /// <param name="propertyValue">int value to set in property.</param>
1424
 
                internal void SetPropertyValue( int propertyValue )
1425
 
                {
1426
 
                        if ( Type != Syntax.Int32 )
1427
 
                        {
1428
 
                                throw new SyntaxException( Type );
1429
 
                        }
1430
 
 
1431
 
                        // Remember the old value before overwriting it with the new value.
1432
 
                        string currentValue = ValueString;
1433
 
                        ValueString = propertyValue.ToString();
1434
 
 
1435
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1436
 
                }
1437
 
 
1438
 
                /// <summary>
1439
 
                /// Sets a uint value into the property.
1440
 
                /// </summary>
1441
 
                /// <param name="propertyValue">uint value to set in property.</param>
1442
 
                internal void SetPropertyValue( uint propertyValue )
1443
 
                {
1444
 
                        if ( Type != Syntax.UInt32 )
1445
 
                        {
1446
 
                                throw new SyntaxException( Type );
1447
 
                        }
1448
 
 
1449
 
                        // Remember the old value before overwriting it with the new value.
1450
 
                        string currentValue = ValueString;
1451
 
                        ValueString = propertyValue.ToString();
1452
 
 
1453
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1454
 
                }
1455
 
 
1456
 
                /// <summary>
1457
 
                /// Sets a long value into the property.
1458
 
                /// </summary>
1459
 
                /// <param name="propertyValue">long value to set in property.</param>
1460
 
                internal void SetPropertyValue( long propertyValue )
1461
 
                {
1462
 
                        if ( Type != Syntax.Int64 )
1463
 
                        {
1464
 
                                throw new SyntaxException( Type );
1465
 
                        }
1466
 
 
1467
 
                        // Remember the old value before overwriting it with the new value.
1468
 
                        string currentValue = ValueString;
1469
 
                        ValueString = propertyValue.ToString();
1470
 
 
1471
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1472
 
                }
1473
 
 
1474
 
                /// <summary>
1475
 
                /// Sets a ulong value into the property.
1476
 
                /// </summary>
1477
 
                /// <param name="propertyValue">ulong value to set in property.</param>
1478
 
                internal void SetPropertyValue( ulong propertyValue )
1479
 
                {
1480
 
                        if ( Type != Syntax.UInt64 )
1481
 
                        {
1482
 
                                throw new SyntaxException( Type );
1483
 
                        }
1484
 
 
1485
 
                        // Remember the old value before overwriting it with the new value.
1486
 
                        string currentValue = ValueString;
1487
 
                        ValueString = propertyValue.ToString();
1488
 
 
1489
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1490
 
                }
1491
 
 
1492
 
                /// <summary>
1493
 
                /// Sets a char value into the property.
1494
 
                /// </summary>
1495
 
                /// <param name="propertyValue">char value to set in property.</param>
1496
 
                internal void SetPropertyValue( char propertyValue )
1497
 
                {
1498
 
                        if ( Type != Syntax.Char )
1499
 
                        {
1500
 
                                throw new SyntaxException( Type );
1501
 
                        }
1502
 
 
1503
 
                        // Remember the old value before overwriting it with the new value.
1504
 
                        string currentValue = ValueString;
1505
 
                        ValueString = ( ( ushort )propertyValue ).ToString();
1506
 
 
1507
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1508
 
                }
1509
 
 
1510
 
                /// <summary>
1511
 
                /// Sets a float value into the property.
1512
 
                /// </summary>
1513
 
                /// <param name="propertyValue">float value to set in property.</param>
1514
 
                internal void SetPropertyValue( float propertyValue )
1515
 
                {
1516
 
                        if ( Type != Syntax.Single )
1517
 
                        {
1518
 
                                throw new SyntaxException( Type );
1519
 
                        }
1520
 
 
1521
 
                        // Remember the old value before overwriting it with the new value.
1522
 
                        string currentValue = ValueString;
1523
 
                        ValueString = propertyValue.ToString();
1524
 
 
1525
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1526
 
                }
1527
 
 
1528
 
                /// <summary>
1529
 
                /// Sets a bool value into the property.
1530
 
                /// </summary>
1531
 
                /// <param name="propertyValue">bool value to set in property.</param>
1532
 
                internal void SetPropertyValue( bool propertyValue )
1533
 
                {
1534
 
                        if ( Type != Syntax.Boolean )
1535
 
                        {
1536
 
                                throw new SyntaxException( Type );
1537
 
                        }
1538
 
 
1539
 
                        // Remember the old value before overwriting it with the new value.
1540
 
                        string currentValue = ValueString;
1541
 
                        ValueString = propertyValue ? "1" : "0";
1542
 
 
1543
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1544
 
                }
1545
 
 
1546
 
                /// <summary>
1547
 
                /// Sets a DateTime value into the property.
1548
 
                /// </summary>
1549
 
                /// <param name="propertyValue">DateTime value to set in property.</param>
1550
 
                internal void SetPropertyValue( DateTime propertyValue )
1551
 
                {
1552
 
                        if ( Type != Syntax.DateTime )
1553
 
                        {
1554
 
                                throw new SyntaxException( Type );
1555
 
                        }
1556
 
 
1557
 
                        // Remember the old value before overwriting it with the new value.
1558
 
                        string currentValue = ValueString;
1559
 
                        ValueString = propertyValue.Ticks.ToString();
1560
 
 
1561
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1562
 
                }
1563
 
 
1564
 
                /// <summary>
1565
 
                /// Sets a Uri value into the property.
1566
 
                /// </summary>
1567
 
                /// <param name="propertyValue">Uri value to set in property.</param>
1568
 
                internal void SetPropertyValue( Uri propertyValue )
1569
 
                {
1570
 
                        if ( Type != Syntax.Uri )
1571
 
                        {
1572
 
                                throw new SyntaxException( Type );
1573
 
                        }
1574
 
 
1575
 
                        // Remember the old value before overwriting it with the new value.
1576
 
                        string currentValue = ValueString;
1577
 
                        ValueString = propertyValue.ToString();
1578
 
 
1579
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1580
 
                }
1581
 
 
1582
 
                /// <summary>
1583
 
                /// Sets an Xml value into the property.
1584
 
                /// </summary>
1585
 
                /// <param name="propertyValue">Xml value to set in property.</param>
1586
 
                internal void SetPropertyValue( XmlDocument propertyValue )
1587
 
                {
1588
 
                        if ( Type != Syntax.XmlDocument )
1589
 
                        {
1590
 
                                throw new SyntaxException( Type );
1591
 
                        }
1592
 
 
1593
 
                        // Remember the old value before overwriting it with the new value.
1594
 
                        string currentValue = ValueString;
1595
 
                        ValueString = propertyValue.InnerXml;
1596
 
 
1597
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1598
 
                }
1599
 
 
1600
 
                /// <summary>
1601
 
                /// Sets a TimeSpan value into the property.
1602
 
                /// </summary>
1603
 
                /// <param name="propertyValue">TimeSpan value to set in property.</param>
1604
 
                internal void SetPropertyValue( TimeSpan propertyValue )
1605
 
                {
1606
 
                        if ( Type != Syntax.TimeSpan )
1607
 
                        {
1608
 
                                throw new SyntaxException( Type );
1609
 
                        }
1610
 
 
1611
 
                        // Remember the old value before overwriting it with the new value.
1612
 
                        string currentValue = ValueString;
1613
 
                        ValueString = propertyValue.Ticks.ToString();
1614
 
 
1615
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1616
 
                }
1617
 
 
1618
 
                /// <summary>
1619
 
                /// Sets a Relationship value into the property.
1620
 
                /// </summary>
1621
 
                /// <param name="relationship">Relationship value to set in property.</param>
1622
 
                internal void SetPropertyValue( Relationship relationship )
1623
 
                {
1624
 
                        if ( Type != Syntax.Relationship )
1625
 
                        {
1626
 
                                throw new SyntaxException( Type );
1627
 
                        }
1628
 
 
1629
 
                        // Remember the old value before overwriting it with the new value.
1630
 
                        string currentValue = ValueString;
1631
 
                        ValueString = relationship.ToString();
1632
 
 
1633
 
                        SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1634
 
                }
1635
 
                #endregion
1636
 
 
1637
 
                #region Public Methods
1638
 
                /// <summary>
1639
 
                /// Deletes this property from the property list.
1640
 
                /// </summary>
1641
 
                public void Delete()
1642
 
                {
1643
 
                        // Make sure this is not a system property
1644
 
                        if ( IsSystemProperty() )
1645
 
                        {
1646
 
                                throw new InvalidOperationException( "Cannot delete a system property" );
1647
 
                        }
1648
 
 
1649
 
                        DeleteProperty();
1650
 
                }
1651
 
 
1652
 
                /// <summary>
1653
 
                /// Determines if the property is a system (non-editable) property.
1654
 
                /// </summary>
1655
 
                /// <returns>True if propertyName specifies a system property, otherwise false is returned.</returns>
1656
 
                public bool IsSystemProperty()
1657
 
                {
1658
 
                        return PropertyTags.IsSystemProperty( xmlProperty.GetAttribute( XmlTags.NameAttr ) ); 
1659
 
                }
1660
 
 
1661
 
                /// <summary>
1662
 
                /// Sets the value of this property.
1663
 
                /// </summary>
1664
 
                /// <param name="propertyValue">Property value to set.</param>
1665
 
                public void SetValue( Property propertyValue )
1666
 
                {
1667
 
                        // Make sure this is not a system property
1668
 
                        if ( IsSystemProperty() )
1669
 
                        {
1670
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1671
 
                        }
1672
 
 
1673
 
                        SetPropertyValue( propertyValue );
1674
 
                }
1675
 
 
1676
 
                /// <summary>
1677
 
                /// Sets the value of this property.
1678
 
                /// </summary>
1679
 
                /// <param name="propertyValue">Property value to set.</param>
1680
 
                public void SetValue( object propertyValue )
1681
 
                {
1682
 
                        // Make sure this is not a system property
1683
 
                        if ( IsSystemProperty() )
1684
 
                        {
1685
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1686
 
                        }
1687
 
 
1688
 
                        SetPropertyValue( propertyValue );
1689
 
                }
1690
 
 
1691
 
                /// <summary>
1692
 
                /// Sets a string value into the property.
1693
 
                /// </summary>
1694
 
                /// <param name="propertyValue">string value to set in property.</param>
1695
 
                public void SetValue( string propertyValue )
1696
 
                {
1697
 
                        // Make sure this is not a system property
1698
 
                        if ( IsSystemProperty() )
1699
 
                        {
1700
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1701
 
                        }
1702
 
 
1703
 
                        SetPropertyValue( propertyValue );
1704
 
                }
1705
 
 
1706
 
                /// <summary>
1707
 
                /// Sets an sbyte value into the property.
1708
 
                /// </summary>
1709
 
                /// <param name="propertyValue">sbyte value to set in property.</param>
1710
 
                public void SetValue( sbyte propertyValue )
1711
 
                {
1712
 
                        // Make sure this is not a system property
1713
 
                        if ( IsSystemProperty() )
1714
 
                        {
1715
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1716
 
                        }
1717
 
 
1718
 
                        SetPropertyValue( propertyValue );
1719
 
                }
1720
 
 
1721
 
                /// <summary>
1722
 
                /// Sets a byte value into the property.
1723
 
                /// </summary>
1724
 
                /// <param name="propertyValue">byte value to set in property.</param>
1725
 
                public void SetValue( byte propertyValue )
1726
 
                {
1727
 
                        // Make sure this is not a system property
1728
 
                        if ( IsSystemProperty() )
1729
 
                        {
1730
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1731
 
                        }
1732
 
 
1733
 
                        SetPropertyValue( propertyValue );
1734
 
                }
1735
 
 
1736
 
                /// <summary>
1737
 
                /// Sets a short value into the property.
1738
 
                /// </summary>
1739
 
                /// <param name="propertyValue">short value to set in property.</param>
1740
 
                public void SetValue( short propertyValue )
1741
 
                {
1742
 
                        // Make sure this is not a system property
1743
 
                        if ( IsSystemProperty() )
1744
 
                        {
1745
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1746
 
                        }
1747
 
 
1748
 
                        SetPropertyValue( propertyValue );
1749
 
                }
1750
 
 
1751
 
                /// <summary>
1752
 
                /// Sets a ushort value into the property.
1753
 
                /// </summary>
1754
 
                /// <param name="propertyValue">ushort value to set in property.</param>
1755
 
                public void SetValue( ushort propertyValue )
1756
 
                {
1757
 
                        // Make sure this is not a system property
1758
 
                        if ( IsSystemProperty() )
1759
 
                        {
1760
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1761
 
                        }
1762
 
 
1763
 
                        SetPropertyValue( propertyValue );
1764
 
                }
1765
 
 
1766
 
                /// <summary>
1767
 
                /// Sets an int value into the property.
1768
 
                /// </summary>
1769
 
                /// <param name="propertyValue">int value to set in property.</param>
1770
 
                public void SetValue( int propertyValue )
1771
 
                {
1772
 
                        // Make sure this is not a system property
1773
 
                        if ( IsSystemProperty() )
1774
 
                        {
1775
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1776
 
                        }
1777
 
 
1778
 
                        SetPropertyValue( propertyValue );
1779
 
                }
1780
 
 
1781
 
                /// <summary>
1782
 
                /// Sets a uint value into the property.
1783
 
                /// </summary>
1784
 
                /// <param name="propertyValue">uint value to set in property.</param>
1785
 
                public void SetValue( uint propertyValue )
1786
 
                {
1787
 
                        // Make sure this is not a system property
1788
 
                        if ( IsSystemProperty() )
1789
 
                        {
1790
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1791
 
                        }
1792
 
 
1793
 
                        SetPropertyValue( propertyValue );
1794
 
                }
1795
 
 
1796
 
                /// <summary>
1797
 
                /// Sets a long value into the property.
1798
 
                /// </summary>
1799
 
                /// <param name="propertyValue">long value to set in property.</param>
1800
 
                public void SetValue( long propertyValue )
1801
 
                {
1802
 
                        // Make sure this is not a system property
1803
 
                        if ( IsSystemProperty() )
1804
 
                        {
1805
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1806
 
                        }
1807
 
 
1808
 
                        SetPropertyValue( propertyValue );
1809
 
                }
1810
 
 
1811
 
                /// <summary>
1812
 
                /// Sets a ulong value into the property.
1813
 
                /// </summary>
1814
 
                /// <param name="propertyValue">ulong value to set in property.</param>
1815
 
                public void SetValue( ulong propertyValue )
1816
 
                {
1817
 
                        // Make sure this is not a system property
1818
 
                        if ( IsSystemProperty() )
1819
 
                        {
1820
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1821
 
                        }
1822
 
 
1823
 
                        SetPropertyValue( propertyValue );
1824
 
                }
1825
 
 
1826
 
                /// <summary>
1827
 
                /// Sets a char value into the property.
1828
 
                /// </summary>
1829
 
                /// <param name="propertyValue">char value to set in property.</param>
1830
 
                public void SetValue( char propertyValue )
1831
 
                {
1832
 
                        // Make sure this is not a system property
1833
 
                        if ( IsSystemProperty() )
1834
 
                        {
1835
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1836
 
                        }
1837
 
 
1838
 
                        SetPropertyValue( propertyValue );
1839
 
                }
1840
 
 
1841
 
                /// <summary>
1842
 
                /// Sets a float value into the property.
1843
 
                /// </summary>
1844
 
                /// <param name="propertyValue">float value to set in property.</param>
1845
 
                public void SetValue( float propertyValue )
1846
 
                {
1847
 
                        // Make sure this is not a system property
1848
 
                        if ( IsSystemProperty() )
1849
 
                        {
1850
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1851
 
                        }
1852
 
 
1853
 
                        SetPropertyValue( propertyValue );
1854
 
                }
1855
 
 
1856
 
                /// <summary>
1857
 
                /// Sets a bool value into the property.
1858
 
                /// </summary>
1859
 
                /// <param name="propertyValue">bool value to set in property.</param>
1860
 
                public void SetValue( bool propertyValue )
1861
 
                {
1862
 
                        // Make sure this is not a system property
1863
 
                        if ( IsSystemProperty() )
1864
 
                        {
1865
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1866
 
                        }
1867
 
 
1868
 
                        SetPropertyValue( propertyValue );
1869
 
                }
1870
 
 
1871
 
                /// <summary>
1872
 
                /// Sets a DateTime value into the property.
1873
 
                /// </summary>
1874
 
                /// <param name="propertyValue">DateTime value to set in property.</param>
1875
 
                public void SetValue( DateTime propertyValue )
1876
 
                {
1877
 
                        // Make sure this is not a system property
1878
 
                        if ( IsSystemProperty() )
1879
 
                        {
1880
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1881
 
                        }
1882
 
 
1883
 
                        SetPropertyValue( propertyValue );
1884
 
                }
1885
 
 
1886
 
                /// <summary>
1887
 
                /// Sets a Uri value into the property.
1888
 
                /// </summary>
1889
 
                /// <param name="propertyValue">Uri value to set in property.</param>
1890
 
                public void SetValue( Uri propertyValue )
1891
 
                {
1892
 
                        // Make sure this is not a system property
1893
 
                        if ( IsSystemProperty() )
1894
 
                        {
1895
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1896
 
                        }
1897
 
 
1898
 
                        SetPropertyValue( propertyValue );
1899
 
                }
1900
 
 
1901
 
                /// <summary>
1902
 
                /// Sets an Xml value into the property.
1903
 
                /// </summary>
1904
 
                /// <param name="propertyValue">Xml value to set in property.</param>
1905
 
                public void SetValue( XmlDocument propertyValue )
1906
 
                {
1907
 
                        // Make sure this is not a system property
1908
 
                        if ( IsSystemProperty() )
1909
 
                        {
1910
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1911
 
                        }
1912
 
 
1913
 
                        SetPropertyValue( propertyValue );
1914
 
                }
1915
 
 
1916
 
                /// <summary>
1917
 
                /// Sets a TimeSpan value into the property.
1918
 
                /// </summary>
1919
 
                /// <param name="propertyValue">TimeSpan value to set in property.</param>
1920
 
                public void SetValue( TimeSpan propertyValue )
1921
 
                {
1922
 
                        // Make sure this is not a system property
1923
 
                        if ( IsSystemProperty() )
1924
 
                        {
1925
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1926
 
                        }
1927
 
 
1928
 
                        SetPropertyValue( propertyValue );
1929
 
                }
1930
 
 
1931
 
                /// <summary>
1932
 
                /// Sets a Relationship value into the property.
1933
 
                /// </summary>
1934
 
                /// <param name="propertyValue">Relationship value to set in property.</param>
1935
 
                public void SetValue( Relationship propertyValue )
1936
 
                {
1937
 
                        // Make sure this is not a system property
1938
 
                        if ( IsSystemProperty() )
1939
 
                        {
1940
 
                                throw new InvalidOperationException( "Cannot modify a system property" );
1941
 
                        }
1942
 
 
1943
 
                        SetPropertyValue( propertyValue );
1944
 
                }
1945
 
 
1946
 
                /// <summary>
1947
 
                /// Converts the property value of this instance to its equivalent string.
1948
 
                /// </summary>
1949
 
                /// <returns>A string representing the value of this object.</returns>
1950
 
                public override string ToString()
1951
 
                {
1952
 
                        string output = null;
1953
 
 
1954
 
                        switch ( Type )
1955
 
                        {
1956
 
                                case Syntax.String:
1957
 
                                        output = ( ( string )GetValue() ).ToString();
1958
 
                                        break;
1959
 
                                
1960
 
                                case Syntax.SByte:
1961
 
                                        output = ( ( sbyte )GetValue() ).ToString();
1962
 
                                        break;
1963
 
 
1964
 
                                case Syntax.Byte:
1965
 
                                        output = ( ( byte )GetValue() ).ToString();
1966
 
                                        break;
1967
 
 
1968
 
                                case Syntax.Int16:
1969
 
                                        output = ( ( short )GetValue() ).ToString();
1970
 
                                        break;
1971
 
 
1972
 
                                case Syntax.UInt16:
1973
 
                                        output = ( ( ushort )GetValue() ).ToString();
1974
 
                                        break;
1975
 
 
1976
 
                                case Syntax.Int32:
1977
 
                                        output = ( ( int )GetValue() ).ToString();
1978
 
                                        break;
1979
 
 
1980
 
                                case Syntax.UInt32:
1981
 
                                        output = ( ( uint )GetValue() ).ToString();
1982
 
                                        break;
1983
 
 
1984
 
                                case Syntax.Int64:
1985
 
                                        output = ( ( long )GetValue() ).ToString();
1986
 
                                        break;
1987
 
 
1988
 
                                case Syntax.UInt64:
1989
 
                                        output = ( ( ulong )GetValue() ).ToString();
1990
 
                                        break;
1991
 
 
1992
 
                                case Syntax.Char:
1993
 
                                        output = ( ( char )GetValue() ).ToString();
1994
 
                                        break;
1995
 
                                
1996
 
                                case Syntax.Single:
1997
 
                                        output = ( ( float )GetValue() ).ToString();
1998
 
                                        break;
1999
 
 
2000
 
                                case Syntax.Boolean:
2001
 
                                        output = ( ( bool )GetValue() ).ToString();
2002
 
                                        break;
2003
 
 
2004
 
                                case Syntax.DateTime:
2005
 
                                        output = ( ( DateTime )GetValue() ).ToString();
2006
 
                                        break;
2007
 
 
2008
 
                                case Syntax.Uri:
2009
 
                                        output = ( ( Uri )GetValue() ).ToString();
2010
 
                                        break;
2011
 
 
2012
 
                                case Syntax.XmlDocument:
2013
 
                                        output = ( ( XmlDocument )GetValue() ).ToString();
2014
 
                                        break;
2015
 
 
2016
 
                                case Syntax.TimeSpan:
2017
 
                                        output = ( ( TimeSpan )GetValue() ).ToString();
2018
 
                                        break;
2019
 
                                        
2020
 
                                case Syntax.Relationship:
2021
 
                                        output = ( ( Relationship )GetValue() ).ToString();
2022
 
                                        break;
2023
 
                        }
2024
 
 
2025
 
                        return output;
2026
 
                }
2027
 
 
2028
 
                /// <summary>
2029
 
                ///     Converts the property value of this instance to its equivalent string using the specified
2030
 
                ///     culture-specific format information.
2031
 
                /// </summary>
2032
 
                /// <param name="ifProvider">An IFormatProvider that supplies culture-specific formatting information.</param>
2033
 
                /// <returns>A string representing the value of this object.</returns>
2034
 
                public string ToString( IFormatProvider ifProvider )
2035
 
                {
2036
 
                        string output = null;
2037
 
 
2038
 
                        switch ( Type )
2039
 
                        {
2040
 
                                case Syntax.String:
2041
 
                                        output = ( ( string )GetValue() ).ToString( ifProvider );
2042
 
                                        break;
2043
 
 
2044
 
                                case Syntax.SByte:
2045
 
                                        output = ( ( sbyte )GetValue() ).ToString( ifProvider );
2046
 
                                        break;
2047
 
 
2048
 
                                case Syntax.Byte:
2049
 
                                        output = ( ( byte )GetValue() ).ToString( ifProvider );
2050
 
                                        break;
2051
 
 
2052
 
                                case Syntax.Int16:
2053
 
                                        output = ( ( short )GetValue() ).ToString( ifProvider );
2054
 
                                        break;
2055
 
 
2056
 
                                case Syntax.UInt16:
2057
 
                                        output = ( ( ushort )GetValue() ).ToString( ifProvider );
2058
 
                                        break;
2059
 
 
2060
 
                                case Syntax.Int32:
2061
 
                                        output = ( ( int )GetValue() ).ToString( ifProvider );
2062
 
                                        break;
2063
 
 
2064
 
                                case Syntax.UInt32:
2065
 
                                        output = ( ( uint )GetValue() ).ToString( ifProvider );
2066
 
                                        break;
2067
 
 
2068
 
                                case Syntax.Int64:
2069
 
                                        output = ( ( long )GetValue() ).ToString( ifProvider );
2070
 
                                        break;
2071
 
 
2072
 
                                case Syntax.UInt64:
2073
 
                                        output = ( ( ulong )GetValue() ).ToString( ifProvider );
2074
 
                                        break;
2075
 
 
2076
 
                                case Syntax.Char:
2077
 
                                        output = ( ( char )GetValue() ).ToString( ifProvider );
2078
 
                                        break;
2079
 
                                
2080
 
                                case Syntax.Single:
2081
 
                                        output = ( ( float )GetValue() ).ToString( ifProvider );
2082
 
                                        break;
2083
 
 
2084
 
                                case Syntax.Boolean:
2085
 
                                        output = ( ( bool )GetValue() ).ToString( ifProvider );
2086
 
                                        break;
2087
 
 
2088
 
                                case Syntax.DateTime:
2089
 
                                        output = ( ( DateTime )GetValue() ).ToString( ifProvider );
2090
 
                                        break;
2091
 
 
2092
 
                                default:
2093
 
                                        throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );
2094
 
                        }
2095
 
 
2096
 
                        return output;
2097
 
                }
2098
 
 
2099
 
                /// <summary>
2100
 
                /// Converts the property value of this instance to its equivalent string using the specified format.
2101
 
                /// </summary>
2102
 
                /// <param name="format">A string that specifies the return format.</param>
2103
 
                /// <returns>A string representing the value of this object.</returns>
2104
 
                public string ToString( string format )
2105
 
                {
2106
 
                        string output = null;
2107
 
 
2108
 
                        switch ( Type )
2109
 
                        {
2110
 
                                case Syntax.SByte:
2111
 
                                        output = ( ( sbyte )GetValue() ).ToString( format );
2112
 
                                        break;
2113
 
 
2114
 
                                case Syntax.Byte:
2115
 
                                        output = ( ( byte )GetValue() ).ToString( format );
2116
 
                                        break;
2117
 
 
2118
 
                                case Syntax.Int16:
2119
 
                                        output = ( ( short )GetValue() ).ToString( format );
2120
 
                                        break;
2121
 
 
2122
 
                                case Syntax.UInt16:
2123
 
                                        output = ( ( ushort )GetValue() ).ToString( format );
2124
 
                                        break;
2125
 
 
2126
 
                                case Syntax.Int32:
2127
 
                                        output = ( ( int )GetValue() ).ToString( format );
2128
 
                                        break;
2129
 
 
2130
 
                                case Syntax.UInt32:
2131
 
                                        output = ( ( uint )GetValue() ).ToString( format );
2132
 
                                        break;
2133
 
 
2134
 
                                case Syntax.Int64:
2135
 
                                        output = ( ( long )GetValue() ).ToString( format );
2136
 
                                        break;
2137
 
 
2138
 
                                case Syntax.UInt64:
2139
 
                                        output = ( ( ulong )GetValue() ).ToString( format );
2140
 
                                        break;
2141
 
 
2142
 
                                case Syntax.Single:
2143
 
                                        output = ( ( float )GetValue() ).ToString( format );
2144
 
                                        break;
2145
 
 
2146
 
                                case Syntax.DateTime:
2147
 
                                        output = ( ( DateTime )GetValue() ).ToString( format );
2148
 
                                        break;
2149
 
 
2150
 
                                default:
2151
 
                                        throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );
2152
 
                        }
2153
 
 
2154
 
                        return output;
2155
 
                }
2156
 
 
2157
 
                /// <summary>
2158
 
                /// Converts the numeric value of this instance to its equivalent string using the specified
2159
 
                /// format and culture-specific format information.
2160
 
                /// </summary>
2161
 
                /// <param name="format">A string that specifies the return format.</param>
2162
 
                /// <param name="ifProvider">An IFormatProvider that supplies culture-specific formatting information.</param>
2163
 
                /// <returns>A string representing the value of this object.</returns>
2164
 
                public string ToString( string format, IFormatProvider ifProvider )
2165
 
                {
2166
 
                        string output = null;
2167
 
 
2168
 
                        switch ( Type )
2169
 
                        {
2170
 
                                case Syntax.SByte:
2171
 
                                        output = ( ( sbyte )GetValue() ).ToString( format, ifProvider );
2172
 
                                        break;
2173
 
 
2174
 
                                case Syntax.Byte:
2175
 
                                        output = ( ( byte )GetValue() ).ToString( format, ifProvider );
2176
 
                                        break;
2177
 
 
2178
 
                                case Syntax.Int16:
2179
 
                                        output = ( ( short )GetValue() ).ToString( format, ifProvider );
2180
 
                                        break;
2181
 
 
2182
 
                                case Syntax.UInt16:
2183
 
                                        output = ( ( ushort )GetValue() ).ToString( format, ifProvider );
2184
 
                                        break;
2185
 
 
2186
 
                                case Syntax.Int32:
2187
 
                                        output = ( ( int )GetValue() ).ToString( format, ifProvider );
2188
 
                                        break;
2189
 
 
2190
 
                                case Syntax.UInt32:
2191
 
                                        output = ( ( uint )GetValue() ).ToString( format, ifProvider );
2192
 
                                        break;
2193
 
 
2194
 
                                case Syntax.Int64:
2195
 
                                        output = ( ( long )GetValue() ).ToString( format, ifProvider );
2196
 
                                        break;
2197
 
 
2198
 
                                case Syntax.UInt64:
2199
 
                                        output = ( ( ulong )GetValue() ).ToString( format, ifProvider );
2200
 
                                        break;
2201
 
 
2202
 
                                case Syntax.Single:
2203
 
                                        output = ( ( float )GetValue() ).ToString( format, ifProvider );
2204
 
                                        break;
2205
 
 
2206
 
                                case Syntax.DateTime:
2207
 
                                        output = ( ( DateTime )GetValue() ).ToString( format, ifProvider );
2208
 
                                        break;
2209
 
 
2210
 
                                default:
2211
 
                                        throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );
2212
 
                        }
2213
 
 
2214
 
                        return output;
2215
 
                }
2216
 
                #endregion
2217
 
        }
2218
 
}