コード例 #1
0
        private object getOrCreatePO(POIdentifier id, Type t)
        {
            //NOTE: use getIdentifier to get the correct id instance, to ensure that the weaktable keeps working
            //TODO: provide factory
            //TODO: Note that objects are not removed from the identity cache after serialization, so are reuse on deserialization!
            //TODO: provide a way to remove objects from the cache?
            object po;

            if (pos.TryGetValue(getIdentifier(id.Guid), out po))
            {
                return(po);
            }
            po = Activator.CreateInstance(t);
            pos.Add(getIdentifier(id.Guid), po);
            ids.Add(po, getIdentifier(id.Guid));
            return(po);
        }
コード例 #2
0
 public static SerializedValue CreateReference(SerializedType serializedType, POIdentifier reference)
 {
     return(new SerializedValue {
         Type = serializedType, ReferenceIdentifier = reference
     });
 }