Beispiel #1
0
        /// <summary>
        /// This class is used to place type information on the wire. Since the wire protocol is Provider independent, 
        /// only interface types are stored. Usually this is used to declare the type of the following IPersistenceObject.
        /// </summary>
        /// <remarks>
        /// Since the <see cref="InterfaceType.Factory"/> cannot be serialiezed, this class cannot provide full dehydration.
        /// Use <see cref="GetSystemType"/> and your own factory to retrieve <see cref="InterfaceType"/>.</remarks>
        /// <param name="ifType">System.Type to serialize</param>
        /// <param name="iftFactory"></param>
        internal SerializableType(InterfaceType ifType, InterfaceType.Factory iftFactory)
        {
            var type = ifType.Type;

            if (type.IsGenericType)
            {
                Type genericType = type.GetGenericTypeDefinition();
                TypeName = genericType.FullName;
                AssemblyQualifiedName = genericType.AssemblyQualifiedName;

                GenericTypeParameter = type.GetGenericArguments()
                    .Select(t => new SerializableType(iftFactory(t), iftFactory))
                    .ToArray();
            }
            else
            {
                TypeName = type.FullName;
                AssemblyQualifiedName = type.AssemblyQualifiedName;
                GenericTypeParameter = new SerializableType[] { };
            }

            // This is null if the Type is e.g. a Generic Parameter - not supported
            if (string.IsNullOrEmpty(AssemblyQualifiedName))
                throw new NotSupportedException("AssemblyQualifiedName must not be null or empty - maybe this Type is a Generic Parameter or something similarily strange.");
        }
Beispiel #2
0
        public static string InheritanceAssociationName(InterfaceType parentClass, InterfaceType childClass)
        {
            //if (parentClass == null) { throw new ArgumentNullException("parentClass"); }
            //if (childClass == null) { throw new ArgumentNullException("childClass"); }

            return InheritanceAssociationName(parentClass.Type.Name, childClass.Type.Name);
        }
 public void DecrementQuery(InterfaceType ifType, int objectCount, long startTicks)
 {
     var endTicks = Stopwatch.GetTimestamp();
     foreach (var a in _appender)
     {
         a.DecrementQuery(ifType, objectCount, startTicks, endTicks);
     }
 }
 public void DecrementGetObjects(InterfaceType ifType, int resultSize, long startTicks)
 {
     var endTicks = Stopwatch.GetTimestamp();
     foreach (var a in _appender)
     {
         a.DecrementGetObjects(ifType, resultSize, startTicks, endTicks);
     }
 }
Beispiel #5
0
 public void DecrementFetchRelation(InterfaceType ifType, int resultSize, long startTicks, long endTicks)
 {
     lock (counterLock)
     {
         this.ObjectTotals.FetchRelation.Count(resultSize, startTicks, endTicks);
         Get(ifType).FetchRelation.Count(resultSize, startTicks, endTicks);
         Dump(false);
     }
 }
 public override IServerCollectionHandler GetServerCollectionHandler(
     IReadOnlyZetboxContext ctx,
     InterfaceType aType,
     InterfaceType bType,
     RelationEndRole endRole)
 {
     if (ctx == null) throw new ArgumentNullException("ctx");
     return GetServerCollectionHandlerHelper(
         typeof(ServerCollectionHandler<,,,>),
         ctx.ToImplementationType(aType),
         ctx.ToImplementationType(bType),
         endRole);
 }
Beispiel #7
0
        public ZetboxService(IServerObjectHandlerFactory sohFactory, Func<IZetboxContext> ctxFactory, InterfaceType.Factory iftFactory, IPerfCounter perfCounter, ZetboxStreamReader.Factory readerFactory, ZetboxStreamWriter.Factory writerFactory)
        {
            if (readerFactory == null) throw new ArgumentNullException("readerFactory");
            if (writerFactory == null) throw new ArgumentNullException("writerFactory");

            Logging.Facade.Debug("Creating new ZetboxService instance");

            _sohFactory = sohFactory;
            _ctxFactory = ctxFactory;
            _iftFactory = iftFactory;
            _perfCounter = perfCounter;
            _readerFactory = readerFactory;
            _writerFactory = writerFactory;
        }
 public NHibernateImplementationType(Type type, InterfaceType.Factory iftFactory, INHibernateImplementationTypeChecker typeChecker)
     : base(// translate from NHibernate dynamic proxies if type is not in the generated assembly, but the BaseType is.
         (type != null 
             && typeChecker != null
             && type.Assembly != typeChecker.GetType().Assembly 
             && type.BaseType != null 
             && type.BaseType.Assembly == typeChecker.GetType().Assembly)
         ? type.BaseType 
         : type, 
     iftFactory, 
     typeChecker)
 {
     _typeChecker = typeChecker;
 }
