1
/****************************************************************************
3
| Copyright (c) 2007 Novell, Inc.
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.
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.
15
| You should have received a copy of the GNU General Public License
16
| along with this program; if not, contact Novell, Inc.
18
| To contact Novell about this file by physical or electronic mail,
19
| you may find current contact information at www.novell.com
21
| Author: Mike Lasky <mlasky@novell.com>
22
|***************************************************************************/
26
using System.Collections;
29
namespace Simias.Storage
32
/// Defines a relationship between Node objects.
34
public class Relationship
38
/// Well known identifier that represents the root directory relationship in a dirNode.
40
private const string RootID = "a9d9a742-fd42-492c-a7f2-4ec4f023c625";
43
/// Collection that reference belongs to.
45
private string collectionID;
48
/// Node object that is the reference.
50
private string nodeID;
55
/// Gets the Collection identifier for the relationship.
57
public string CollectionID
59
get { return collectionID; }
63
/// Gets whether this object is the root relationship.
67
get { return ( nodeID == RootID ) ? true : false; }
71
/// Gets the Node identifier for the relationship.
75
get { return nodeID; }
81
/// Constructor for the Relationship object that creates a root relationship object.
83
/// <param name="collection">Collection for the relationship.</param>
84
public Relationship( Collection collection ) :
85
this ( collection.ID, null )
90
/// Constructor for the Relationship object.
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 )
97
this.collectionID = collectionID.ToLower();
98
this.nodeID = ( nodeID != null ) ? nodeID.ToLower() : RootID;
102
/// Constructs the Relationship object from its internal representation.
104
/// <param name="relationString">Internal representation of relationship.</param>
105
internal Relationship( string relationString )
107
int index = relationString.IndexOf( ':' );
110
throw new CollectionStoreException( String.Format( "Invalid relationship format: {0}.", relationString ) );
113
nodeID = relationString.Substring( 0, index );
114
collectionID = relationString.Substring( index + 1 );
118
#region Internal Methods
120
/// Returns internal representation of relationship.
122
/// <returns>A string containing the internal representation of the relationship.</returns>
123
internal new string ToString()
125
return nodeID + ":" + collectionID;
131
/// Represents a property name/value pair for a node. Properties have
132
/// well-defined syntax types.
134
public class Property
136
#region Class Members
138
/// Property operations that are recorded so properties can be merged at object commit time.
140
internal enum Operation
143
/// No operation or change.
148
/// New property value added.
153
/// Property value was deleted.
158
/// Property value was modified.
163
/// The name of the Node object was changed.
169
/// Types of flags that are defined on the property.
171
internal const uint Hidden = 0x00010000;
172
internal const uint Local = 0x00020000;
173
internal const uint MultiValued = 0x00040000;
176
/// Mask used to get just the system flags.
178
private const uint SystemFlagMask = 0xFFFF0000;
181
/// This XmlElement contains all the information about the property.
183
private XmlElement xmlProperty;
186
/// The property list where this property is stored.
188
private PropertyList propertyList = null;
191
/// Member used to keep track of property additions, deletions and modifications.
193
private Operation operation = Operation.None;
196
/// Member used to store the old value of the property, if it was modified.
198
private string oldValue = null;
201
/// Member used to indicate if the oldFlags value contains a changed value.
203
private bool flagsModified = false;
206
/// Member used to store the old flag value, if it was modified.
208
private uint oldFlags = 0;
213
/// Gets or sets a string representation of the property value.
215
internal string ValueString
217
get { return ( Type == Syntax.XmlDocument ) ? xmlProperty.InnerXml : xmlProperty.InnerText; }
220
if ( Type == Syntax.XmlDocument )
222
xmlProperty.InnerXml = value;
226
xmlProperty.InnerText = value;
232
/// Gets a search string representation of the property value.
234
internal string SearchString
236
get { return xmlProperty.InnerXml; }
240
/// Gets the owning document for this xml node.
242
internal XmlDocument OwnerDocument
244
get { return xmlProperty.OwnerDocument; }
248
/// Allows the corresponding XML element to be set into the object when this property
249
/// has been added to the property list.
251
internal XmlElement XmlProperty
253
get { return xmlProperty; }
254
set { xmlProperty = value; }
258
/// Allows the property list to be set into the object when this property has been
259
/// added to the property list.
261
internal PropertyList XmlPropertyList
263
get { return propertyList; }
264
set { propertyList = value; }
268
/// Gets and sets the hidden status of a property.
270
internal bool HiddenProperty
272
get { return ( PropertyFlags & Hidden ) == Hidden ? true : false; }
278
PropertyFlags |= Hidden;
282
PropertyFlags &= ~Hidden;
288
/// Gets and sets all of the flags for the property object.
290
internal uint PropertyFlags
294
// Check to see if this property contains any flags.
295
uint propertyFlags = 0;
296
if ( xmlProperty.HasAttribute( XmlTags.FlagsAttr ) )
298
propertyFlags = Convert.ToUInt32( xmlProperty.GetAttribute( XmlTags.FlagsAttr ) );
301
return propertyFlags;
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 );
314
/// Gets the name of this property.
318
get { return xmlProperty.GetAttribute( XmlTags.NameAttr ); }
322
/// Gets and sets the syntax type of this property.
326
get { return ( Syntax )Enum.Parse( typeof( Syntax ), xmlProperty.GetAttribute( XmlTags.TypeAttr ) ); }
330
/// Gets and sets the flags for this property.
334
get { return ( ushort )PropertyFlags; }
335
set { PropertyFlags = ( PropertyFlags & SystemFlagMask ) | ( uint )value; }
339
/// Gets and sets the value of this property as an object.
343
get { return GetValue(); }
344
set { SetValue( value ); }
348
/// Gets whether this property is associated with a node or if it is a new property object.
350
public bool IsAssociatedProperty
352
get { return ( propertyList == null ) ? false : true; }
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.
360
public bool LocalProperty
362
get { return ( PropertyFlags & Local ) == Local ? true : false; }
368
PropertyFlags |= Local;
372
PropertyFlags &= ~Local;
378
/// Gets and sets the multivalued status of a property.
380
public bool MultiValuedProperty
382
get { return ( PropertyFlags & MultiValued ) == MultiValued ? true : false; }
388
PropertyFlags |= MultiValued;
392
PropertyFlags &= ~MultiValued;
400
/// Constructor used by the PropertyList.IEnumerable interface to create property objects.
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 )
406
this.propertyList = propertyList;
407
this.xmlProperty = xmlProperty;
411
/// Constructs a property object.
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 )
418
XmlDocument propDoc = new XmlDocument();
419
xmlProperty = propDoc.CreateElement( XmlTags.PropertyTag );
421
xmlProperty.SetAttribute( XmlTags.NameAttr, name );
422
xmlProperty.SetAttribute( XmlTags.TypeAttr, syntax.ToString() );
423
ValueString = propertyValue;
427
/// Constructs a property.
429
/// <param name="property">PropertyTags.</param>
430
public Property( Property property )
432
XmlDocument propDoc = new XmlDocument();
433
xmlProperty = ( XmlElement )propDoc.ImportNode( property.xmlProperty, true );
434
propDoc.AppendChild( xmlProperty );
438
/// Constructs a property.
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 )
444
Syntax syntax = GetSyntaxType( propertyValue );
446
XmlDocument propDoc = new XmlDocument();
447
xmlProperty = propDoc.CreateElement( XmlTags.PropertyTag );
448
xmlProperty.SetAttribute( XmlTags.NameAttr, name );
449
xmlProperty.SetAttribute( XmlTags.TypeAttr, syntax.ToString() );
451
ValueString = GetValueFromPropertyObject( syntax, propertyValue );
455
/// Constructs a property
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 )
465
/// Constructs a property.
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() )
475
/// Constructs a property.
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() )
485
/// Constructs a property.
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() )
495
/// Constructs a property.
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() )
505
/// Constructs a property.
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() )
515
/// Constructs a property.
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() )
525
/// Constructs a property.
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() )
535
/// Constructs a property.
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() )
545
/// Constructs a property.
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() )
555
/// Constructs a property.
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() )
565
/// Constructs a property.
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" )
575
/// Constructs a property.
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() )
585
/// Constructs a property.
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() )
595
/// Constructs a property.
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 )
605
/// Constructs a property.
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() )
615
/// Constructs a property.
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() )
625
#region Private Methods
627
/// Returns an object containing the value of this property.
629
/// <returns>An object that contains the value of the property.</returns>
630
private object GetValue()
632
object propertyValue;
634
// Based on the syntax type, create an object and stuff in the property value.
638
propertyValue = xmlProperty.InnerText;
642
propertyValue = SByte.Parse( xmlProperty.InnerText );
646
propertyValue = Byte.Parse( xmlProperty.InnerText );
650
propertyValue = Int16.Parse( xmlProperty.InnerText );
654
propertyValue = UInt16.Parse( xmlProperty.InnerText );
658
propertyValue = Int32.Parse( xmlProperty.InnerText );
662
propertyValue = UInt32.Parse( xmlProperty.InnerText );
666
propertyValue = Int64.Parse( xmlProperty.InnerText );
670
propertyValue = UInt64.Parse( xmlProperty.InnerText );
674
propertyValue = ( Char )UInt16.Parse( xmlProperty.InnerText );
678
propertyValue = Single.Parse( xmlProperty.InnerText );
682
propertyValue = Boolean.Parse( ( xmlProperty.InnerText == "0" ) ? Boolean.FalseString : Boolean.TrueString );
685
case Syntax.DateTime:
686
long timeValue = Int64.Parse( xmlProperty.InnerText );
687
propertyValue = new DateTime( timeValue );
691
propertyValue = new Uri( xmlProperty.InnerText );
694
case Syntax.XmlDocument:
695
propertyValue = new XmlDocument();
696
( ( XmlDocument )propertyValue ).LoadXml( xmlProperty.InnerXml );
699
case Syntax.TimeSpan:
700
long tickValue = Int64.Parse( xmlProperty.InnerText );
701
propertyValue = new TimeSpan( tickValue );
704
case Syntax.Relationship:
705
propertyValue = new Relationship( xmlProperty.InnerText );
709
throw new SyntaxException( Type );
712
return propertyValue;
716
/// Returns a string value representing the property value.
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 )
725
// Convert the propertyValue object type to a supported property syntax type.
729
valueString = ( String )propertyValue;
733
valueString = ( ( SByte )propertyValue ).ToString();
737
valueString = ( ( Byte )propertyValue ).ToString();
741
valueString = ( ( Int16 )propertyValue ).ToString();
745
valueString = ( ( UInt16 )propertyValue ).ToString();
749
valueString = ( ( Int32 )propertyValue ).ToString();
753
valueString = ( ( UInt32 )propertyValue ).ToString();
757
valueString = ( ( Int64 )propertyValue ).ToString();
761
valueString = ( ( UInt64 )propertyValue ).ToString();
765
valueString = ( ( UInt16 )( ( char )propertyValue )).ToString();
769
valueString = ( ( Single )propertyValue ).ToString();
773
valueString = ( ( Boolean )propertyValue == true ) ? "1" : "0";
776
case Syntax.DateTime:
777
valueString = ( ( DateTime ) propertyValue ).Ticks.ToString();
781
valueString = ( ( Uri )propertyValue ).ToString();
784
case Syntax.XmlDocument:
785
valueString = ( ( XmlDocument )propertyValue ).InnerXml;
788
case Syntax.TimeSpan:
789
valueString = ( ( TimeSpan ) propertyValue ).Ticks.ToString();
792
case Syntax.Relationship:
793
valueString = ( ( Relationship ) propertyValue ).ToString();
797
// There is no top level type that matches this object. Check for an enumerated type.
798
if ( propertyValue.GetType().BaseType.Name == "System.Enum" )
800
valueString = ( ( Int32 )propertyValue ).ToString();
804
throw new SyntaxException( syntax );
813
/// Returns if specified state is valid state to save property merge information.
815
/// <param name="state">Current property state.</param>
816
/// <returns>True if valid state, otherwise false.</returns>
817
private bool ValidSaveMergeInfoState( PropertyList.PropertyListState state )
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;
828
#region Internal Methods
830
/// Restores the old state of the Node object.
832
/// <param name="node">Node object to restore previous state for.</param>
833
internal void AbortMergeInformation( Node node )
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 ) )
839
// Operation is the current state of the property.
843
// Remove the property from the PropertyList object.
846
// Restore its in-memory state.
847
operation = Operation.None;
849
flagsModified = false;
853
case Operation.Delete:
854
// Add the property back to the PropertyList.
855
node.Properties.AddNodeProperty( this );
857
// Restore its in-memory state.
858
operation = Operation.None;
860
flagsModified = false;
864
case Operation.Modify:
865
// Restore its in-memory state.
866
operation = Operation.None;
868
// Has the value changed?
869
if ( oldValue != null )
871
// Set the value back into the property.
872
ValueString = oldValue;
876
// Have the flags changed?
879
PropertyFlags = oldFlags;
880
flagsModified = false;
885
case Operation.NameChange:
886
// Restore the name the Node object.
887
node.BaseName = oldValue;
889
// Restore its in-memory state.
890
operation = Operation.None;
898
/// Applies the merge information contained in this property to the specified node.
900
/// <param name="node">Node to merge property on to.</param>
901
internal void ApplyMergeInformation( Node node )
907
XmlNode xmlNode = node.Properties.PropertyDocument.ImportNode( xmlProperty, true );
908
node.Properties.PropertyRoot.AppendChild( xmlNode );
912
case Operation.Delete:
914
// Get the current value of this property.
915
string currentValue = ValueString;
917
// Find the property that matches the one to delete.
918
MultiValuedList mvlDelete = node.Properties.FindValues( Name, true );
919
foreach ( Property p in mvlDelete )
921
// Does the value match?
922
if ( p.ValueString == currentValue )
924
// Remove all the children of this xml property node and remove this node
926
p.xmlProperty.RemoveAll();
927
p.xmlProperty.ParentNode.RemoveChild( p.xmlProperty );
934
case Operation.Modify:
936
Property modifyProperty = null;
938
// Get the current value of the property.
939
string currentValue = ValueString;
941
// If the value has been modified used the oldValue.
942
string matchValue = ( oldValue != null ) ? oldValue : currentValue;
944
// Find the property that matches the one to modify.
945
MultiValuedList mvlModify = node.Properties.FindValues( Name, true );
946
if ( mvlModify.Count > 1 )
948
// Search through all of the properties to find a match.
949
foreach ( Property p in mvlModify )
951
// Are the values equal?
952
if ( p.ValueString == matchValue )
954
// Set the new value.
955
p.ValueString = currentValue;
957
// If the flags have changed, update the flags.
960
p.xmlProperty.SetAttribute( XmlTags.FlagsAttr, PropertyFlags.ToString() );
968
// Check if a match was found.
969
if ( modifyProperty == null )
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 );
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 )
984
// Get the single property and see if either is marked as multivalued.
985
modifyProperty = mvlModify[ 0 ];
988
if ( ( modifyProperty.ValueString != matchValue ) && ( modifyProperty.MultiValuedProperty || MultiValuedProperty ) )
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 );
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;
1000
// If the flags have changed, update the flags.
1001
if ( flagsModified )
1003
modifyProperty.xmlProperty.SetAttribute( XmlTags.FlagsAttr, PropertyFlags.ToString() );
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 );
1017
case Operation.NameChange:
1019
// Set the name in the new Node object.
1020
node.BaseName = ValueString;
1027
/// Deletes this property from the property list.
1029
public void DeleteProperty()
1031
// Only delete if the property is attached to a list.
1032
if ( IsAssociatedProperty )
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 ) );
1038
// Save the property merge information before all the pertinent info is destroyed.
1039
SaveMergeInformation( propertyList, Operation.Delete, null, false, 0 );
1041
// Remove all the children of this xml property node.
1042
xmlProperty.RemoveAll();
1044
// Remove this node from its parent.
1045
xmlProperty.ParentNode.RemoveChild( xmlProperty );
1046
xmlProperty = ( XmlElement )tempDoc.FirstChild;
1048
// Setup the now detached property.
1049
propertyList = null;
1054
/// Returns the syntax type from a C# object.
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 )
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" )
1066
syntax = ( Syntax )Enum.Parse( typeof( Syntax ), Enum.GetUnderlyingType( propertyValue.GetType() ).Name );
1070
syntax = ( Syntax )Enum.Parse( typeof( Syntax ), propertyValue.GetType().Name );
1077
/// Saves the old state of the object so it can be merged at object commit time.
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 )
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 ) )
1090
// Operation is the current state of the property.
1091
switch ( operation )
1093
// When the current state is Add the new state should act as follows:
1095
// Add: Illegal state. An added value cannot be added again. The add code will
1096
// report that the new state is Modify.
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.
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.
1104
if ( op == Operation.Delete )
1106
// Set back to pre-add state.
1107
operation = Operation.None;
1108
propertyList.RemoveFromChangeList( this );
1113
// When the current state is Delete the new state should act as follows:
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.
1118
// Delete: Do nothing. Deleting a property that has already been deleted does nothing.
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 )
1125
// Set back to pre-delete state.
1126
operation = Operation.None;
1127
propertyList.RemoveFromChangeList( this );
1132
// When the current state is Modify the new state should act as follows:
1134
// Add: Illegal state. An existing value cannot be added. The add code will report
1135
// that the new state is modify.
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.
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 )
1148
// Set the new state to delete.
1149
operation = Operation.Delete;
1151
// Has the value changed?
1152
if ( oldValue != null )
1154
// Set the value back into the property.
1155
ValueString = oldValue;
1159
// Have the flags changed?
1160
if ( flagsModified )
1162
PropertyFlags = oldFlags;
1163
flagsModified = false;
1167
else if ( op == Operation.Modify )
1169
// Don't ever overwrite a saved old value.
1170
if ( ( oldValue == null ) && ( priorValue != null ) )
1172
oldValue = priorValue;
1175
if ( ( flagsModified == false ) && ( priorFlagsModified == true ) )
1177
oldFlags = priorFlags;
1178
flagsModified = true;
1184
// When the current state is None the new state should act as follows:
1186
// Add: Set the current state to add and add the new property to the mergeList.
1188
// Delete: Set the current state to delete and add the deleted property to the
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.
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 )
1200
if ( priorValue != null )
1202
oldValue = priorValue;
1205
if ( priorFlagsModified )
1207
oldFlags = priorFlags;
1208
flagsModified = true;
1211
else if ( op == Operation.NameChange )
1213
oldValue = priorValue;
1217
propertyList.AddToChangeList( this );
1220
// When the current state is NameChange the new state should act as follows:
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:
1231
/// Sets the value of this property.
1233
/// <param name="propertyValue">Property value to set.</param>
1234
internal void SetPropertyValue( object propertyValue )
1236
// Based on the syntax type, create an object and stuff in the property value.
1237
switch ( GetSyntaxType( propertyValue ) )
1240
SetPropertyValue( ( string )propertyValue );
1244
SetPropertyValue( ( sbyte )propertyValue );
1248
SetPropertyValue( ( byte )propertyValue );
1252
SetPropertyValue( ( short )propertyValue );
1256
SetPropertyValue( ( ushort )propertyValue );
1260
SetPropertyValue( ( int )propertyValue );
1264
SetPropertyValue( ( uint )propertyValue );
1268
SetPropertyValue( ( long )propertyValue );
1272
SetPropertyValue( ( ulong )propertyValue );
1276
SetPropertyValue( ( char )propertyValue );
1280
SetPropertyValue( ( float )propertyValue );
1283
case Syntax.Boolean:
1284
SetPropertyValue( ( bool )propertyValue );
1287
case Syntax.DateTime:
1288
SetPropertyValue( ( DateTime )propertyValue );
1292
SetPropertyValue( ( Uri )propertyValue );
1295
case Syntax.XmlDocument:
1296
SetPropertyValue( ( XmlDocument )propertyValue );
1299
case Syntax.TimeSpan:
1300
SetPropertyValue( ( TimeSpan )propertyValue );
1303
case Syntax.Relationship:
1304
SetPropertyValue( ( Relationship )propertyValue );
1308
throw new CollectionStoreException( new ArgumentException( "Invalid object", "propertyValue" ) );
1313
/// Sets a property value into the property.
1315
/// <param name="propertyValue">Property value to set in property.</param>
1316
internal void SetPropertyValue( Property propertyValue )
1318
if ( Type != propertyValue.Type )
1320
throw new SyntaxException( propertyValue.Type );
1323
// Remember the old value before overwriting it with the new value.
1324
string currentValue = ValueString;
1325
ValueString = propertyValue.ValueString;
1327
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1331
/// Sets a string value into the property.
1333
/// <param name="propertyValue">string value to set in property.</param>
1334
internal void SetPropertyValue( string propertyValue )
1336
if ( Type != Syntax.String )
1338
throw new SyntaxException( Type );
1341
// Remember the old value before overwriting it with the new value.
1342
string currentValue = ValueString;
1343
ValueString = propertyValue;
1345
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1349
/// Sets an sbyte value into the property.
1351
/// <param name="propertyValue">sbyte value to set in property.</param>
1352
internal void SetPropertyValue( sbyte propertyValue )
1354
if ( Type != Syntax.SByte )
1356
throw new SyntaxException( Type );
1359
// Remember the old value before overwriting it with the new value.
1360
string currentValue = ValueString;
1361
ValueString = propertyValue.ToString();
1363
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1367
/// Sets a byte value into the property.
1369
/// <param name="propertyValue">byte value to set in property.</param>
1370
internal void SetPropertyValue( byte propertyValue )
1372
if ( Type != Syntax.Byte )
1374
throw new SyntaxException( Type );
1377
// Remember the old value before overwriting it with the new value.
1378
string currentValue = ValueString;
1379
ValueString = propertyValue.ToString();
1381
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1385
/// Sets a short value into the property.
1387
/// <param name="propertyValue">short value to set in property.</param>
1388
internal void SetPropertyValue( short propertyValue )
1390
if ( Type != Syntax.Int16 )
1392
throw new SyntaxException( Type );
1395
// Remember the old value before overwriting it with the new value.
1396
string currentValue = ValueString;
1397
ValueString = propertyValue.ToString();
1399
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1403
/// Sets a ushort value into the property.
1405
/// <param name="propertyValue">ushort value to set in property.</param>
1406
internal void SetPropertyValue( ushort propertyValue )
1408
if ( Type != Syntax.UInt16 )
1410
throw new SyntaxException( Type );
1413
// Remember the old value before overwriting it with the new value.
1414
string currentValue = ValueString;
1415
ValueString = propertyValue.ToString();
1417
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1421
/// Sets an int value into the property.
1423
/// <param name="propertyValue">int value to set in property.</param>
1424
internal void SetPropertyValue( int propertyValue )
1426
if ( Type != Syntax.Int32 )
1428
throw new SyntaxException( Type );
1431
// Remember the old value before overwriting it with the new value.
1432
string currentValue = ValueString;
1433
ValueString = propertyValue.ToString();
1435
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1439
/// Sets a uint value into the property.
1441
/// <param name="propertyValue">uint value to set in property.</param>
1442
internal void SetPropertyValue( uint propertyValue )
1444
if ( Type != Syntax.UInt32 )
1446
throw new SyntaxException( Type );
1449
// Remember the old value before overwriting it with the new value.
1450
string currentValue = ValueString;
1451
ValueString = propertyValue.ToString();
1453
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1457
/// Sets a long value into the property.
1459
/// <param name="propertyValue">long value to set in property.</param>
1460
internal void SetPropertyValue( long propertyValue )
1462
if ( Type != Syntax.Int64 )
1464
throw new SyntaxException( Type );
1467
// Remember the old value before overwriting it with the new value.
1468
string currentValue = ValueString;
1469
ValueString = propertyValue.ToString();
1471
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1475
/// Sets a ulong value into the property.
1477
/// <param name="propertyValue">ulong value to set in property.</param>
1478
internal void SetPropertyValue( ulong propertyValue )
1480
if ( Type != Syntax.UInt64 )
1482
throw new SyntaxException( Type );
1485
// Remember the old value before overwriting it with the new value.
1486
string currentValue = ValueString;
1487
ValueString = propertyValue.ToString();
1489
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1493
/// Sets a char value into the property.
1495
/// <param name="propertyValue">char value to set in property.</param>
1496
internal void SetPropertyValue( char propertyValue )
1498
if ( Type != Syntax.Char )
1500
throw new SyntaxException( Type );
1503
// Remember the old value before overwriting it with the new value.
1504
string currentValue = ValueString;
1505
ValueString = ( ( ushort )propertyValue ).ToString();
1507
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1511
/// Sets a float value into the property.
1513
/// <param name="propertyValue">float value to set in property.</param>
1514
internal void SetPropertyValue( float propertyValue )
1516
if ( Type != Syntax.Single )
1518
throw new SyntaxException( Type );
1521
// Remember the old value before overwriting it with the new value.
1522
string currentValue = ValueString;
1523
ValueString = propertyValue.ToString();
1525
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1529
/// Sets a bool value into the property.
1531
/// <param name="propertyValue">bool value to set in property.</param>
1532
internal void SetPropertyValue( bool propertyValue )
1534
if ( Type != Syntax.Boolean )
1536
throw new SyntaxException( Type );
1539
// Remember the old value before overwriting it with the new value.
1540
string currentValue = ValueString;
1541
ValueString = propertyValue ? "1" : "0";
1543
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1547
/// Sets a DateTime value into the property.
1549
/// <param name="propertyValue">DateTime value to set in property.</param>
1550
internal void SetPropertyValue( DateTime propertyValue )
1552
if ( Type != Syntax.DateTime )
1554
throw new SyntaxException( Type );
1557
// Remember the old value before overwriting it with the new value.
1558
string currentValue = ValueString;
1559
ValueString = propertyValue.Ticks.ToString();
1561
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1565
/// Sets a Uri value into the property.
1567
/// <param name="propertyValue">Uri value to set in property.</param>
1568
internal void SetPropertyValue( Uri propertyValue )
1570
if ( Type != Syntax.Uri )
1572
throw new SyntaxException( Type );
1575
// Remember the old value before overwriting it with the new value.
1576
string currentValue = ValueString;
1577
ValueString = propertyValue.ToString();
1579
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1583
/// Sets an Xml value into the property.
1585
/// <param name="propertyValue">Xml value to set in property.</param>
1586
internal void SetPropertyValue( XmlDocument propertyValue )
1588
if ( Type != Syntax.XmlDocument )
1590
throw new SyntaxException( Type );
1593
// Remember the old value before overwriting it with the new value.
1594
string currentValue = ValueString;
1595
ValueString = propertyValue.InnerXml;
1597
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1601
/// Sets a TimeSpan value into the property.
1603
/// <param name="propertyValue">TimeSpan value to set in property.</param>
1604
internal void SetPropertyValue( TimeSpan propertyValue )
1606
if ( Type != Syntax.TimeSpan )
1608
throw new SyntaxException( Type );
1611
// Remember the old value before overwriting it with the new value.
1612
string currentValue = ValueString;
1613
ValueString = propertyValue.Ticks.ToString();
1615
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1619
/// Sets a Relationship value into the property.
1621
/// <param name="relationship">Relationship value to set in property.</param>
1622
internal void SetPropertyValue( Relationship relationship )
1624
if ( Type != Syntax.Relationship )
1626
throw new SyntaxException( Type );
1629
// Remember the old value before overwriting it with the new value.
1630
string currentValue = ValueString;
1631
ValueString = relationship.ToString();
1633
SaveMergeInformation( propertyList, Operation.Modify, currentValue, false, 0 );
1637
#region Public Methods
1639
/// Deletes this property from the property list.
1641
public void Delete()
1643
// Make sure this is not a system property
1644
if ( IsSystemProperty() )
1646
throw new InvalidOperationException( "Cannot delete a system property" );
1653
/// Determines if the property is a system (non-editable) property.
1655
/// <returns>True if propertyName specifies a system property, otherwise false is returned.</returns>
1656
public bool IsSystemProperty()
1658
return PropertyTags.IsSystemProperty( xmlProperty.GetAttribute( XmlTags.NameAttr ) );
1662
/// Sets the value of this property.
1664
/// <param name="propertyValue">Property value to set.</param>
1665
public void SetValue( Property propertyValue )
1667
// Make sure this is not a system property
1668
if ( IsSystemProperty() )
1670
throw new InvalidOperationException( "Cannot modify a system property" );
1673
SetPropertyValue( propertyValue );
1677
/// Sets the value of this property.
1679
/// <param name="propertyValue">Property value to set.</param>
1680
public void SetValue( object propertyValue )
1682
// Make sure this is not a system property
1683
if ( IsSystemProperty() )
1685
throw new InvalidOperationException( "Cannot modify a system property" );
1688
SetPropertyValue( propertyValue );
1692
/// Sets a string value into the property.
1694
/// <param name="propertyValue">string value to set in property.</param>
1695
public void SetValue( string propertyValue )
1697
// Make sure this is not a system property
1698
if ( IsSystemProperty() )
1700
throw new InvalidOperationException( "Cannot modify a system property" );
1703
SetPropertyValue( propertyValue );
1707
/// Sets an sbyte value into the property.
1709
/// <param name="propertyValue">sbyte value to set in property.</param>
1710
public void SetValue( sbyte propertyValue )
1712
// Make sure this is not a system property
1713
if ( IsSystemProperty() )
1715
throw new InvalidOperationException( "Cannot modify a system property" );
1718
SetPropertyValue( propertyValue );
1722
/// Sets a byte value into the property.
1724
/// <param name="propertyValue">byte value to set in property.</param>
1725
public void SetValue( byte propertyValue )
1727
// Make sure this is not a system property
1728
if ( IsSystemProperty() )
1730
throw new InvalidOperationException( "Cannot modify a system property" );
1733
SetPropertyValue( propertyValue );
1737
/// Sets a short value into the property.
1739
/// <param name="propertyValue">short value to set in property.</param>
1740
public void SetValue( short propertyValue )
1742
// Make sure this is not a system property
1743
if ( IsSystemProperty() )
1745
throw new InvalidOperationException( "Cannot modify a system property" );
1748
SetPropertyValue( propertyValue );
1752
/// Sets a ushort value into the property.
1754
/// <param name="propertyValue">ushort value to set in property.</param>
1755
public void SetValue( ushort propertyValue )
1757
// Make sure this is not a system property
1758
if ( IsSystemProperty() )
1760
throw new InvalidOperationException( "Cannot modify a system property" );
1763
SetPropertyValue( propertyValue );
1767
/// Sets an int value into the property.
1769
/// <param name="propertyValue">int value to set in property.</param>
1770
public void SetValue( int propertyValue )
1772
// Make sure this is not a system property
1773
if ( IsSystemProperty() )
1775
throw new InvalidOperationException( "Cannot modify a system property" );
1778
SetPropertyValue( propertyValue );
1782
/// Sets a uint value into the property.
1784
/// <param name="propertyValue">uint value to set in property.</param>
1785
public void SetValue( uint propertyValue )
1787
// Make sure this is not a system property
1788
if ( IsSystemProperty() )
1790
throw new InvalidOperationException( "Cannot modify a system property" );
1793
SetPropertyValue( propertyValue );
1797
/// Sets a long value into the property.
1799
/// <param name="propertyValue">long value to set in property.</param>
1800
public void SetValue( long propertyValue )
1802
// Make sure this is not a system property
1803
if ( IsSystemProperty() )
1805
throw new InvalidOperationException( "Cannot modify a system property" );
1808
SetPropertyValue( propertyValue );
1812
/// Sets a ulong value into the property.
1814
/// <param name="propertyValue">ulong value to set in property.</param>
1815
public void SetValue( ulong propertyValue )
1817
// Make sure this is not a system property
1818
if ( IsSystemProperty() )
1820
throw new InvalidOperationException( "Cannot modify a system property" );
1823
SetPropertyValue( propertyValue );
1827
/// Sets a char value into the property.
1829
/// <param name="propertyValue">char value to set in property.</param>
1830
public void SetValue( char propertyValue )
1832
// Make sure this is not a system property
1833
if ( IsSystemProperty() )
1835
throw new InvalidOperationException( "Cannot modify a system property" );
1838
SetPropertyValue( propertyValue );
1842
/// Sets a float value into the property.
1844
/// <param name="propertyValue">float value to set in property.</param>
1845
public void SetValue( float propertyValue )
1847
// Make sure this is not a system property
1848
if ( IsSystemProperty() )
1850
throw new InvalidOperationException( "Cannot modify a system property" );
1853
SetPropertyValue( propertyValue );
1857
/// Sets a bool value into the property.
1859
/// <param name="propertyValue">bool value to set in property.</param>
1860
public void SetValue( bool propertyValue )
1862
// Make sure this is not a system property
1863
if ( IsSystemProperty() )
1865
throw new InvalidOperationException( "Cannot modify a system property" );
1868
SetPropertyValue( propertyValue );
1872
/// Sets a DateTime value into the property.
1874
/// <param name="propertyValue">DateTime value to set in property.</param>
1875
public void SetValue( DateTime propertyValue )
1877
// Make sure this is not a system property
1878
if ( IsSystemProperty() )
1880
throw new InvalidOperationException( "Cannot modify a system property" );
1883
SetPropertyValue( propertyValue );
1887
/// Sets a Uri value into the property.
1889
/// <param name="propertyValue">Uri value to set in property.</param>
1890
public void SetValue( Uri propertyValue )
1892
// Make sure this is not a system property
1893
if ( IsSystemProperty() )
1895
throw new InvalidOperationException( "Cannot modify a system property" );
1898
SetPropertyValue( propertyValue );
1902
/// Sets an Xml value into the property.
1904
/// <param name="propertyValue">Xml value to set in property.</param>
1905
public void SetValue( XmlDocument propertyValue )
1907
// Make sure this is not a system property
1908
if ( IsSystemProperty() )
1910
throw new InvalidOperationException( "Cannot modify a system property" );
1913
SetPropertyValue( propertyValue );
1917
/// Sets a TimeSpan value into the property.
1919
/// <param name="propertyValue">TimeSpan value to set in property.</param>
1920
public void SetValue( TimeSpan propertyValue )
1922
// Make sure this is not a system property
1923
if ( IsSystemProperty() )
1925
throw new InvalidOperationException( "Cannot modify a system property" );
1928
SetPropertyValue( propertyValue );
1932
/// Sets a Relationship value into the property.
1934
/// <param name="propertyValue">Relationship value to set in property.</param>
1935
public void SetValue( Relationship propertyValue )
1937
// Make sure this is not a system property
1938
if ( IsSystemProperty() )
1940
throw new InvalidOperationException( "Cannot modify a system property" );
1943
SetPropertyValue( propertyValue );
1947
/// Converts the property value of this instance to its equivalent string.
1949
/// <returns>A string representing the value of this object.</returns>
1950
public override string ToString()
1952
string output = null;
1957
output = ( ( string )GetValue() ).ToString();
1961
output = ( ( sbyte )GetValue() ).ToString();
1965
output = ( ( byte )GetValue() ).ToString();
1969
output = ( ( short )GetValue() ).ToString();
1973
output = ( ( ushort )GetValue() ).ToString();
1977
output = ( ( int )GetValue() ).ToString();
1981
output = ( ( uint )GetValue() ).ToString();
1985
output = ( ( long )GetValue() ).ToString();
1989
output = ( ( ulong )GetValue() ).ToString();
1993
output = ( ( char )GetValue() ).ToString();
1997
output = ( ( float )GetValue() ).ToString();
2000
case Syntax.Boolean:
2001
output = ( ( bool )GetValue() ).ToString();
2004
case Syntax.DateTime:
2005
output = ( ( DateTime )GetValue() ).ToString();
2009
output = ( ( Uri )GetValue() ).ToString();
2012
case Syntax.XmlDocument:
2013
output = ( ( XmlDocument )GetValue() ).ToString();
2016
case Syntax.TimeSpan:
2017
output = ( ( TimeSpan )GetValue() ).ToString();
2020
case Syntax.Relationship:
2021
output = ( ( Relationship )GetValue() ).ToString();
2029
/// Converts the property value of this instance to its equivalent string using the specified
2030
/// culture-specific format information.
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 )
2036
string output = null;
2041
output = ( ( string )GetValue() ).ToString( ifProvider );
2045
output = ( ( sbyte )GetValue() ).ToString( ifProvider );
2049
output = ( ( byte )GetValue() ).ToString( ifProvider );
2053
output = ( ( short )GetValue() ).ToString( ifProvider );
2057
output = ( ( ushort )GetValue() ).ToString( ifProvider );
2061
output = ( ( int )GetValue() ).ToString( ifProvider );
2065
output = ( ( uint )GetValue() ).ToString( ifProvider );
2069
output = ( ( long )GetValue() ).ToString( ifProvider );
2073
output = ( ( ulong )GetValue() ).ToString( ifProvider );
2077
output = ( ( char )GetValue() ).ToString( ifProvider );
2081
output = ( ( float )GetValue() ).ToString( ifProvider );
2084
case Syntax.Boolean:
2085
output = ( ( bool )GetValue() ).ToString( ifProvider );
2088
case Syntax.DateTime:
2089
output = ( ( DateTime )GetValue() ).ToString( ifProvider );
2093
throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );
2100
/// Converts the property value of this instance to its equivalent string using the specified format.
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 )
2106
string output = null;
2111
output = ( ( sbyte )GetValue() ).ToString( format );
2115
output = ( ( byte )GetValue() ).ToString( format );
2119
output = ( ( short )GetValue() ).ToString( format );
2123
output = ( ( ushort )GetValue() ).ToString( format );
2127
output = ( ( int )GetValue() ).ToString( format );
2131
output = ( ( uint )GetValue() ).ToString( format );
2135
output = ( ( long )GetValue() ).ToString( format );
2139
output = ( ( ulong )GetValue() ).ToString( format );
2143
output = ( ( float )GetValue() ).ToString( format );
2146
case Syntax.DateTime:
2147
output = ( ( DateTime )GetValue() ).ToString( format );
2151
throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );
2158
/// Converts the numeric value of this instance to its equivalent string using the specified
2159
/// format and culture-specific format information.
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 )
2166
string output = null;
2171
output = ( ( sbyte )GetValue() ).ToString( format, ifProvider );
2175
output = ( ( byte )GetValue() ).ToString( format, ifProvider );
2179
output = ( ( short )GetValue() ).ToString( format, ifProvider );
2183
output = ( ( ushort )GetValue() ).ToString( format, ifProvider );
2187
output = ( ( int )GetValue() ).ToString( format, ifProvider );
2191
output = ( ( uint )GetValue() ).ToString( format, ifProvider );
2195
output = ( ( long )GetValue() ).ToString( format, ifProvider );
2199
output = ( ( ulong )GetValue() ).ToString( format, ifProvider );
2203
output = ( ( float )GetValue() ).ToString( format, ifProvider );
2206
case Syntax.DateTime:
2207
output = ( ( DateTime )GetValue() ).ToString( format, ifProvider );
2211
throw new CollectionStoreException( new ArgumentException( "Objects of type " + Type.ToString() + " do not take formatters" ) );