bool IRemotingTypeInfo.CanCastTo(System.Type targetType, object o) { // Console.WriteLine ("CanCastTo: " + targetType); // if this is a local servant, check it directly if (_realObject != null) { return(targetType.IsInstanceOfType(_realObject)); } // check if the thing was created with a valid type if (targetType.IsInstanceOfType(o)) { return(true); } // otherwise, perform the remote query if necessary string icename = IceUtil.TypeToIceName(targetType); if (_typeIds == null) { Ice.Object iob = o as Ice.Object; _typeIds = iob.ice_ids(); } return(((IList)_typeIds).Contains(icename)); }
public bool ice_isA(string name) { Type t = this.GetType(); Type o = IceUtil.IceNameToType(name); return(t == o || t.IsSubclassOf(o)); }
public string[] ice_ids() { ArrayList typenames = new ArrayList(); Type t = this.GetType(); while (t != typeof(Ice.Object)) { typenames.Add(IceUtil.TypeToIceName(t)); t = t.BaseType; } typenames.Add("::Ice::Object"); // blah. return((string[])typenames.ToArray(typeof(string))); }
public string ice_id() { return(IceUtil.TypeToIceName(this.GetType())); }
public object ReadSlice(object inst) { string sliceName = ReadSliceName(); int sliceDataSize = ReadInt32(); sliceDataSize -= 4; // size includes the 4 bytes of the size itself Type sliceType = IceUtil.IceNameToType(sliceName); if (sliceType == null) { // this means we have no local definition of this slice; // we keep going. Eventually we will hit an Ice.Object, // which is the terminating condition of this recursion, // since we know we have Ice.Object defined. ReadBytes(sliceDataSize); return(ReadSlice(inst)); } if (inst == null) { // if it's null, it has yet to be created, and this is // the first (i.e. most derived) slice that we // understand. inst = Activator.CreateInstance(sliceType); } MethodInfo unmarshal = sliceType.GetMethod("ice_unmarshal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); if (unmarshal != null) { object[] args = new object[1]; args[0] = this; try { unmarshal.Invoke(inst, args); } catch (TargetInvocationException te) { throw te.InnerException; } } else { FieldInfo[] fields = sliceType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly); foreach (FieldInfo field in fields) { if (IceChannelUtils.IceByValue(field.FieldType)) { object elem = ReadObject(field.FieldType); field.SetValue(inst, elem); } else { // this is a class type int r = ReadClassInstanceRef(); if (r == 0) { field.SetValue(inst, null); } else { _instancePatchList.Add(new FieldPatchInfo(r, inst, field)); } } } } if (sliceType == typeof(Ice.Object)) { return(inst); } else { return(ReadSlice(inst)); } }