1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 using System; 6 using System.ComponentModel; 7 8 namespace Ice 9 { 10 [Serializable] 11 public abstract class Value : ICloneable 12 { 13 private const string _id = "::Ice::Object"; 14 15 /// <summary> 16 /// Returns the Slice type ID of the interface supported by this object. 17 /// </summary> 18 /// <returns>The return value is always ::Ice::Object.</returns> ice_staticId()19 public static string ice_staticId() 20 { 21 return _id; 22 } 23 24 /// <summary> 25 /// Returns the Slice type ID of the most-derived interface supported by this object. 26 /// </summary> 27 /// <returns>The return value is always ::Ice::Object.</returns> ice_id()28 public virtual string ice_id() 29 { 30 return _id; 31 } 32 33 /// <summary> 34 /// The Ice run time invokes this method prior to marshaling an object's data members. This allows a subclass 35 /// to override this method in order to validate its data members. 36 /// </summary> ice_preMarshal()37 public virtual void ice_preMarshal() 38 { 39 } 40 41 /// <summary> 42 /// This Ice run time invokes this method vafter unmarshaling an object's data members. This allows a 43 /// subclass to override this method in order to perform additional initialization. 44 /// </summary> ice_postUnmarshal()45 public virtual void ice_postUnmarshal() 46 { 47 } 48 49 /// <summary> 50 /// Returns the sliced data if the value has a preserved-slice base class and has been sliced during 51 /// un-marshaling of the value, null is returned otherwise. 52 /// </summary> 53 /// <returns>The sliced data or null.</returns> ice_getSlicedData()54 public virtual SlicedData ice_getSlicedData() 55 { 56 return null; 57 } 58 59 [EditorBrowsable(EditorBrowsableState.Never)] iceWrite(OutputStream ostr)60 public virtual void iceWrite(OutputStream ostr) 61 { 62 ostr.startValue(null); 63 iceWriteImpl(ostr); 64 ostr.endValue(); 65 } 66 67 [EditorBrowsable(EditorBrowsableState.Never)] iceRead(InputStream istr)68 public virtual void iceRead(InputStream istr) 69 { 70 istr.startValue(); 71 iceReadImpl(istr); 72 istr.endValue(false); 73 } 74 75 [EditorBrowsable(EditorBrowsableState.Never)] iceWriteImpl(OutputStream ostr)76 protected virtual void iceWriteImpl(OutputStream ostr) 77 { 78 } 79 80 [EditorBrowsable(EditorBrowsableState.Never)] iceReadImpl(InputStream istr)81 protected virtual void iceReadImpl(InputStream istr) 82 { 83 } 84 85 /// <summary> 86 /// Returns a copy of the object. The cloned object contains field-for-field copies 87 /// of the state. 88 /// </summary> 89 /// <returns>The cloned object.</returns> Clone()90 public object Clone() 91 { 92 return MemberwiseClone(); 93 } 94 } 95 96 public class InterfaceByValue : Value 97 { InterfaceByValue(string id)98 public InterfaceByValue(string id) 99 { 100 _id = id; 101 } 102 ice_id()103 public override string ice_id() 104 { 105 return _id; 106 } 107 108 [EditorBrowsable(EditorBrowsableState.Never)] iceWriteImpl(OutputStream ostr)109 protected override void iceWriteImpl(OutputStream ostr) 110 { 111 ostr.startSlice(ice_id(), -1, true); 112 ostr.endSlice(); 113 } 114 115 [EditorBrowsable(EditorBrowsableState.Never)] iceReadImpl(InputStream istr)116 protected override void iceReadImpl(InputStream istr) 117 { 118 istr.startSlice(); 119 istr.endSlice(); 120 } 121 122 private string _id; 123 } 124 } 125