Beispiel #9
0
        public void DecrementFetchRelation(InterfaceType ifType, int resultSize, long startTicks)
        {
            lock (sync)
            {
                var duration = Stopwatch.GetTimestamp() - startTicks;

                FetchRelationTotal++;
                FetchRelationObjectsTotal += resultSize;
                FetchRelationSumDuration += duration;
                Get(ifType).FetchRelationTotal++;
                Get(ifType).FetchRelationObjectsTotal += resultSize;
                Get(ifType).FetchRelationSumDuration += duration;

                ShouldDump();
            }
        }
Beispiel #10
0
        public void DecrementQuery(InterfaceType ifType, int objectCount, long startTicks)
        {
            lock (sync)
            {
                var duration = Stopwatch.GetTimestamp() - startTicks;
                QueriesTotal++;
                QueriesObjectsTotal += objectCount;
                QueriesSumDuration += duration;

                Get(ifType).QueriesTotal++;
                Get(ifType).QueriesObjectsTotal += objectCount;
                Get(ifType).QueriesSumDuration += duration;

                ShouldDump();
            }
        }
Beispiel #11
0
 public void IncrementGetObjects(InterfaceType ifType)
 {
 }
Beispiel #12
0
 public FrozenMemoryContext(InterfaceType.Factory iftFactory, Func<IFrozenContext> lazyCtx, MemoryImplementationType.MemoryFactory implTypeFactory)
     : base(iftFactory, lazyCtx, implTypeFactory)
 {
 }
Beispiel #13
0
 private static IPersistenceObject FindObject(IZetboxContext ctx, Dictionary<Guid, IPersistenceObject> objects, Guid exportGuid, InterfaceType ifType)
 {
     if (!objects.ContainsKey(exportGuid))
     {
         if (!ifType.Type.IsIDataObject() &&
             !ifType.Type.IsIRelationEntry())
         {
             throw new NotSupportedException(String.Format("Interfacetype {0} is not supported", ifType));
         }
         IPersistenceObject obj = ctx.Internals().CreateUnattached(ifType);
         objects[exportGuid] = obj;
         ((Zetbox.App.Base.IExportable)obj).ExportGuid = exportGuid;
         ctx.Internals().AttachAsNew(obj);
         return obj;
     }
     else
     {
         return objects[exportGuid];
     }
 }
Beispiel #14
0
 public void DecrementGetListOf(InterfaceType ifType, int resultSize, long startTicks, long endTicks)
 {
     lock (counterLock)
     {
         this.ObjectTotals.GetListOf.Count(resultSize, startTicks, endTicks);
         Get(ifType).GetListOf.Count(resultSize, startTicks, endTicks);
         Dump(false);
     }
 }
Beispiel #15
0
 private ObjectMemoryCounters Get(InterfaceType ifType)
 {
     var name = ifType.Type.FullName;
     ObjectMemoryCounters result;
     if (!Objects.TryGetValue(name, out result))
     {
         result = new ObjectMemoryCounters(name);
         Objects[name] = result;
     }
     return result;
 }
Beispiel #16
0
 public bool IsAssignableFrom(InterfaceType b)
 {
     return this.Type.IsAssignableFrom(b.Type);
 }
