示例#1
0
        protected virtual void Dispose(bool disposing)
        {
            //System.Diagnostics.Trace.WriteLine("****** Dispose *********");
            //System.Diagnostics.Trace.Write(Environment.StackTrace);
            //System.Diagnostics.Trace.Assert(mEntity != null);
            //System.Diagnostics.Trace.Write(string.Format("{0} is being disposed with disposing = {1} and refcount = {2}", this.ToString(), disposing, mRefCount));

            if (disposing)
            {
                if (mRefCount <= 0)
                {
                    mRefCount = 0;
                    if (mEntity != null)
                    {
                        mEntity.Dispose();
                        mEntity = null;
                        GC.SuppressFinalize(this);
                    }
                }
            }
            else
            {
                mEntity      = null;
                mConstructor = null;
            }
        }
示例#2
0
        internal void InitEntity(IDesignScriptEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("host", "DesignScriptEntity can't be created with null IDesignScriptEntity");
            }

            if (entity.Owner != null)
            {
                throw new ArgumentException("Input host already has owner assigned to it. DesignScriptEntity can't be created with it.", "host");
            }

            mEntity = entity;
            mEntity.SetOwner(this);
        }
        private string WriteDSEntity(IDesignScriptEntity entity, string paramName = null)
        {
            Type type = entity.GetType();

            Type[] interfaces = type.GetInterfaces();

            //Find first available writer for this entity and the serialize.
            for (int i = interfaces.Length - 1; i >= 0; --i)
            {
                Func <GeometryExpressionBuilder, IDesignScriptEntity, string, string> writer;
                if (mWriters.TryGetValue(interfaces[i], out writer))
                {
                    return(writer(this, entity, paramName));
                }
            }
            throw new NotImplementedException();
        }
        /// <summary>
        /// Finds the underlying interface implementation type and uses appropriate
        /// writer to serialize the given entity.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="typeName">output type name</param>
        /// <returns></returns>
        public IGeometryDataCollection WriteEntity(IDesignScriptEntity entity, out string typeName)
        {
            Type type = entity.GetType();

            Type[] interfaces = type.GetInterfaces();

            //Find first available writer for this entity and the serialize.
            for (int i = interfaces.Length - 1; i >= 0; --i)
            {
                Func <IDesignScriptEntity, IGeometryDataCollection> writer;
                if (mDataWriters.TryGetValue(interfaces[i], out writer))
                {
                    typeName = mDataTypes[interfaces[i]];
                    return(writer(entity));
                }
            }
            throw new NotImplementedException();
        }
示例#5
0
 public virtual IPersistentObject Persist(IDesignScriptEntity entity)
 {
     throw new NotImplementedException("Persist method is not implemented by PersistenceManager.");
 }
示例#6
0
 internal DesignScriptEntity(IDesignScriptEntity entity)
 {
     InitEntity(entity);
 }
示例#7
0
 public virtual IPersistentObject Persist(IDesignScriptEntity entity)
 {
     throw new NotImplementedException("Persist method is not implemented by PersistenceManager.");
 }
 public static string WriteEntity <T>(GeometryExpressionBuilder eb, IDesignScriptEntity entity, string paramName) where T : IDesignScriptEntity
 {
     return(eb.WriteEntity((T)entity, paramName));
 }
 public override IPersistentObject Persist(IDesignScriptEntity entity)
 {
     return new PersistentObject(entity);
 }
 /// <summary>
 /// Finds the underlying interface implementation type and uses appropriate
 /// writer to serialize the given entity.
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="typeName">output type name</param>
 /// <returns></returns>
 public static IGeometryDataCollection WriteEntity(IDesignScriptEntity entity, out string typeName)
 {
     return(mSerializers.WriteEntity(entity, out typeName));
 }
示例#11
0
 public override IPersistentObject Persist(IDesignScriptEntity entity)
 {
     return(new PersistentObject(entity));
 }
示例#12
0
 public PersistentObject(IDesignScriptEntity geometry)
 {
     mEntity = geometry;
     Visible = true;
     Color   = null;
 }
示例#13
0
 public PersistentObject(IDesignScriptEntity geometry)
 {
     mEntity = geometry;
     Visible = true;
     Color = null;
 }