public void TestFixtureSetUp() { Configuration.ConfigWithEmbeddedXml(null, "application_config", Assembly.GetExecutingAssembly(), "Cooper.Sync.Test.ConfigFiles") .RenderProperties() .Castle(resolver => Resolve(resolver.Container)); //初始化同步锁 DependencyResolver.Resolve<ILockHelper>().Init<Account>(); DependencyResolver.Resolve<ILockHelper>().Init<GoogleConnection>(); _logger = DependencyResolver.Resolve<ILoggerFactory>().Create(GetType()); _sessionManager = DependencyResolver.Resolve<ISessionManager>(); _accountHelper = DependencyResolver.Resolve<IAccountHelper>(); _accountService = DependencyResolver.Resolve<IAccountService>(); _accountConnectionService = DependencyResolver.Resolve<IAccountConnectionService>(); _taskService = DependencyResolver.Resolve<ITaskService>(); _externalServiceProvider = DependencyResolver.Resolve<IExternalServiceProvider>(); _googleTokenService = DependencyResolver.Resolve<IGoogleTokenService>(); _syncProcessor = DependencyResolver.Resolve<IGoogleSyncProcesser>(); GoogleSyncSettings.ClientIdentifier = "234919028272-gsmmng06nheoih4ajp60oq8s33at1os0.apps.googleusercontent.com"; GoogleSyncSettings.ClientSecret = "jXcjxFzCQGferMI37I0GSc05"; }
internal static ValueTask <Info <Texture2D> > GetTextureResourceAsync( [NotNull] string uriString, [CanBeNull] IExternalServiceProvider provider, CancellationToken token) => Internal.TryGet(uriString, out Info <Texture2D> info) ? new ValueTask <Info <Texture2D> >(info) : External.TryGetTextureAsync(uriString, provider, token);
public void TestFixtureSetUp() { Configuration.ConfigWithEmbeddedXml(null, "application_config", Assembly.GetExecutingAssembly(), "Cooper.Sync.Test.ConfigFiles") .RenderProperties() .Castle(resolver => Resolve(resolver.Container)); //初始化同步锁 DependencyResolver.Resolve <ILockHelper>().Init <Account>(); DependencyResolver.Resolve <ILockHelper>().Init <GoogleConnection>(); _logger = DependencyResolver.Resolve <ILoggerFactory>().Create(GetType()); _sessionManager = DependencyResolver.Resolve <ISessionManager>(); _accountHelper = DependencyResolver.Resolve <IAccountHelper>(); _accountService = DependencyResolver.Resolve <IAccountService>(); _accountConnectionService = DependencyResolver.Resolve <IAccountConnectionService>(); _taskService = DependencyResolver.Resolve <ITaskService>(); _externalServiceProvider = DependencyResolver.Resolve <IExternalServiceProvider>(); _googleTokenService = DependencyResolver.Resolve <IGoogleTokenService>(); _syncProcessor = DependencyResolver.Resolve <IGoogleSyncProcesser>(); GoogleSyncSettings.ClientIdentifier = "234919028272-gsmmng06nheoih4ajp60oq8s33at1os0.apps.googleusercontent.com"; GoogleSyncSettings.ClientSecret = "jXcjxFzCQGferMI37I0GSc05"; }
public static ValueTask <GameObjectInfo> GetGameObjectResourceAsync( [NotNull] string uriString, [CanBeNull] IExternalServiceProvider provider, CancellationToken token) => Internal.TryGet(uriString, out GameObjectInfo info) ? new ValueTask <GameObjectInfo>(info) : External.TryGetGameObjectAsync(uriString, provider, token);
public DefaultCommandProcessor(Func <CommandHandler <TCommand> > handlerBuilder, IExternalServiceProvider externalServiceProvider, ILoggerFactory loggerFactory, IUowFactory uowFactory) { _handlerBuilder = handlerBuilder; _externalServiceProvider = externalServiceProvider; _loggerFactory = loggerFactory; _uowfactory = uowFactory; }
public CommandProcessorBuilder(CrossContext ctx, IExternalServiceProvider externalServiceProvider, IUowFactory uowFactory, ILoggerFactory loggerFactory) { _ctx = ctx ?? throw new ArgumentNullException(nameof(ctx), "Correlation unreachable"); _externalServiceProvider = externalServiceProvider ?? throw new ArgumentNullException(nameof(externalServiceProvider)); _uowFactory = uowFactory ?? throw new ArgumentNullException(nameof(uowFactory)); _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public ProcessorFactory( IExternalServiceProvider externalServiceProvider, IUowFactory uowFactory, ILoggerFactory loggerFactory) { _externalServiceProvider = externalServiceProvider; _uowFactory = uowFactory; _loggerFactory = loggerFactory; }
public GoogleSyncProcesser( ILockHelper lockHelper, ILoggerFactory loggerFactory, ISessionManager sessionManager, IAccountHelper accountHelper, IAccountService accountService, IAccountConnectionService accountConnectionService, ITaskService taskService, IExternalServiceProvider externalServiceProvider, IGoogleTokenService googleTokenService, IGoogleTaskSyncService googleTaskSyncService, IGoogleCalendarEventSyncService googleCalendarEventSyncService, IGoogleContactSyncService googleContactSyncService) : base(lockHelper, loggerFactory, sessionManager, accountHelper, accountService, accountConnectionService, taskService, externalServiceProvider) { lockHelper.Init <GoogleConnection>(); _googleTokenService = googleTokenService; _googleTaskSyncService = googleTaskSyncService; _googleCalendarEventSyncService = googleCalendarEventSyncService; _googleContactSyncService = googleContactSyncService; }
public GoogleSyncProcesser( ILockHelper lockHelper, ILoggerFactory loggerFactory, ISessionManager sessionManager, IAccountHelper accountHelper, IAccountService accountService, IAccountConnectionService accountConnectionService, ITaskService taskService, IExternalServiceProvider externalServiceProvider, IGoogleTokenService googleTokenService, IGoogleTaskSyncService googleTaskSyncService, IGoogleCalendarEventSyncService googleCalendarEventSyncService, IGoogleContactSyncService googleContactSyncService) : base(lockHelper, loggerFactory, sessionManager, accountHelper, accountService, accountConnectionService, taskService, externalServiceProvider) { lockHelper.Init<GoogleConnection>(); _googleTokenService = googleTokenService; _googleTaskSyncService = googleTaskSyncService; _googleCalendarEventSyncService = googleCalendarEventSyncService; _googleContactSyncService = googleContactSyncService; }
public SyncProcesser( ILockHelper lockHelper, ILoggerFactory loggerFactory, ISessionManager sessionManager, IAccountHelper accountHelper, IAccountService accountService, IAccountConnectionService accountConnectionService, ITaskService taskService, IExternalServiceProvider externalServiceProvider ) { //初始化同步锁 lockHelper.Init <Account>(); _logger = loggerFactory.Create(GetType()); _sessionManager = sessionManager; _accountHelper = accountHelper; _accountService = accountService; _accountConnectionService = accountConnectionService; _taskService = taskService; _externalServiceProvider = externalServiceProvider; }
public GoogleCalendarEventSyncDataService(IExternalServiceProvider externalServiceProvider, ILoggerFactory loggerFactory) { _externalServiceProvider = externalServiceProvider; _logger = loggerFactory.Create(GetType()); }
static async ValueTask <AggregatedMeshMarkerResource> CreateImpl(string uriString, [NotNull] Model msg, IExternalServiceProvider provider, CancellationToken token, [NotNull] GameObject root) { root.transform.localRotation = msg.OrientationHint.ToUpperInvariant() == "Z_UP" ? Quaternion.Euler(0, -90, 0) : Quaternion.Euler(90, 0, 90); var marker = root.AddComponent <AggregatedMeshMarkerResource>(); var children = new List <MeshTrianglesResource>(); var templateMeshes = new List <MeshTrianglesResource>(); foreach (var mesh in msg.Meshes) { token.ThrowIfCancellationRequested(); GameObject obj = new GameObject(); obj.AddComponent <MeshRenderer>(); obj.AddComponent <MeshFilter>(); obj.EnsureComponent <BoxCollider>(); obj.transform.SetParent(root.transform, false); MeshTrianglesResource meshResource = obj.AddComponent <MeshTrianglesResource>(); meshResource.Name = mesh.Name; var meshColors = mesh.ColorChannels.Length != 0 ? mesh.ColorChannels[0].Colors : Array.Empty <Iviz.Msgs.IvizMsgs.Color32>(); var material = msg.Materials[(int)mesh.MaterialIndex]; var diffuseTexture = material.Textures.FirstOrDefault(texture => texture.Type == Msgs.IvizMsgs.Texture.TYPE_DIFFUSE); var bumpTexture = material.Textures.FirstOrDefault(texture => texture.Type == Msgs.IvizMsgs.Texture.TYPE_NORMALS); var meshDiffuseTexCoords = diffuseTexture != null && diffuseTexture.UvIndex < mesh.TexCoords.Length ? mesh.TexCoords[diffuseTexture.UvIndex].Coords : Array.Empty <Vector3f>(); var meshBumpTexCoords = bumpTexture != null && bumpTexture.UvIndex < mesh.TexCoords.Length ? mesh.TexCoords[bumpTexture.UvIndex].Coords : Array.Empty <Vector3f>(); using (var vertices = new Rent <Vector3>(mesh.Vertices.Length)) using (var normals = new Rent <Vector3>(mesh.Normals.Length)) using (var colors = new Rent <Color32>(meshColors.Length)) using (var diffuseTexCoords = new Rent <Vector3>(meshDiffuseTexCoords.Length)) using (var bumpTexCoords = new Rent <Vector3>(meshBumpTexCoords.Length)) using (var tangents = new Rent <Vector4>(mesh.Tangents.Length)) using (var triangles = new Rent <int>(mesh.Faces.Length * 3)) { for (int i = 0; i < vertices.Length; i++) { vertices.Array[i] = Assimp2Unity(mesh.Vertices[i]); } MemCopy(mesh.Normals, normals.Array, normals.Length * 3 * sizeof(float)); MemCopy(meshColors, colors.Array, colors.Length * sizeof(int)); MemCopy(meshDiffuseTexCoords, diffuseTexCoords.Array, diffuseTexCoords.Length * 3 * sizeof(float)); MemCopy(meshBumpTexCoords, bumpTexCoords.Array, bumpTexCoords.Length * 3 * sizeof(float)); MemCopy(mesh.Faces, triangles.Array, triangles.Length * sizeof(int)); for (int i = 0; i < mesh.Tangents.Length; i++) { (float x, float y, float z) = mesh.Tangents[i]; tangents.Array[i] = new Vector4(x, y, z, -1); } meshResource.Set(vertices, normals, tangents, diffuseTexCoords, bumpTexCoords, triangles, colors); } meshResource.Color = material.Diffuse.ToColor32(); meshResource.EmissiveColor = material.Emissive.ToColor32(); if (diffuseTexture != null && diffuseTexture.Path.Length != 0) { var textureInfo = await GetTextureResourceAsync(uriString, diffuseTexture.Path, provider, token); if (textureInfo != null) { meshResource.DiffuseTexture = textureInfo.Object; } else { Core.Logger.Warn($"SceneModel: Failed to retrieve diffuse texture " + $"'{diffuseTexture.Path}' required by {uriString}"); } } if (bumpTexture != null && bumpTexture.Path.Length != 0) { var textureInfo = await GetTextureResourceAsync(uriString, bumpTexture.Path, provider, token); if (textureInfo != null) { meshResource.BumpTexture = textureInfo.Object; } else { Core.Logger.Warn($"SceneModel: Failed to retrieve normal texture " + $"'{bumpTexture.Path}' required by {uriString}"); } } meshResource.Mesh.name = mesh.Name; children.Add(meshResource); templateMeshes.Add(meshResource); } List <GameObject> nodes = new List <GameObject>(); bool[] used = new bool[templateMeshes.Count]; foreach (var node in msg.Nodes) { token.ThrowIfCancellationRequested(); GameObject nodeObject = new GameObject($"Node:{node.Name}"); nodes.Add(nodeObject); nodeObject.transform.SetParent( node.Parent == -1 ? root.transform : nodes[node.Parent].transform, false); Matrix4x4 m = new Matrix4x4(); for (int i = 0; i < 16; i++) { m[i] = node.Transform.M[i]; } nodeObject.transform.localRotation = m.rotation; nodeObject.transform.localPosition = m.GetColumn(3); nodeObject.transform.localScale = m.lossyScale; foreach (int meshId in node.Meshes) { if (!used[meshId]) { templateMeshes[meshId].transform.SetParent(nodeObject.transform, false); used[meshId] = true; } else { GameObject newMesh = Object.Instantiate( templateMeshes[meshId].gameObject, nodeObject.transform, false); children.Add(newMesh.GetComponent <MeshTrianglesResource>()); } } } marker.Children = children; var parentCollider = root.EnsureComponent <BoxCollider>(); var markerChildren = marker.Children .Select(resource => TransformBoundsUntil(resource.LocalBounds, resource.Transform, root.transform)); var nullableRootBounds = markerChildren.CombineBounds(); if (nullableRootBounds is Bounds rootBounds) { parentCollider.center = rootBounds.center; parentCollider.size = rootBounds.size; } return(marker); }
public static async ValueTask <AggregatedMeshMarkerResource> CreateAsync([NotNull] string uriString, [NotNull] Model msg, [CanBeNull] IExternalServiceProvider provider, CancellationToken token) { if (uriString is null) { throw new ArgumentNullException(nameof(uriString)); } if (msg is null) { throw new ArgumentNullException(nameof(msg)); } token.ThrowIfCancellationRequested(); var root = new GameObject($"Root:{uriString} [{msg.OrientationHint}]"); try { return(await CreateImpl(uriString, msg, provider, token, root)); } catch (Exception) { if (root != null) { Object.Destroy(root); } throw; } }
static ValueTask <Info <Texture2D> > GetTextureResourceAsync([NotNull] string uriString, [NotNull] string localPath, IExternalServiceProvider provider, CancellationToken token) { Uri uri = new Uri(uriString); string uriPath = Uri.UnescapeDataString(uri.AbsolutePath); string directoryName = Path.GetDirectoryName(uriPath); if (!string.IsNullOrEmpty(directoryName) && Path.DirectorySeparatorChar == '\\') { directoryName = directoryName.Replace('\\', '/'); // windows! } string textureUri = $"{uri.Scheme}://{uri.Host}{directoryName}/{localPath}"; return(Resource.GetTextureResourceAsync(textureUri, provider, token)); }