Exemplo n.º 1
0
        public async Task RegisterNullException()
        {
            ProviderContainer   providerContainer = Client.DefaultSubscription.GetProviders();
            Response <Provider> response          = await providerContainer.GetAsync("microsoft.insights");

            Assert.ThrowsAsync <ArgumentNullException>(async() => { await response.Value.RegisterAsync(null); });
        }
Exemplo n.º 2
0
 static BaseProvider()
 {
     ProviderLoader.Instance.ConfigChanged = (ProviderLoader) =>
     {
         ProviderContainer.Clear();
     };
 }
Exemplo n.º 3
0
        public async Task UnregisterEmptyException()
        {
            ProviderContainer   providerContainer = Client.DefaultSubscription.GetProviders();
            Response <Provider> response          = await providerContainer.GetAsync("microsoft.insights");

            Assert.ThrowsAsync <RequestFailedException>(async() => { await response.Value.UnregisterAsync(""); });
        }
Exemplo n.º 4
0
        public async Task Get()
        {
            ProviderContainer   providerContainer = Client.DefaultSubscription.GetProviders();
            Response <Provider> response          = await providerContainer.GetAsync("microsoft.insights");

            Provider result = response.Value;

            Assert.IsNotNull(result);
        }
Exemplo n.º 5
0
        public async Task CheckIfExists()
        {
            ProviderContainer providerContainer = Client.DefaultSubscription.GetProviders();

            Assert.IsTrue(await providerContainer.CheckIfExistsAsync("microsoft.insights"));
            var response = await providerContainer.CheckIfExistsAsync("DoesNotExist");

            Assert.False(response);
        }
Exemplo n.º 6
0
        public async Task Unregister()
        {
            ProviderContainer   providerContainer = Client.DefaultSubscription.GetProviders();
            Response <Provider> response          = await providerContainer.GetAsync("microsoft.insights");

            var result     = response.Value;
            var unregister = await result.UnregisterAsync("microsoft.insights");

            Assert.IsNotNull(unregister);
        }
Exemplo n.º 7
0
        public async Task TryGet()
        {
            ProviderContainer providerContainer = Client.DefaultSubscription.GetProviders();
            Provider          provider          = await providerContainer.GetIfExistsAsync("microsoft.insights");

            Assert.IsNotNull(provider);

            var response = await providerContainer.GetIfExistsAsync("DoesNotExist");

            Assert.IsNull(response.Value);
        }
Exemplo n.º 8
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            VerificationManager.Register(new ApiVerification());

            ProviderContainer.Register <Facade.User.UserAccountProfile>();
            ProviderContainer.Register <Facade.User.UserOrganizationsProfile>();
            ProviderContainer.Register <Facade.User.UserAscriptionProfile>();
        }
