public RpcObjectProxyFactory GenerateObjectProxyFactory <TService>( IReadOnlyCollection <string>?implementedServices, IReadOnlyDictionary <string, ImmutableArray <Type> >?knownServiceTypes) where TService : class { lock (this.syncRoot) { var serviceInterfaces = GetAllServices <TService>(implementedServices, knownServiceTypes); var key = new HashSetKey <Type>(serviceInterfaces.Select(s => s.Type)); // If a proxy with the same set of service interfaces has been generated before // let's reuse that one. if (this.generatedFactories.TryGetValue(key, out var currFactory)) { // TODO: Should maybe look for a factory which has a superset of implemented interfaces? return((RpcObjectProxyFactory)currFactory); } var(moduleBuilder, definedProxyTypes) = CreateModuleBuilder(); var proxyTypeBuilder = new RpcServiceProxyBuilder <TRpcProxy, TMethodDef>( serviceInterfaces, moduleBuilder, definedProxyTypes); (Func <TProxyArgs, TMethodDef[], RpcProxyBase> proxyCreator, TMethodDef[] proxyMethodDefs) = proxyTypeBuilder.BuildObjectProxyFactory <TProxyArgs>(); RpcObjectProxyFactory newFactory = this.CreateProxyFactory(proxyCreator, implementedServices, proxyMethodDefs); this.generatedFactories.Add(key, newFactory); return(newFactory); } }
public NativeMultipleHashSets(ISet <int>[] initialValues, Allocator allocator) { UnityEngine.Profiling.Profiler.BeginSample("allocating"); data = new NativeHashSet <HashSetKey>(initialValues.Sum(x => x.Count), allocator); UnityEngine.Profiling.Profiler.EndSample(); if (initialValues.Length >= short.MaxValue) { throw new Exception("Too many individual sets to be stored in a short"); } for (short i = 0; i < initialValues.Length; i++) { var set = initialValues[i]; if (set == null || set.Count <= 0) { continue; } var hashValue = new HashSetKey { index = i }; foreach (var value in set) { hashValue.data = value; data.Add(hashValue); } } }
public bool Contains(short index, int item) { var dataItem = new HashSetKey(index, item); return(data.Contains(dataItem)); }
public bool Remove(short index, int item) { var dataItem = new HashSetKey(index, item); return(data.Remove(dataItem)); }
public bool Add(short index, int item) { var dataItem = new HashSetKey(index, item); return(data.Add(dataItem)); }