/// <summary> /// Initializes a new instances of the QueryTranslatorProvider class /// with the specified components. If no Identity is passed, /// unrestricted queries are executed. /// </summary> /// <param name="metaDataResolver"></param> /// <param name="identity">the user who is making the query; if null, a unrestricted query is executed.</param> /// <param name="source"></param> /// <param name="ctx"></param> /// <param name="iftFactory"></param> /// <param name="perfCounter"></param> protected QueryTranslatorProvider(IMetaDataResolver metaDataResolver, Identity identity, IQueryable source, IZetboxContext ctx, InterfaceType.Factory iftFactory, IPerfCounter perfCounter) { if (metaDataResolver == null) { throw new ArgumentNullException("metaDataResolver"); } if (source == null) { throw new ArgumentNullException("source"); } if (ctx == null) { throw new ArgumentNullException("ctx"); } if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } this.MetaDataResolver = metaDataResolver; this.Identity = identity; this.Source = source; this.Ctx = ctx; this.IftFactory = iftFactory; this.perfCounter = perfCounter; }
public ProxyMock(InterfaceType.Factory iftFactory, BaseMemoryContext backingStore, IFrozenContext frozen, TypeMap map) { _iftFactory = iftFactory; _backingStore = backingStore; _memoryFactory = new MemoryObjectHandlerFactory(); _map = map; var generatedAssembly = System.Reflection.Assembly.Load(MemoryProvider.GeneratedAssemblyName); Importer.LoadFromXml(_backingStore, generatedAssembly.GetManifestResourceStream("Zetbox.Objects.MemoryImpl.FrozenObjects.xml"), "FrozenObjects.xml from assembly"); // create default test data var list = new List <TestObjClass>(); while (list.Count < 2) { var newObj = _backingStore.Create <TestObjClass>(); newObj.ObjectProp = null; // kunde; newObj.StringProp = "blah" + list.Count; list.Add(newObj); } list[0].StringProp = "First"; list[0].TestEnumProp = TestEnum.First; list[1].StringProp = "Second"; list[1].TestEnumProp = TestEnum.Second; _backingStore.SubmitChanges(); }
/// <summary> /// Initializes a new instance of the BaseMemoryContext class, using the specified assemblies for interfaces and implementation. /// </summary> protected BaseMemoryContext(InterfaceType.Factory iftFactory) { this.objects = new ContextCache <int>(this, item => item.ID); this.iftFactoryCache = new FuncCache <Type, InterfaceType>(t => iftFactory(t)); this._iftFactory = t => iftFactoryCache.Invoke(t); ZetboxContextDebuggerSingleton.Created(this); }
public MemoryContext(InterfaceType.Factory iftFactory, Func <IFrozenContext> lazyCtx, MemoryImplementationType.MemoryFactory implTypeFactory) : base(iftFactory) { _lazyCtx = lazyCtx; _implTypeFactoryCache = new FuncCache <Type, MemoryImplementationType>(t => implTypeFactory(t)); _implTypeFactory = t => _implTypeFactoryCache.Invoke(t); }
/// <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."); } }
internal NHibernateContext( IMetaDataResolver metaDataResolver, Identity identity, ZetboxConfig config, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory, NHibernateImplementationType.Factory implTypeFactory, global::NHibernate.ISession nhSession, INHibernateImplementationTypeChecker implChecker, IPerfCounter perfCounter) : base(metaDataResolver, identity, config, lazyCtx, iftFactory) { if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } _implTypeFactory = implTypeFactory; _nhSession = nhSession; _implChecker = implChecker; _attachedObjects = new ContextCache <int>(this, item => item.ID); _attachedObjectsByProxy = new ContextCache <IProxyObject>(this, item => ((NHibernatePersistenceObject)item).NHibernateProxy); _perfCounter = perfCounter; }
public override void SetUp() { base.SetUp(); _iftFactory = scope.Resolve <InterfaceType.Factory>(); ctx = GetContext(); obj = new TestObjClassImpl(); ctx.Attach(obj); }
private void ExtractDefinitionGuid(InterfaceType.Factory iftFactory, Type t) { var guids = t.GetCustomAttributes(typeof(DefinitionGuidAttribute), false).OfType <DefinitionGuidAttribute>().ToArray(); if (guids.Length > 0) { _typeMap[guids[0].Guid] = iftFactory(t).ToSerializableType(); } }
public void Read(out OrderByContract[] orderBys, InterfaceType.Factory iftFactory) { orderBys = TraceArray(() => { OrderByContract result; Read(out result, iftFactory); return(result); }); }
public override void SetUp() { base.SetUp(); Logging.Log.Info("ZetboxContextTests.SetUp() is called"); this._iftFactory = scope.Resolve <InterfaceType.Factory>(); ctx = GetContext(); //CacheController<Zetbox.API.IDataObject>.Current.Clear(); }
/// <summary> /// Deserialize a Linq Expression Tree. /// </summary> /// <param name="iftFactory">InterfaceType.Factory to pass on the the read SerializableExpressions</param> public SerializableExpression ReadSerializableExpression(InterfaceType.Factory iftFactory) { TraceCurrentPos(); if (_source.ReadBoolean()) { return(SerializableExpression.FromStream(this, iftFactory)); } else { return(null); } }
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; }
internal SerializableExpression(ZetboxStreamReader binReader, StreamSerializationContext ctx, InterfaceType.Factory iftFactory) { this.iftFactory = iftFactory; SerializableType t; binReader.Read(out t); this.SerializableType = t; int nt; binReader.Read(out nt); NodeType = nt; }
public SerializableConstructorInfo(ConstructorInfo ci, InterfaceType.Factory iftFactory) : base(ci, iftFactory) { if (ci == null) { throw new ArgumentNullException("ci"); } if (iftFactory == null) { throw new ArgumentNullException("iftFactory"); } this.ParameterTypes = ci.GetParameters().Select(i => new SerializableType(iftFactory(i.ParameterType), iftFactory)).ToArray(); }
public SerializableMemberInfo(MemberInfo mi, InterfaceType.Factory iftFactory) { if (mi == null) { throw new ArgumentNullException("mi"); } if (iftFactory == null) { throw new ArgumentNullException("iftFactory"); } this.Type = new SerializableType(iftFactory(mi.DeclaringType), iftFactory); this.Name = mi.Name; }
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; }
public void Read(out OrderByContract orderBy, InterfaceType.Factory iftFactory) { orderBy = Trace(() => { int type; Read(out type); SerializableExpression expression; Read(out expression, iftFactory); return(new OrderByContract() { Type = (OrderByType)type, Expression = expression }); }); }
void context_BeginRequest(object sender, EventArgs e) { if (container == null) { Logging.Configure(); var config = ZetboxConfig.FromFile(HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["configFile"]), "AspNet.xml"); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Client.Modules); container = builder.Build(); ViewModelFactory = container.Resolve <IViewModelFactory>(); IftFactory = container.Resolve <InterfaceType.Factory>(); } ZetboxContext = container.Resolve <IZetboxContext>(); }
public TypeMap(InterfaceType.Factory iftFactory, IEnumerable <TypeMapAssembly> assemblies) { if (iftFactory == null) { throw new ArgumentNullException("iftFactory"); } if (assemblies == null) { throw new ArgumentNullException("assemblies"); } _typeMap = new Dictionary <Guid, SerializableType>(); foreach (var t in assemblies.SelectMany(a => a.Value.GetTypes())) { ExtractDefinitionGuid(iftFactory, t); } _guidMap = _typeMap.ToDictionary(k => k.Value, v => v.Key); }
public ZetboxContextImpl(ClientIsolationLevel il, ZetboxConfig config, IProxy proxy, string clientImplementationAssembly, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory, ClientImplementationType.ClientFactory implTypeFactory, IPerfCounter perfCounter, IIdentityResolver identityResolver) { if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } this._clientIsolationLevel = il; this.config = config; this.proxy = proxy; this._ClientImplementationAssembly = clientImplementationAssembly; this._objects = new ContextCache <int>(this, item => item.ID); this._lazyCtx = lazyCtx; this._iftFactory = iftFactory; this._implTypeFactory = implTypeFactory; this._perfCounter = perfCounter; this._identityResolver = identityResolver; CreatedAt = new StackTrace(true); ZetboxContextDebuggerSingleton.Created(this); }
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 ProxyImplementation(InterfaceType.Factory iftFactory, Zetbox.API.Client.ZetboxService.IZetboxService service, IPerfCounter perfCounter, ZetboxStreamReader.Factory readerFactory, ZetboxStreamWriter.Factory writerFactory) { if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } if (readerFactory == null) { throw new ArgumentNullException("readerFactory"); } if (writerFactory == null) { throw new ArgumentNullException("writerFactory"); } _iftFactory = iftFactory; _service = service; _perfCounter = perfCounter; _readerFactory = readerFactory; _writerFactory = writerFactory; }
/// <summary> /// Initializes a new instance of the BaseZetboxDataContext class using the specified <see cref="Identity"/>. /// </summary> /// <param name="metaDataResolver">the IMetaDataResolver for this context.</param> /// <param name="identity">the identity of this context. if this is null, the context does no security checks</param> /// <param name="config"></param> /// <param name="lazyCtx"></param> /// <param name="iftFactory"></param> protected BaseZetboxDataContext(IMetaDataResolver metaDataResolver, Identity identity, ZetboxConfig config, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory) { if (metaDataResolver == null) { throw new ArgumentNullException("metaDataResolver"); } if (config == null) { throw new ArgumentNullException("config"); } if (iftFactory == null) { throw new ArgumentNullException("iftFactory"); } this.metaDataResolver = metaDataResolver; this.identityStore = identity; this.config = config; this.iftFactoryCache = new FuncCache <Type, InterfaceType>(r => iftFactory(r)); this.iftFactory = t => iftFactoryCache.Invoke(t); this.lazyCtx = lazyCtx; }
/// <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 void SetUp() { base.SetUp(); iftFactory = scope.Resolve <InterfaceType.Factory>(); using (IZetboxContext ctx = GetContext()) { ctx.GetQuery <TestObjClass>().ForEach(obj => { obj.ObjectProp = null; ctx.Delete(obj); }); ProjectDataFixture.DeleteData(ctx); ctx.SubmitChanges(); } using (IZetboxContext ctx = GetContext()) { var list = new List <TestObjClass>(); while (list.Count < 2) { var newObj = ctx.Create <TestObjClass>(); newObj.ObjectProp = null; // kunde; newObj.StringProp = "blah" + list.Count; list.Add(newObj); } ctx.SubmitChanges(); firstId = list[0].ID; list[0].StringProp = "First"; list[0].TestEnumProp = TestEnum.First; secondId = list[1].ID; list[1].StringProp = "Second"; list[1].TestEnumProp = TestEnum.Second; ctx.SubmitChanges(); } }
public override void SetUp() { base.SetUp(); iftFactory = scope.Resolve<InterfaceType.Factory>(); using (IZetboxContext ctx = GetContext()) { ctx.GetQuery<TestObjClass>().ForEach(obj => { obj.ObjectProp = null; ctx.Delete(obj); }); ProjectDataFixture.DeleteData(ctx); ctx.SubmitChanges(); } using (IZetboxContext ctx = GetContext()) { var list = new List<TestObjClass>(); while (list.Count < 2) { var newObj = ctx.Create<TestObjClass>(); newObj.ObjectProp = null; // kunde; newObj.StringProp = "blah" + list.Count; list.Add(newObj); } ctx.SubmitChanges(); firstId = list[0].ID; list[0].StringProp = "First"; list[0].TestEnumProp = TestEnum.First; secondId = list[1].ID; list[1].StringProp = "Second"; list[1].TestEnumProp = TestEnum.Second; ctx.SubmitChanges(); } }
public override void SetUp() { base.SetUp(); iftFactory = scope.Resolve<InterfaceType.Factory>(); }
public EfImplementationType(Type type, InterfaceType.Factory iftFactory, IEfImplementationTypeChecker typeChecker) : base(type, iftFactory, typeChecker) { _typeChecker = typeChecker; }
public ZetboxMockFactory(InterfaceType.Factory iftFactory) { }
/// <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 ZetboxContextMock(IMetaDataResolver metaDataResolver, Identity identity, ZetboxConfig config, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory) : base(metaDataResolver, identity, config, lazyCtx, iftFactory) { TestObjClasses[1] = new TestObjClassImpl() { ID = 1 }; TestObjClasses[3] = new TestObjClassImpl() { ID = 3 }; TestObjClasses[22] = new TestObjClassImpl() { ID = 22 }; base.Attach(TestObjClasses[1]); base.Attach(TestObjClasses[3]); base.Attach(TestObjClasses[22]); TestObjClasses[1].BaseTestObjClass = null; TestObjClasses[1].StringProp = "some value (ID=1)"; TestObjClasses[1].SubClasses.Add(TestObjClasses[3]); TestObjClasses[1].SubClasses.Add(TestObjClasses[22]); TestObjClasses[1].TestEnumProp = Zetbox.API.Mocks.TestEnum.X; TestObjClasses[1].TestNames.Add("some name (ID=1,1)"); TestObjClasses[3].BaseTestObjClass = TestObjClasses[1]; TestObjClasses[3].StringProp = "some other value (ID=3)"; TestObjClasses[3].TestEnumProp = Zetbox.API.Mocks.TestEnum.Y; TestObjClasses[3].TestNames.Add("some other name (ID=3,1)"); TestObjClasses[3].TestNames.Add("some other name (ID=3,1)"); TestObjClasses[22].BaseTestObjClass = TestObjClasses[1]; TestObjClasses[22].StringProp = "some test value (ID=22)"; TestObjClasses[22].TestEnumProp = Zetbox.API.Mocks.TestEnum.Y; TestObjClasses[22].TestNames.Add("some test name (ID=22,1)"); TestObjClasses[22].TestNames.Add("some test name (ID=22,2)"); }
/// <summary> /// Internal Constructor /// </summary> public EfDataContext(IMetaDataResolver metaDataResolver, Identity identity, ZetboxConfig config, Func <IFrozenContext> lazyCtx, InterfaceType.Factory iftFactory, EfImplementationType.EfFactory implTypeFactory, IPerfCounter perfCounter) : base(metaDataResolver, identity, config, lazyCtx, iftFactory) { if (perfCounter == null) { throw new ArgumentNullException("perfCounter"); } _ctx = new EfObjectContext(config); _implTypeFactory = implTypeFactory; _perfCounter = perfCounter; }
/// <summary> /// Serializes a test TestObjClass to the stream sw. /// </summary> /// <param name="sw"></param> public static void ToStream <LOCALINTERFACE, ENUMTYPE>(ZetboxStreamWriter sw, InterfaceType.Factory iftFactory) where LOCALINTERFACE : TestObjClass <LOCALINTERFACE, ENUMTYPE> where ENUMTYPE : struct { // BaseServerPersistenceObject sw.Write(GetSerializableType <LOCALINTERFACE, ENUMTYPE>(iftFactory)); sw.Write(TestObjClassId); sw.Write((int)TestObjectState); sw.Write((int)AccessRights.Full); // TestObjClass // BaseTestObjClass Reference sw.Write(TestBaseClassId); // StringProp sw.Write(TestStringPropValue); //// SubClasses are not serialized, but fetched lazily //foreach (int subClassID in TestSubClassesIds) //{ // BinarySerializer.ToStream(true, sw); // BinarySerializer.ToStream(subClassID, sw); //} //BinarySerializer.ToStream(false, sw); // TestEnumProp sw.Write((int)TestEnum.TestSerializationValue); // TestNames var ceType = GetSerializableCollectionEntryType <LOCALINTERFACE, ENUMTYPE>(iftFactory); for (int i = 0; i < TestTestNamesIds.Length; i++) { sw.Write(true); sw.Write(ceType); sw.Write(TestTestNamesIds[i]); sw.Write((int)TestCollectionEntryState); sw.Write((int)AccessRights.Full); sw.Write(TestTestNamesValues[i]); } sw.Write(false); }
private static SerializableType GetSerializableCollectionEntryType <LOCALINTERFACE, ENUMTYPE>(InterfaceType.Factory iftFactory) where LOCALINTERFACE : TestObjClass <LOCALINTERFACE, ENUMTYPE> where ENUMTYPE : struct { return(iftFactory(typeof(IValueCollectionEntry <LOCALINTERFACE, string>)).ToSerializableType()); }
public override void SetUp() { base.SetUp(); _iftFactory = scope.Resolve<InterfaceType.Factory>(); ctx = GetContext(); obj = new TestObjClassImpl(); ctx.Attach(obj); }
public override void SetUp() { base.SetUp(); Logging.Log.Info("ZetboxContextTests.SetUp() is called"); this._iftFactory = scope.Resolve<InterfaceType.Factory>(); ctx = GetContext(); //CacheController<Zetbox.API.IDataObject>.Current.Clear(); }