public void MakePersistent()
 {
     ThrowErrorIfNotTransient();
     previous = new EntityOid(metamodel, TypeName, Key)
     {
         IsTransient = IsTransient
     };
     IsTransient = false;
     CacheState();
 }
 public void MakePersistentAndUpdateKey(object[] newKey)
 {
     ThrowErrorIfNotTransient(newKey);
     previous = new EntityOid(metamodel, TypeName, Key)
     {
         IsTransient = IsTransient
     };
     Key         = newKey; // after old key is saved !
     IsTransient = false;
     CacheState();
 }
        public EntityOid(IMetamodelManager metamodel, string[] strings)
        {
            Assert.AssertNotNull(metamodel);
            this.metamodel = metamodel;
            var helper = new StringDecoderHelper(metamodel, strings);

            TypeName    = helper.GetNextString();
            Key         = helper.GetNextObjectArray();
            IsTransient = helper.GetNextBool();
            EntityKey   = (EntityKey)helper.GetNextSerializable();

            if (helper.HasNext)
            {
                bool hasPrevious = helper.GetNextBool();
                if (hasPrevious)
                {
                    previous = (EntityOid)helper.GetNextEncodedToStrings();
                }
            }
            CacheState();
        }
        public EntityOid(IMetamodelManager metamodel, ILoggerFactory loggerFactory, string[] strings)
        {
            this.metamodel = metamodel ?? throw new InitialisationException($"{nameof(metamodel)} is null");
            logger         = loggerFactory.CreateLogger <EntityOid>();
            var helper = new StringDecoderHelper(metamodel, loggerFactory, loggerFactory.CreateLogger <StringDecoderHelper>(), strings);

            TypeName    = helper.GetNextString();
            Key         = helper.GetNextObjectArray();
            IsTransient = helper.GetNextBool();
            EntityKey   = (EntityKey)helper.GetNextSerializable();

            if (helper.HasNext)
            {
                var hasPrevious = helper.GetNextBool();
                if (hasPrevious)
                {
                    previous = (EntityOid)helper.GetNextEncodedToStrings();
                }
            }

            CacheState();
        }
 public void MakePersistentAndUpdateKey(object[] newKey) {
     ThrowErrorIfNotTransient(newKey);
     previous = new EntityOid(metamodel, TypeName, Key) {IsTransient = IsTransient};
     Key = newKey; // after old key is saved ! 
     IsTransient = false;
     CacheState();
 }
 public void MakePersistent() {
     ThrowErrorIfNotTransient();
     previous = new EntityOid(metamodel, TypeName, Key) {IsTransient = IsTransient};
     IsTransient = false;
     CacheState();
 }
        public EntityOid(IMetamodelManager metamodel, string[] strings) {
            Assert.AssertNotNull(metamodel);
            this.metamodel = metamodel;
            var helper = new StringDecoderHelper(metamodel, strings);

            TypeName = helper.GetNextString();
            Key = helper.GetNextObjectArray();
            IsTransient = helper.GetNextBool();
            EntityKey = (EntityKey) helper.GetNextSerializable();

            if (helper.HasNext) {
                bool hasPrevious = helper.GetNextBool();
                if (hasPrevious) {
                    previous = (EntityOid) helper.GetNextEncodedToStrings();
                }
            }
            CacheState();
        }
 public IOid CreateTransientOid(object obj) {
     var oid = new EntityOid(metamodel, obj.GetType(), new object[] {++transientId}, true);
     Log.DebugFormat("Created OID {0} for instance of {1}", oid, obj.GetType().FullName);
     return oid;
 }