Exemplo n.º 9
0
        public async Task Get()
        {
            ProviderContainer   providerContainer = Client.DefaultSubscription.GetProviders();
            Response <Provider> response          = await providerContainer.GetAsync("microsoft.insights");

            Provider result = response.Value;

            Assert.IsNotNull(result);

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await Client.GetProvider(result.Data.Id + "x").GetAsync());

            Assert.AreEqual(404, ex.Status);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Saves the data.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="uploadedFile"></param>
        /// <param name="file">The file.</param>
        /// <param name="fileType"></param>
        public override void SaveData(HttpContext context, HttpPostedFile uploadedFile, BinaryFile file, BinaryFileType fileType)
        {
            // Check to see if we should flip the image.
            try
            {
                file.FileName = Path.GetFileName(uploadedFile.FileName);
                file.MimeType = uploadedFile.ContentType;

                Bitmap bmp  = new Bitmap(uploadedFile.InputStream);
                var    exif = new EXIFextractor(ref bmp, "\n");
                if (exif["Orientation"] != null)
                {
                    RotateFlipType flip = OrientationToFlipType(exif["Orientation"].ToString());
                    if (flip != RotateFlipType.RotateNoneFlipNone)   // don't flip if orientation is correct
                    {
                        bmp.RotateFlip(flip);
                        exif.setTag(0x112, "1");   // reset orientation tag
                    }
                }

                if (context.Request.QueryString["enableResize"] != null)
                {
                    Bitmap resizedBmp = RoughResize(bmp, 1024, 768);
                    bmp = resizedBmp;
                }

                using (var stream = new MemoryStream())
                {
                    bmp.Save(stream, ContentTypeToImageFormat(file.MimeType));

                    if (file.Data == null)
                    {
                        file.Data = new BinaryFileData();
                    }

                    file.Data.Content = stream.ToArray();
                }

                // Use provider to persist file
                var provider = fileType != null
                    ? ProviderContainer.GetComponent(fileType.StorageEntityType.Name)
                    : ProviderContainer.DefaultComponent;

                provider.SaveFile(file, null);
            }
            catch (Exception ex)
            {
                ExceptionLogService.LogException(ex, context);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Saves the data.
        /// </summary>
        /// <param name="context">The current HTTP context.</param>
        /// <param name="uploadedFile">The file that was uploaded</param>
        /// <param name="file">The file.</param>
        /// <param name="fileType">The file type.</param>
        public virtual void SaveData(HttpContext context, HttpPostedFile uploadedFile, BinaryFile file, BinaryFileType fileType)
        {
            var provider = fileType != null
                ? ProviderContainer.GetComponent(fileType.StorageEntityType.Name)
                : ProviderContainer.DefaultComponent;

            file.MimeType = uploadedFile.ContentType;
            file.FileName = Path.GetFileName(uploadedFile.FileName);
            var bytes = new byte[uploadedFile.ContentLength];

            uploadedFile.InputStream.Read(bytes, 0, uploadedFile.ContentLength);
            file.Data = new BinaryFileData {
                Content = bytes
            };
            provider.SaveFile(file, null);
        }
Exemplo n.º 12
0
        protected async Task <string> GetFirstUsableLocationAsync(ProviderContainer providersClient, string resourceProviderNamespace, string resourceType)
        {
            var provider = (await providersClient.GetAsync(resourceProviderNamespace)).Value;

            return(provider.Data.ResourceTypes.Where(
                       (resType) =>
            {
                if (resType.ResourceType == resourceType)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
                       ).First().Locations.FirstOrDefault());
        }
Exemplo n.º 13
0
        public Dictionary <string, object> GetUserInfo(string userCode)
        {
            IUser user = xUtils.GetUserByCode(userCode);

            if (user == null)
            {
                return(null);
            }
            var dic = new Dictionary <string, object>();

            dic.Add("UserCode", user.UserCode);            //账号
            dic.Add("UserName", user.UserName);            //姓名
            dic.Add("Register_Time", user.Register_Time);  //注册时间
            dic.Add("Avatar", user.Avatar);                //头像
            dic.Add("User_Level", user.Grade.Level);       //会员等级
            dic.Add("Auth_Status", (int)user.Auth_Status); //认证状态
            dic.Add("UserStatus", (int)user.Status);       //账户状态
            dic.Add("HasPayPwd", user.HasPayPassword());   //是否已设置支付密码
            FillIdentityInfo(user.UserId, dic);            //填充认证信息
            FillShareInfo(user.UserId, dic);               //填充分享链接
            FillInviterInfo(user.Refer_ID, dic);           //填充推荐人信息
            var         list  = ProviderContainer.GetProviders <IUserProfile>();
            List <Task> tasks = new List <Task>();

            foreach (var item in list)
            {
                //多线程获取用户资料
                tasks.Add(
                    Task.Factory.StartNew(() =>
                {
                    if (!dic.ContainsKey(item.PropertyName))
                    {
                        object value = item.GetProfile(user);
                        dic.Add(item.PropertyName, value);
                    }
                }));
            }
            //同步线程
            Task.WaitAll(tasks.ToArray());
            return(dic);
        }
        public IEnumerable <Element> Provide(ElementProviderContext context, EntityToken token)
        {
            var folder = (FormFolderEntityToken)token;

            if (folder.FolderType != "Fields")
            {
                yield break;
            }

            var form = ModelsFacade.GetModel(folder.FormName);

            if (form == null)
            {
                yield break;
            }

            if (_entityTokenHandlers == null)
            {
                _entityTokenHandlers = new ProviderContainer <IElementProviderFor>("FormBuilder");
            }

            foreach (var field in form.Fields)
            {
                var elementHandle = context.CreateElementHandle(new FormFieldEntityToken(form.Name, field.Name));
                var fieldElement  = new Element(elementHandle)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = field.Name,
                        ToolTip     = field.Name,
                        HasChildren = _entityTokenHandlers.GetProvidersFor(elementHandle.EntityToken).Any(),
                        Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                };

                yield return(fieldElement);
            }
        }
Exemplo n.º 15
0
 public MainViewModel(string configuration)
 {
     m_providers = ProviderContainer.GetProviders(configuration);
 }
Exemplo n.º 16
0
        public void GetEmptyException()
        {
            ProviderContainer providerContainer = Client.DefaultSubscription.GetProviders();

            Assert.ThrowsAsync <ArgumentException>(async() => { await providerContainer.GetAsync(""); });
        }
Exemplo n.º 17
0
        private void Init()
        {
            container = CreateChild <UguiObject>("container", 0);
            {
                container.Anchor = AnchorType.TopStretch;
                container.Pivot  = PivotType.Top;
                container.Y      = 0f;
                container.SetOffsetHorizontal(0f);
                container.Height = FoldedHeight;

                providerContainer = container.CreateChild <ProviderContainer>("provider", 1);
                {
                    providerContainer.Anchor = AnchorType.TopStretch;
                    providerContainer.Pivot  = PivotType.Top;
                    providerContainer.SetOffsetHorizontal(0f);
                    providerContainer.Y      = 0f;
                    providerContainer.Height = ProviderControllerHeight;
                }
                bannerContainer = container.CreateChild <BannerContainer>("banner", 0);
                {
                    bannerContainer.Anchor         = AnchorType.Fill;
                    bannerContainer.Offset         = new Offset(0f, 54f, 0f, 96f);
                    bannerContainer.IsInteractible = false;
                }
                searchBarContainer = container.CreateChild <SearchBarContainer>("search-bar", 2);
                {
                    searchBarContainer.Anchor = AnchorType.BottomStretch;
                    searchBarContainer.Pivot  = PivotType.Bottom;
                    searchBarContainer.SetOffsetHorizontal(0f);
                    searchBarContainer.Y      = 0f;
                    searchBarContainer.Height = SearchBarHeight;

                    searchBarContainer.AdvancedButton.OnTriggered += OnAdvancedButton;
                }
            }
            shadowButton = CreateChild <ShadowButton>("shadow", 1);
            {
                shadowButton.Anchor = AnchorType.Fill;
                shadowButton.Offset = new Offset(0f, FoldedHeight, 0f, 0f);
                shadowButton.Active = false;
                shadowButton.Alpha  = 0f;

                shadowButton.OnTriggered += OnShadowButton;
            }
            scrollTopButton = CreateChild <ScrollTopButton>("scroll-button", 2);
            {
                scrollTopButton.Anchor = AnchorType.Bottom;
                scrollTopButton.Y      = -28f;
                scrollTopButton.Size   = new Vector2(120f, 24f);
                scrollTopButton.Active = false;

                scrollTopButton.OnTriggered += OnScrollTopButton;
            }

            foldAni = new Anime();
            foldAni.AddEvent(0f, () => bannerContainer.IsInteractible = false);
            foldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, FoldedHeight)
            .Build();
            foldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            foldAni.AddEvent(0f, () => shadowButton.Active = false);

            unfoldAni = new Anime();
            unfoldAni.AddEvent(0f, () => shadowButton.Active = true);
            unfoldAni.AnimateFloat(h =>
            {
                container.Height = h;
                shadowButton.SetOffsetTop(h);
                bannerContainer.AdjustBannerTexture();
            })
            .AddTime(0f, () => container.Height)
            .AddTime(0.25f, UnfoldedHeight)
            .Build();
            unfoldAni.AnimateFloat(a => shadowButton.Alpha = a)
            .AddTime(0f, () => shadowButton.Alpha)
            .AddTime(0.25f, 0.5f)
            .Build();
            unfoldAni.AddEvent(unfoldAni.Duration, () => bannerContainer.IsInteractible = true);

            scrollButtonShowAni = new Anime();
            scrollButtonShowAni.AddEvent(0f, () => scrollTopButton.Active = true);
            scrollButtonShowAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 0f, 1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 0f, 28f, 0f);
            }).AddTime(0f, 0f, EaseType.BackEaseOut)
            .AddTime(0.25f, 1f)
            .Build();

            scrollButtonHideAni = new Anime();
            scrollButtonHideAni.AnimateFloat((i) =>
            {
                scrollTopButton.Alpha = Easing.Linear(i, 1f, -1f, 0f);
                scrollTopButton.Y     = Easing.Linear(i, 28f, -28f, 0f);
            }).AddTime(0f, 0f, EaseType.SineEaseOut)
            .AddTime(0.25f, 1f)
            .Build();
            scrollButtonHideAni.AddEvent(scrollButtonHideAni.Duration, () => scrollTopButton.Active = false);

            OnEnableInited();
        }
 public LocalizationPageAttachingProvider()
 {
     EntityTokenHandlers    = new ProviderContainer <IElementProviderFor>("Localization");
     ElementActionProviders = new ProviderContainer <IElementActionProviderFor>("Localization");
 }
