Ejemplo n.º 1
0
        private void DropReferences(object instance)
        {
            IPersistentObject managed = (IPersistentObject)instance;

            this.uow.Objects.Remove(managed.Id);
            IList     references = managed.GetReferences();
            ArrayList tmp        = new ArrayList(references);

            foreach (ObjectReference reference in tmp)
            {
                if (!IsLoaded(reference.ObjectId))
                {
                    continue;
                }

                IPersistentObject referencedObject = (IPersistentObject)this.Get(reference.ObjectId);
                referencedObject.SetUnloaded(reference.Property, true);
                Type         referencedObjectType = referencedObject.GetType();
                PropertyInfo pi        = referencedObjectType.GetProperty(reference.Property);
                bool         stackMute = referencedObject.Mute;
                referencedObject.Mute = true;
                pi.SetValue(referencedObject, null, null);
                referencedObject.Mute = stackMute;
            }
        }
 /// <summary>
 /// Returns the extension for the given persistent object
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 /// <exception cref="NotSupportedException"></exception>
 public static string GetFileExtension(IPersistentObject obj)
 {
     if (obj is UTinyProject)
     {
         return(ProjectFileExtension);
     }
     if (obj is UTinyModule)
     {
         return(ModuleFileExtension);
     }
     throw new NotSupportedException($"Persitent object of type {obj.GetType()} has no known file extension");
 }
        private void Initialize(IPersistentObject target)
        {
            Type type = target.GetType().BaseType;
            PropertyInfo[] properties = type.GetProperties();
            target.Initializing = true;

            foreach (PropertyInfo property in properties)
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsGenericType && propertyType.IsInterface)
                {
                    InjectInterceptableList(target, property, propertyType);
                }
            }
            target.Initializing = false;
        }
Ejemplo n.º 4
0
        private void Initialize(IPersistentObject target)
        {
            Type type = target.GetType().BaseType;

            PropertyInfo[] properties = type.GetProperties();
            target.Initializing = true;

            foreach (PropertyInfo property in properties)
            {
                Type propertyType = property.PropertyType;

                if (propertyType.IsGenericType && propertyType.IsInterface)
                {
                    InjectInterceptableList(target, property, propertyType);
                }
            }
            target.Initializing = false;
        }
Ejemplo n.º 5
0
        private IPersistentObject UpdateTask(IPersistentObject po)
        {
            Contract.Requires(typeof(Task).IsAssignableFrom(po.GetType()));

            const string MethodName = "UpdateTask";

            CheckObjectAlreadyDisposed();

            Task task = po as Task;

            CheckTask(task);

            if (s_Logger.IsDebugEnabled)
            {
                s_Logger.Debug(string.Format("{0}({1})", MethodName, task));
            }
            return(BaseUpdate(task));
        }
Ejemplo n.º 6
0
        public string Serialize()
        {
            var persistentProperties = new PropertyDictionary();

            foreach (var entry in properties)
            {
                if ((string)entry.Key == "Initializing")
                {
                    continue;
                }

                if ((string)entry.Key == "Mute")
                {
                    continue;
                }

                if ((string)entry.Key == "Context")
                {
                    continue;
                }

                if ((string)entry.Key == "Id")
                {
                    continue;
                }

                persistentProperties.Add(entry.Key, entry.Value);
            }

            SerializedObject so = new SerializedObject();

            so.Data = persistentProperties;
            so.Type = target.GetType().BaseType;

            return(JSONSerializer.Serialize(so));
        }
        public IPersistentObject Delete(IPersistentObject po)
        {
            Contract.Requires(Transaction.Current != null);
            //Contract.Requires(IsOperational);
            Contract.Requires(po != null);
            Contract.Requires(po.PersistenceId.HasValue);

            Contract.Ensures(Contract.Result<IPersistentObject>() != null);
            Contract.Ensures(Contract.Result<IPersistentObject>().GetType() == po.GetType());
            Contract.Ensures(!Contract.Result<IPersistentObject>().PersistenceId.HasValue);

            return default(IPersistentObject);
        }
        private IPersistentObject UpdateTask(IPersistentObject po)
        {
            Contract.Requires(typeof(Task).IsAssignableFrom(po.GetType()));

            const string MethodName = "UpdateTask";

            CheckObjectAlreadyDisposed();

            Task task = po as Task;

            CheckTask(task);

            if (s_Logger.IsDebugEnabled)
            {
                s_Logger.Debug(string.Format("{0}({1})", MethodName, task));
            }
            return BaseUpdate(task);
        }
        public IPersistentObject Delete(IPersistentObject po)
        {
            Contract.Requires(Transaction.Current != null);
            Contract.Requires(Transaction.Current.TransactionInformation.DistributedIdentifier == Guid.Empty);
            //Contract.Requires(IsOperational);
            Contract.Requires(po != null);
            Contract.Requires(po.PersistenceId.HasValue);

            Contract.Ensures(Contract.Result<IPersistentObject>() != null);
            Contract.Ensures(Contract.Result<IPersistentObject>().GetType() == po.GetType());
            Contract.Ensures(!Contract.Result<IPersistentObject>().PersistenceId.HasValue);

            return default(IPersistentObject);
        }