public string GetIdentity(MarshalReference marshalReference, MarshalReferenceValue marshalReferenceValue)
        {
            IClassMap     classMap = Context.DomainMap.MustGetClassMap(marshalReference.Type);
            StringBuilder id       = new StringBuilder();
            string        sep      = classMap.IdentitySeparator;

            if (sep == "")
            {
                sep = "|";
            }
            foreach (IPropertyMap propertyMap in classMap.GetIdentityPropertyMaps())
            {
                if (propertyMap.ReferenceType == ReferenceType.None)
                {
                    MarshalProperty mp = marshalReferenceValue.GetReferenceProperty(propertyMap.Name);
                    id.Append(mp.Value + sep);
                }
                else
                {
                    MarshalReference mr = marshalReferenceValue.GetReferenceReference(propertyMap.Name);
                    id.Append(GetIdentity(mr, marshalReferenceValue) + sep);
                }
            }
            if (id.Length > 0)
            {
                id.Length -= sep.Length;
            }
            return(id.ToString());
        }
        public object ToReferenceValue(object targetObject, string type, MarshalReferenceValue value, MarshalReference mr, IPropertyMap propertyMap)
        {
            IClassMap classMap = Context.DomainMap.MustGetClassMap(type);
            Type      realType = Context.AssemblyManager.MustGetTypeFromClassMap(classMap);
            string    identity = GetIdentity(mr, value);

            return(Context.GetObjectById(identity, realType, true));
        }
        private MarshalReferenceValue FromPropertyReference(object sourceObject, object value, IPropertyMap propertyMap)
        {
            MarshalReferenceValue mrv = new MarshalReferenceValue();

            if (value != null)
            {
                foreach (IPropertyMap idPropertyMap in propertyMap.MustGetReferencedClassMap().GetIdentityPropertyMaps())
                {
                    if (idPropertyMap.ReferenceType == ReferenceType.None)
                    {
                        mrv.ReferenceProperties.Add(FromProperty(value, idPropertyMap));
                    }
                    else
                    {
                        mrv.ReferenceReferences.Add(FromReference(value, idPropertyMap));
                    }
                }
            }
            return(mrv);
        }
 private MarshalReferenceValue FromPropertyReference(object sourceObject, object value, IPropertyMap propertyMap)
 {
     MarshalReferenceValue mrv = new MarshalReferenceValue() ;
     if (value != null)
     {
         foreach (IPropertyMap idPropertyMap in propertyMap.MustGetReferencedClassMap().GetIdentityPropertyMaps())
         {
             if (idPropertyMap.ReferenceType == ReferenceType.None)
             {
                 mrv.ReferenceProperties.Add(FromProperty(value, idPropertyMap)) ;
             }
             else
             {
                 mrv.ReferenceReferences.Add(FromReference(value, idPropertyMap)) ;
             }
         }
     }
     return mrv;
 }
 public object ToReferenceValue(object targetObject, string type, MarshalReferenceValue value, MarshalReference mr, IPropertyMap propertyMap)
 {
     IClassMap classMap = Context.DomainMap.MustGetClassMap(type);
     Type realType = Context.AssemblyManager.MustGetTypeFromClassMap(classMap);
     string identity = GetIdentity(mr, value);
     return Context.GetObjectById(identity, realType, true);
 }
 public string GetIdentity(MarshalReference marshalReference, MarshalReferenceValue marshalReferenceValue)
 {
     IClassMap classMap = Context.DomainMap.MustGetClassMap(marshalReference.Type);
     StringBuilder id = new StringBuilder() ;
     string sep = classMap.IdentitySeparator;
     if (sep == "") { sep = "|"; }
     foreach (IPropertyMap propertyMap in classMap.GetIdentityPropertyMaps())
     {
         if (propertyMap.ReferenceType == ReferenceType.None)
         {
             MarshalProperty mp = marshalReferenceValue.GetReferenceProperty(propertyMap.Name);
             id.Append(mp.Value + sep);
         }
         else
         {
             MarshalReference mr = marshalReferenceValue.GetReferenceReference(propertyMap.Name);
             id.Append(GetIdentity(mr, marshalReferenceValue) + sep);
         }
     }
     if (id.Length > 0) { id.Length -= sep.Length; }
     return id.ToString();
 }