Exemplo n.º 19
0
        /// <summary>
        /// Provides an end method for an asynchronous process.
        /// </summary>
        /// <param name="result">An IAsyncResult that contains information about the status of the process.</param>
        public void EndProcessRequest(IAsyncResult result)
        {
            HttpContext context = (HttpContext)result.AsyncState;

            try
            {
                // restore the command from the context
                SqlCommand cmd = (SqlCommand)context.Items["cmd"];
                using (SqlDataReader reader = cmd.EndExecuteReader(result))
                {
                    reader.Read();
                    context.Response.Clear();
                    var fileName = (string)reader["FileName"];
                    context.Response.AddHeader("content-disposition", string.Format("inline;filename={0}", fileName));
                    context.Response.ContentType = (string)reader["MimeType"];

                    var entityTypeName = (string)reader["StorageTypeName"];
                    var provider       = ProviderContainer.GetComponent(entityTypeName);

                    if (provider is Database)
                    {
                        context.Response.BinaryWrite((byte[])reader["Data"]);
                    }
                    else
                    {
                        var    url = (string)reader["Url"];
                        Stream stream;

                        if (url.StartsWith("~/"))
                        {
                            var path     = context.Server.MapPath(url);
                            var fileInfo = new FileInfo(path);
                            stream = fileInfo.Open(FileMode.Open, FileAccess.Read);
                        }
                        else
                        {
                            var request  = WebRequest.Create(url);
                            var response = request.GetResponse();
                            stream = response.GetResponseStream();
                        }

                        if (stream != null)
                        {
                            using (var memoryStream = new MemoryStream())
                            {
                                stream.CopyTo(memoryStream);
                                stream.Close();
                                context.Response.BinaryWrite(memoryStream.ToArray());
                            }
                        }
                        else
                        {
                            context.Response.StatusCode        = 404;
                            context.Response.StatusDescription = "Unable to find the requested file.";
                        }
                    }

                    context.Response.Flush();
                    context.Response.End();
                }
            }
            catch (Exception ex)
            {
                ExceptionLogService.LogException(ex, context);
                context.Response.StatusCode        = 500;
                context.Response.StatusDescription = ex.Message;
                context.Response.Flush();
                context.Response.End();
            }
        }