Beispiel #17
0
        /// <summary>
        /// Wrap a given ImplementationType
        /// </summary>
        /// <param name="type">A valid ImplementationType</param>
        /// <param name="iftFactory"></param>
        /// <param name="implTypeChecker"></param>
        /// <exception cref="ArgumentOutOfRangeException">if <paramref name="type"/> doesn't 
        /// fulfill all constraints</exception>
        /// <exception cref="ArgumentNullException">if <paramref name="type"/> is null</exception>
        protected ImplementationType(Type type, InterfaceType.Factory iftFactory, IImplementationTypeChecker implTypeChecker)
        {
            if (type == null) throw new ArgumentNullException("type");
            if (iftFactory == null) throw new ArgumentNullException("iftFactory");
            if (implTypeChecker == null) throw new ArgumentNullException("implTypeChecker");
            if (!implTypeChecker.IsImplementationType(type)) { throw new ArgumentOutOfRangeException("type", String.Format("Type {0} is not an ImplementationType", type.AssemblyQualifiedName)); }

            this._type = type;
            this._iftFactory = iftFactory;
        }
 public override IServerObjectHandler GetServerObjectHandler(InterfaceType type)
 {
     return GetServerObjectHandlerHelper(typeof(NHibernateServerObjectHandler<>), type);
 }
Beispiel #19
0
        public void DecrementGetListOf(InterfaceType ifType, int resultSize, long startTicks)
        {
            lock (sync)
            {
                var duration = Stopwatch.GetTimestamp() - startTicks;

                GetListOfTotal++;
                GetListOfObjectsTotal += resultSize;
                GetListOfSumDuration += duration;
                Get(ifType).GetListOfTotal++;
                Get(ifType).GetListOfObjectsTotal += resultSize;
                Get(ifType).GetListOfSumDuration += duration;

                ShouldDump();
            }
        }
 public long IncrementFetchRelation(InterfaceType ifType)
 {
     foreach (var a in _appender)
     {
         a.IncrementFetchRelation(ifType);
     }
     return Stopwatch.GetTimestamp();
 }
 public long IncrementQuery(InterfaceType ifType)
 {
     foreach (var a in _appender ?? Empty)
     {
         a.IncrementQuery(ifType);
     }
     return Stopwatch.GetTimestamp();
 }
 public long IncrementGetObjects(InterfaceType ifType)
 {
     foreach (var a in _appender)
     {
         a.IncrementGetObjects(ifType);
     }
     return Stopwatch.GetTimestamp();
 }
Beispiel #23
0
 public ZetboxMockFactory(InterfaceType.Factory iftFactory)
 {
 }
Beispiel #24
0
 public void IncrementFetchRelation(InterfaceType ifType)
 {
 }
Beispiel #25
0
 // TODO: Mit david nochmals besprechen
 internal static InterfaceType Create(Type type, IInterfaceTypeChecker typeChecker)
 {
     lock (_lock)
     {
         if (type == null) return new InterfaceType(); // Possible, because a Type could be loaded from an XML File which does not exists in this Zetbox instance
         if (_cache.ContainsKey(type)) return _cache[type];
         var ift = new InterfaceType(type, typeChecker);
         _cache[type] = ift;
         return ift;
     }
 }
Beispiel #26
0
 public void IncrementGetListOf(InterfaceType ifType)
 {
 }
 public ClientImplementationType(Type type, InterfaceType.Factory iftFactory, IClientImplementationTypeChecker typeChecker)
     : base(type, iftFactory, typeChecker)
 {
     _typeChecker = typeChecker;
 }
Beispiel #28
0
 public void IncrementQuery(InterfaceType ifType)
 {
 }
Beispiel #29
0
 private ObjectsPerfCounter Get(InterfaceType ifType)
 {
     var name = ifType.Type.FullName;
     ObjectsPerfCounter result;
     if (!_objects.TryGetValue(name, out result))
     {
         result = new ObjectsPerfCounter(name);
         _objects[name] = result;
     }
     return result;
 }
Beispiel #30
0
 public FrozenMemoryContext(InterfaceType.Factory iftFactory, Func<IFrozenContext> lazyCtx, MemoryImplementationType.MemoryFactory implTypeFactory, IEnumerable<IZetboxContextEventListener> eventListeners)
     : base(iftFactory, lazyCtx, implTypeFactory, eventListeners)
 {
 }