public async Task ComplexTypeUpdate()
        {
            // Arrange
            var libraryApi = new LibraryApi();
            var entry      = new DataModificationEntry(
                "Readers",
                "Person",
                new Dictionary <string, object> {
                { "Id", new Guid("53162782-EA1B-4712-AF26-8AA1D2AC0461") }
            },
                new Dictionary <string, object>(),
                new Dictionary <string, object> {
                { "Addr", new Dictionary <string, object> {
                      { "Zip", "332" }
                  } }
            });
            var changeSet = new ChangeSet(new[] { entry });
            var sc        = new SubmitContext(libraryApi.Context, changeSet);

            // Act
            var changeSetPreparer = libraryApi.Context.Configuration.GetApiService <IChangeSetPreparer>();
            await changeSetPreparer.PrepareAsync(sc, CancellationToken.None);

            var person = entry.Entity as Person;

            // Assert
            Assert.NotNull(person);
            Assert.Equal("332", person.Addr.Zip);
        }
        public static void Init()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            instance = new LibraryApi();
            instance.Configuration.BasePath = "https://localhost:44344/";
        }
Exemple #3
0
        public void PrimitiveTypesShouldWork()
        {
            var model = new LibraryApi().Context.GetModelAsync().Result;
            IEnumerable <EdmError> errors;

            Assert.True(model.Validate(out errors));
            Assert.Empty(errors);

            var universe = model.FindDeclaredType("Microsoft.Restier.EntityFramework.Tests.Models.Library.Universe")
                           as IEdmComplexType;

            Assert.NotNull(universe);

            var propertyArray = universe.Properties().ToArray();
            int i             = 0;

            Assert.True(propertyArray[i++].Type.AsPrimitive().IsBinary());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsBoolean());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsByte());
            // Assert.True(propertyArray[i++].Type.AsPrimitive().IsDate());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsDateTimeOffset());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsDecimal());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsDouble());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsDuration());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsGuid());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsInt16());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsInt32());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsInt64());
            // Assert.True(propertyArray[i++].Type.AsPrimitive().IsSByte());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsSingle());
            // Assert.True(propertyArray[i++].Type.AsPrimitive().IsStream());
            Assert.True(propertyArray[i++].Type.AsPrimitive().IsString());
            // Assert.True(propertyArray[i].Type.AsPrimitive().IsTimeOfDay());
        }
Exemple #4
0
        public void Initialize()
        {
            var            http       = new HttpClient();
            IConfiguration testConfig = TestsHelper.GetLocalConfig();

            bearerAccessToken = testConfig.GetValue(typeof(string),
                                                    "SpotifyUserBearerAccessToken").ToString();
            var accounts = new AccountsService(http, testConfig);

            api = new LibraryApi(http, accounts);
        }
        public TrackResponse GetLibraryTrack(Track track, bool isUserOnly)
        {
            string userName = null;

            if (isUserOnly)
            {
                userName = Authentication.Session.Username;
            }

            var result = LibraryApi.GetTracks(track, Authentication, userName);

            return(result);
        }
Exemple #6
0
        public void ComplexTypeShoudWork()
        {
            var model = new LibraryApi().Context.GetModelAsync().Result;
            IEnumerable <EdmError> errors;

            Assert.True(model.Validate(out errors));
            Assert.Empty(errors);

            var address = model.FindDeclaredType("Microsoft.Restier.EntityFramework.Tests.Models.Library.Address")
                          as IEdmComplexType;

            Assert.NotNull(address);
            Assert.Equal(2, address.Properties().Count());
        }
        public async Task ComplexTypeUpdate()
        {
            // Arrange
            var libraryApi = new LibraryApi();
            var entry = new DataModificationEntry(
                "Readers",
                "Person",
                new Dictionary<string, object> { { "Id", new Guid("53162782-EA1B-4712-AF26-8AA1D2AC0461") } },
                new Dictionary<string, object>(),
                new Dictionary<string, object> { { "Addr", new Dictionary<string, object> { { "Zip", "332" } } } });
            var changeSet = new ChangeSet(new[] { entry });
            var sc = new SubmitContext(libraryApi.Context, changeSet);

            // Act
            var changeSetPreparer = libraryApi.Context.Configuration.GetHookHandler<IChangeSetPreparer>();
            await changeSetPreparer.PrepareAsync(sc, CancellationToken.None);
            var person = entry.Entity as Person;

            // Assert
            Assert.NotNull(person);
            Assert.Equal("332", person.Addr.Zip);
        }
Exemple #8
0
 public LibraryApiDecorator(LibraryApi libraryApi)
 {
     _libraryApi = libraryApi;
 }
 public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
 {
     return(LibraryApi.ConfigureApi(apiType, services)
            .AddSingleton <IQueryExpressionAuthorizer, DisallowEverythingAuthorizer>());
 }
Exemple #10
0
        private async void QueryAssetHash(Dictionary <string, LibraryManager.DownloadAssetInfo> infoList, System.Action <Dictionary <string, LibraryManager.DownloadAssetInfo> > OnQueryFinish)
        {
            // 先连接server,检查所有Asset对应当前平台的文件Hash,并回填数据
            List <string> assetIds = new List <string>();
            int           index    = 0;

            foreach (DownloadAssetInfo info in infoList.Values)
            {
                assetIds.Add(info.id);
                index++;
            }

            DcsLibraryEntityType currentPlatform;

#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            currentPlatform = DcsLibraryEntityType.EntityTypeAssetPC;
#elif UNITY_IOS
            currentPlatform = DcsLibraryEntityType.EntityTypeAssetIOS;
#elif UNITY_ANDROID
            currentPlatform = DcsLibraryEntityType.EntityTypeAssetAndroid;
#elif UNITY_WSA
            currentPlatform = DcsLibraryEntityType.EntityTypeAssetUWP;
#endif

            LibraryApi libraryApi = new LibraryApi("https://library." + AccountManager.Instance.RegionCode + ".datamesh.com");
            try
            {
                List <DcsLibraryResource> queryRs = await libraryApi.ListResourcesByIds(
                    AccountManager.Instance.UserCredential.AccessKey,
                    AccountManager.Instance.UserCredential.AccessSecret,
                    assetIds,
                    currentPlatform);

                Debug.Log("Query find [" + queryRs.Count + "] assets!");
                for (int i = 0; i < queryRs.Count; i++)
                {
                    DcsLibraryResource resource = queryRs[i];
                    Debug.Log("entitis length=" + resource.Entities.Length);
                    for (int j = 0; j < resource.Entities.Length; j++)
                    {
                        DcsLibraryEntity asset = resource.Entities[j];
                        if (asset.EntityType == currentPlatform)
                        {
                            if (infoList.ContainsKey(resource.Id))
                            {
                                DownloadAssetInfo info = infoList[resource.Id];
                                info.hash = asset.Id;
                                Debug.Log("Fill Hash for asset [" + resource.Id + "]=[" + asset.Id + "]");
                            }
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
                err = e.ToString();
            }


            MEHoloEntrance.Instance.Dispatch((param) => {
                if (OnQueryFinish != null)
                {
                    OnQueryFinish(infoList);
                }
            });
        }