示例#1
0
 private static bool HasIdChanged(M modl)
 {
     if (!Definitions.HasAutomaticId && Definitions.HasIdProperty)
     {
         var id = Definitions.IdProperty.GetValue(modl);
         return(IdConverter.HasValue(id) && modl.Modl.Id != id);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        private static Identity GetId(M modl)
        {
            if (!Definitions.HasAutomaticId && Definitions.HasIdProperty)
            {
                var id = Definitions.IdProperty.GetValue(modl);
                if (IdConverter.HasValue(id))
                {
                    return(Identity.FromId(id, Definitions));
                }
            }

            return(Identity.GenerateNewId(Definitions));
        }
示例#3
0
        internal void ChangeId(Identity newId)
        {
            if (!Backer.IsNew)
            {
                throw new InvalidIdException("Can't change id of a Modl that is not new");
            }

            if (!IdConverter.HasValue(newId.Get()))
            {
                throw new InvalidIdException("Can't change to an empty id");
            }

            this.Id = newId;

            WriteNewModlDataToAllInstances();
            WriteIdToAllInstances();
        }