public async Task <ContentItem> AssignGroupAsync(ContentItem profile, string groupContentItemId)
        {
            if (profile == null)
            {
                return(null);
            }

            using (var scope = await _shellHost.GetScopeAsync(_shellSettings))
            {
                var contentManager = scope.ServiceProvider.GetRequiredService <IContentManager>();

                profile.Alter <ProfileGroupedPart>(x => x.GroupContentItemId = groupContentItemId);

                profile.Apply(nameof(ProfileGroupedPart), profile.As <ProfileGroupedPart>());
                ContentExtensions.Apply(profile, profile);

                await contentManager.UpdateAsync(profile);

                await contentManager.PublishAsync(profile);

                await _session.CommitAsync();

                return(profile);
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task <PlaidResult <AccessTokenResponse> > ExchangePublicTokenForAccessTokenAsync(string publicToken)
        {
            //conditions
            Condition.Requires(publicToken).IsNotNullOrWhiteSpace();

            //create the payload to pass
            var payload = new ExchangePublicTokenForAccessTokenRequest(clientId, clientSecret, publicToken);

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.LinkEndpoint_ExchangePublicToken, content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <AccessTokenResponse> result = new PlaidResult <AccessTokenResponse>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                AccessTokenResponse exchangeTokenResponse = JsonConvert.DeserializeObject <AccessTokenResponse>(responseJson);
                result.Value = exchangeTokenResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async Task <PlaidResult <ListOfCategoriesResponse> > GetListOfCategoriesAsync()
        {
            //create the payload to pass
            var payload = string.Empty;

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync("categories/get", content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <ListOfCategoriesResponse> result = new PlaidResult <ListOfCategoriesResponse>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                ListOfCategoriesResponse listCategoriesResponse = JsonConvert.DeserializeObject <ListOfCategoriesResponse>(responseJson);
                result.Value = listCategoriesResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public async Task <PlaidResult <ListOfInstitutionsResponse> > SearchInstitutions(string query, IList <string> products = null)
        {
            //conditions
            Condition.Requires(query).IsNotNullOrWhiteSpace();

            //create the payload to pass
            var payload = new InstitutionSearchRequest(clientPublicKey, query, products);

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_SearchInstitutions, content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <ListOfInstitutionsResponse> result = new PlaidResult <ListOfInstitutionsResponse>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                ListOfInstitutionsResponse listOfInstitutionsResponse = JsonConvert.DeserializeObject <ListOfInstitutionsResponse>(responseJson);
                result.Value = listOfInstitutionsResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
Esempio n. 5
0
        public async Task <ActionResult> Index(string categoryAlias = "", string alias = "", bool isPost = false,
                                               FormCollection form  = null)
        {
            try
            {
                Log.Verbose($"Prepping \"{this.CurrentPageUrl}\".");

                var model = this.GetContents(categoryAlias, alias, isPost, form);

                if (model == null)
                {
                    Log.Error($"Could not serve the url \"{this.CurrentPageUrl}\" because the model was null.");
                    return(this.View(GetLayoutPath() + "404.cshtml"));
                }

                Log.Verbose($"Parsing custom content extensions for \"{this.CurrentPageUrl}\".");
                model.Contents = ContentExtensions.ParseHtml(this.Tenant, model.Contents);

                Log.Verbose($"Parsing custom form extensions for \"{this.CurrentPageUrl}\".");
                model.Contents = await FormsExtension.ParseHtml(model.Contents, isPost, form);

                model.Contents = HitHelper.Add(model.Contents);

                return(this.View(this.GetRazorView <AreaRegistration>("Index/Index.cshtml"), model));
            }
            catch (NpgsqlException ex)
            {
                Log.Error(
                    "An exception was encountered while trying to get content. More info:\nCategory alias: {categoryAlias}, alias: {alias}, is post: {isPost}, form: {form}. Exception\n{ex}.",
                    categoryAlias, alias, isPost, form, ex);
                return(new HttpNotFoundResult());
            }
        }
Esempio n. 6
0
        public async Task LoadReferences_DynamicProperty_Enumerable()
        {
            dynamic adminGroup = await Content.LoadAsync(new ODataRequest
            {
                Path    = Constants.Group.AdministratorsPath,
                Expand  = new[] { "Members" },
                Select  = new[] { "Id", "Name", "Members/Id", "Members/Name", "Members/Path", "Members/Type", "Members/CreationDate", "Members/Index" },
                SiteUrl = ServerContext.GetUrl(null)
            });

            //var members = ((IEnumerable<dynamic>)adminGroup.Members).ToContentEnumerable();
            //var members = adminGroup.Members.ToContentEnumerable();
            var members = ContentExtensions.ToContentEnumerable(adminGroup.Members);

            foreach (dynamic member in members)
            {
                int newIndex = member.Index + 1;
                member.Index = newIndex;

                // use the client Content API, this was the purpose of the ToContentEnumerable extension method
                await member.SaveAsync();

                // load it again from the server
                dynamic tempContent = await Content.LoadAsync(member.Id);

                Assert.AreEqual(newIndex, (int)tempContent.Index);
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        public async Task <PlaidResult <ListOfInstitutionsWithTotalResponse> > GetListOfInstitutionsAsync(int count = 500, int offset = 0)
        {
            //conditions
            Condition.Ensures(count >= 0);
            Condition.Ensures(offset >= 0);

            //create the payload to pass
            var payload = new ListOfInstitutionsRequest(clientId, clientSecret, count, offset);

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_GetInstitutions, content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <ListOfInstitutionsWithTotalResponse> result = new PlaidResult <ListOfInstitutionsWithTotalResponse>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                ListOfInstitutionsWithTotalResponse listOfInstitutionsResponse = JsonConvert.DeserializeObject <ListOfInstitutionsWithTotalResponse>(responseJson);
                result.Value = listOfInstitutionsResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
Esempio n. 8
0
        /// <inheritdoc />
        public async Task <PlaidResult <Institution> > GetInstitutionAsync(string id)
        {
            //conditions
            Condition.Requires(id).IsNotNullOrWhiteSpace();

            //create the payload to pass
            var payload = new InstitutionRequest(clientPublicKey, id);

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.Institutions_GetInstitutionsById, content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <Institution> result = new PlaidResult <Institution>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Institution institutionResponse = JsonConvert.DeserializeObject <Institution>(responseJson);
                result.Value = institutionResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
Esempio n. 9
0
        public async Task <ActionResult> Index(ProfilePage currentPage, EditProfileViewModel editViewModel)
        {
            if (SiteUser == null)
            {
                return(HttpNotFound());
            }

            if (!ModelState.IsValid)
            {
                Response.StatusCode = 400;
                return(View("~/Views/MyProfile/ProfilePage.cshtml", new ProfilePageViewModel(currentPage, editViewModel)));
            }

            await UserManager.UpdateUserInfoAsync(SiteUser.PersonDn, editViewModel.FirstName, editViewModel.LastName, editViewModel.Telephone,
                                                  editViewModel.Mobilephone, editViewModel.Email, editViewModel.Street, editViewModel.Zip, editViewModel.City);

            var newSiteUser = await UserManager.QuerySiteUserAsync(SiteUser.UserName);

            this.SetUserSession(newSiteUser);

            var settingPage = ContentExtensions.GetSettingsPage();

            TempData["UpdateInfoSuccess"] = true;

            return(RedirectToAction("Index", new { node = settingPage.MyAccountLink }));
        }
Esempio n. 10
0
        /// <summary>
        /// 渲染部分视图(重写此方法以实现自定义输出 partial 元素)
        /// </summary>
        /// <param name="partialElement">partial 元素</param>
        /// <returns></returns>
        protected virtual string RenderPartial(IHtmlElement partialElement)
        {
            var path = partialElement.Attribute("path").Value();
            var name = partialElement.Attribute("name").Value();

            try
            {
                if (!PartialExecutors.IsNullOrEmpty() && name != null)
                {
                    return(RenderNamedPartial(partialElement, name));
                }


                else if (path != null)
                {
                    return(RenderVirtualPath(path));
                }
            }
            catch //若渲染时发生错误
            {
                if (JumonyWebConfiguration.Configuration.IgnorePartialRenderException || partialElement.Attribute("ignoreError") != null)
                {
                    return("<!--parital render failed-->");
                }
                else
                {
                    throw;
                }
            }

            throw new NotSupportedException("无法处理的partial标签:" + ContentExtensions.GenerateTagHtml(partialElement, false));
        }
Esempio n. 11
0
 /// <summary>
 /// Executes custom server side validation for the model
 /// </summary>
 /// <param name="validationContext"></param>
 /// <returns></returns>
 public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
 {
     if (PreValueModel.IsRequired && Value.IsNullValueOrEmpty() && !ContentExtensions.HasFile(NewFile))
     {
         yield return(new ValidationResult("Value is required", new[] { "Value" }));
     }
 }
Esempio n. 12
0
        /// <inheritdoc />
        public async Task <PlaidResult <ItemResponse> > UpdateWebHookAsync(string accessToken, string webhook)
        {
            //conditions
            Condition.Requires(accessToken).IsNotNullOrWhiteSpace();
            Condition.Requires(webhook).IsNotNullOrWhiteSpace();

            //create the payload to pass
            var payload = new UpdateWebHookRequest(clientId, clientSecret, accessToken, webhook);

            //serialize object
            HttpContent content = ContentExtensions.ToJsonContent(payload);

            //post it and get the response
            HttpResponseMessage response = await this.httpClient.PostAsync(PlaidInformation.ItemManagement_UpdateWebhook, content);

            //read the string
            string responseJson = await response.Content.ReadAsStringAsync();

            //create the result
            PlaidResult <ItemResponse> result = new PlaidResult <ItemResponse>(responseJson);

            //is it ok
            if (response.StatusCode == HttpStatusCode.OK)
            {
                ItemResponse itemResponse = JsonConvert.DeserializeObject <ItemResponse>(responseJson);
                result.Value = itemResponse;
            }

            //parse the exception
            result.Exception = await this.ParseException(response, responseJson);

            //return
            return(result);
        }
        public void GetUrl_WhenVariationHasCode_ShouldReturnUrlWithQuery()
        {
            var variant = new VariationContent {Code = "code"};

            var result = ContentExtensions.GetUrl(variant, _linkRepositoryMock.Object, _urlResolverMock.Object);

            Assert.Equal<string>(_url + "?variationCode=" + variant.Code, result);
        }
Esempio n. 14
0
        /// <summary>
        /// 渲染 partial 标签
        /// </summary>
        /// <param name="element">partial 标签</param>
        /// <param name="context">渲染上下文</param>
        protected override void Render(IHtmlElement element, IHtmlRenderContext context)
        {
            var partialTag = ContentExtensions.GenerateTagHtml(element, true);

            Trace(string.Format("Begin Render Partial: {0}", partialTag));
            RenderPartial(element, context.Writer);
            Trace(string.Format("End Render Partial: {0}", partialTag));
        }
Esempio n. 15
0
        public void GetUrl_WhenVariationHasNoCode_ShouldReturnBaseUrl()
        {
            var variant = new VariationContent();

            var result = ContentExtensions.GetUrl(variant, _linkRepositoryMock.Object, _urlResolverMock.Object);

            Assert.AreEqual <string>(_url, result);
        }
Esempio n. 16
0
            /// <summary>
            /// 渲染 partial 标签
            /// </summary>
            /// <param name="element">partial 标签</param>
            /// <param name="writer">用于渲染的文本编写器</param>
            public override void Render(IHtmlElement element, TextWriter writer)
            {
                var partialTag = ContentExtensions.GenerateTagHtml(element, true);

                _view.HttpContext.Trace.Write("Jumony for MVC", string.Format("Begin Render Partial: {0}", partialTag));
                _view.RenderPartial(element, writer);
                _view.HttpContext.Trace.Write("Jumony for MVC", string.Format("End Render Partial: {0}", partialTag));
            }
Esempio n. 17
0
        /// <summary>
        /// 渲染 partial 标签
        /// </summary>
        /// <param name="element">partial 标签</param>
        /// <param name="context">渲染上下文</param>
        protected override void Render(IHtmlElement element, HtmlRenderContext context)
        {
            var partialTag = ContentExtensions.GenerateTagHtml(element, true);

            ViewContext.HttpContext.Trace.Write("Jumony View Engine", string.Format("Begin Render Partial: {0}", partialTag));
            RenderPartial(element, context.Writer);
            ViewContext.HttpContext.Trace.Write("Jumony View Engine", string.Format("End Render Partial: {0}", partialTag));
        }
Esempio n. 18
0
 public void CheckerColorsAreAlternatelyBrightAndDarkAsPattern()
 {
     Color[] checkerColors = ContentExtensions.GetCheckerColors();
     Assert.AreEqual(8 * 8, checkerColors.Length);
     Assert.AreEqual(Color.LightGray, checkerColors[0]);
     Assert.AreEqual(Color.DarkGray, checkerColors[1]);
     Assert.AreEqual(Color.DarkGray, checkerColors[checkerColors.Length - 2]);
     Assert.AreEqual(Color.LightGray, checkerColors[checkerColors.Length - 1]);
 }
Esempio n. 19
0
        /// <summary>
        /// 渲染部分视图
        /// </summary>
        /// <param name="partialElement">partial 元素</param>
        /// <returns></returns>
        protected virtual string RenderPartial(IHtmlElement partialElement)
        {
            var action  = partialElement.Attribute("action").Value();
            var view    = partialElement.Attribute("view").Value();
            var path    = partialElement.Attribute("path").Value();
            var handler = partialElement.Attribute("handler").Value();


            var helper = MakeHelper();


            try
            {
                if (action != null)//Action 部分视图
                {
                    var controller  = partialElement.Attribute("controller").Value() ?? (string)RouteData.Values["controller"];
                    var routeValues = GetRouteValues(partialElement);

                    return(helper.Action(actionName: action, controllerName: controller, routeValues: routeValues).ToString());
                }

                else if (view != null)
                {
                    return(helper.Partial(partialViewName: view).ToString());
                }

                else if (path != null)
                {
                    if (!VirtualPathUtility.IsAppRelative(path))
                    {
                        throw new FormatException("path 只能使用应用程序根相对路径,即以 \"~/\" 开头的路径,调用 VirtualPathUtility.ToAppRelative 方法或使用 HttpRequest.AppRelativeCurrentExecutionFilePath 属性获取");
                    }

                    var content = HtmlProviders.LoadContent(HttpContext, path);
                    if (content != null)
                    {
                        return(content.Content);
                    }
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch //若渲染时发生错误
            {
                if (MvcEnvironment.Configuration.IgnorePartialRenderException || partialElement.Attribute("ignoreError") != null)
                {
                    return("<!--parital view render failed-->");
                }
                else
                {
                    throw;
                }
            }

            throw new NotSupportedException("无法处理的partial标签:" + ContentExtensions.GenerateTagHtml(partialElement, false));
        }
Esempio n. 20
0
        private static Picture CreateANewDefaultImage(Vector2D position)
        {
            var material  = ContentExtensions.CreateDefaultMaterial2D();
            var newSprite = new Picture(new Theme(), material,
                                        Rectangle.FromCenter(position, new Size(0.05f)));

            newSprite.Set(BlendMode.Normal);
            return(newSprite);
        }
        private void CreateDefaultMaterial()
        {
            if (service.Viewport != null)
            {
                service.Viewport.DestroyRenderedEntities();                 //ncrunch: no coverage
            }
            Material material = ContentExtensions.CreateDefaultMaterial2D();

            renderExample          = new Sprite(material, new Rectangle(0.25f, 0.25f, 0.5f, 0.5f));
            renderExample.IsActive = true;
        }
Esempio n. 22
0
        /// <summary>
        /// 渲染部分视图(重写此方法以实现自定义输出 partial 元素)
        /// </summary>
        /// <param name="partialElement">partial 元素</param>
        /// <returns></returns>
        protected override string RenderPartial(IHtmlElement partialElement)
        {
            var action = partialElement.Attribute("action").Value();
            var view   = partialElement.Attribute("view").Value();
            var path   = partialElement.Attribute("path").Value();
            var name   = partialElement.Attribute("name").Value();

            if (name != null)
            {
                return(RenderNamedPartial(partialElement, name));
            }

            var helper = MakeHelper();


            try
            {
                if (action != null)//Action 部分视图
                {
                    var routeValues = Url.GetRouteValues(partialElement);

                    return(RenderAction(partialElement, action, partialElement.Attribute("controller").Value(), routeValues));
                }

                else if (view != null)
                {
                    return(RenderPartial(partialElement, view));
                }

                else if (path != null)
                {
                    RenderVirtualPath(path);
                }
            }

            catch (ThreadAbortException)
            {
                throw;//不应屏蔽异常
            }

            catch //若渲染时发生错误
            {
                if (MvcEnvironment.Configuration.IgnorePartialRenderException || partialElement.Attribute("ignoreError") != null)
                {
                    return("<!--parital view render failed-->");
                }
                else
                {
                    throw;
                }
            }

            throw new NotSupportedException("无法处理的partial标签:" + ContentExtensions.GenerateTagHtml(partialElement, false));
        }
Esempio n. 23
0
        internal override void Reload()
        {
            _Texture_Reloading = true;

            if (Metadata == null)
            {
                orig_Reload();
                _Texture_Reloading = false;
                return;
            }

            Unload();
            Texture = null;

            Stream stream = Metadata.Stream;

            if (stream != null)
            {
                bool premul = false; // Assume unpremultiplied by default.
                if (Metadata.TryGetMeta(out TextureMeta meta))
                {
                    premul = meta.Premultiplied;
                }

                using (stream) {
                    if (premul)
                    {
                        Texture = MainThreadHelper.Get(() => Texture2D.FromStream(Celeste.Celeste.Instance.GraphicsDevice, stream)).GetResult();
                    }
                    else
                    {
                        ContentExtensions.LoadTextureLazyPremultiply(Celeste.Celeste.Instance.GraphicsDevice, stream, out int w, out int h, out byte[] data);
                        Texture = MainThreadHelper.Get(() => {
                            Texture2D tex = new Texture2D(Celeste.Celeste.Instance.GraphicsDevice, w, h, false, SurfaceFormat.Color);
                            tex.SetData(data);
                            return(tex);
                        }).GetResult();
                    }
                }
            }
            else if (Fallback != null)
            {
                ((patch_VirtualTexture)(object)Fallback).Reload();
                Texture = Fallback.Texture;
            }

            if (Texture != null)
            {
                Width  = Texture.Width;
                Height = Texture.Height;
            }

            _Texture_Reloading = false;
        }
Esempio n. 24
0
        public async Task <ActionResult> CaluculateDeliveryFee(string supplier, string lorryType,
                                                               string deliveryAddressId, string quantity, string deliveryDate, string itemId)
        {
            var deliveryFeeRequest = PopulateDeliveryFeeRequest(supplier, lorryType, deliveryAddressId, quantity,
                                                                deliveryDate, itemId);

            var deliveryFeeResponse = await _shippingRepository.GetDeliveryFeeAsync(deliveryFeeRequest, _ticket);

            ViewBag.IsInternal = ContentExtensions.GetSettingsPage()?.IsInternal;
            return(PartialView("~/Views/AppPages/CalculateDeliveryFeePage/CalculationResult.cshtml", deliveryFeeResponse));
        }
Esempio n. 25
0
        public void GetUrl_WhenNoRelationExists_ShouldReturnEmptyString()
        {
            _linkRepositoryMock
            .Setup(x => x.GetRelationsByTarget <ProductVariation>(It.IsAny <ContentReference>()))
            .Returns(Enumerable.Empty <ProductVariation>());

            var variant = new VariationContent();

            var result = ContentExtensions.GetUrl(variant, _linkRepositoryMock.Object, _urlResolverMock.Object);

            Assert.AreEqual <string>(string.Empty, result);
        }
Esempio n. 26
0
        public override IDictionary <string, object> GetSerializedValue()
        {
            //generate an id if we need one
            if (MediaId == Guid.Empty)
            {
                MediaId = Guid.NewGuid();
            }

            return(ContentExtensions.WriteUploadedFile(MediaId, RemoveFile, NewFile, _hive, Value, PreValueModel.Sizes));

            var img = Image.FromStream(NewFile.InputStream);
        }
        public async Task UpdateUserIdentifier(ContentItem contentItem, IUser user)
        {
            var profilePart = contentItem.Get <ProfilePart>("ProfilePart");

            profilePart.UserIdentifier = await _userManager.GetUserIdAsync(user);

            contentItem.Apply("ProfilePart", profilePart);

            ContentExtensions.Apply(contentItem, contentItem);

            await _contentManager.UpdateAsync(contentItem);
        }
Esempio n. 28
0
        public async Task <ActionResult> HomeAsync(int pageNumber = 1)
        {
            try
            {
                if (pageNumber <= 0)
                {
                    pageNumber = 1;
                }

                var awaiter = await ContentModel.GetBlogContentsAsync(this.Tenant, pageNumber).ConfigureAwait(true);

                var contents = awaiter?.ToList() ?? new List <Content>();

                if (!contents.Any())
                {
                    return(this.View(GetLayoutPath(this.Tenant) + "404.cshtml"));
                }

                foreach (var content in contents)
                {
                    content.Contents =
                        await ContentExtensions.ParseHtmlAsync(this.Tenant, content.Contents).ConfigureAwait(false);
                }

                string theme  = this.GetTheme();
                string layout = ThemeConfiguration.GetBlogLayout(this.Tenant, theme).Or(ThemeConfiguration.GetLayout(this.Tenant, theme));

                var configuration = await Configurations.GetDefaultConfigurationAsync(this.Tenant).ConfigureAwait(false);

                var model = new Blog
                {
                    Contents   = contents,
                    LayoutPath = GetLayoutPath(this.Tenant),
                    Layout     = layout
                };

                if (configuration != null)
                {
                    model.Title       = configuration.BlogTitle;
                    model.Description = configuration.BlogDescription;
                }

                return(this.View(this.GetRazorView <AreaRegistration>("Frontend/Blog/Home.cshtml", this.Tenant), model));
            }
            catch (NpgsqlException ex)
            {
                Log.Error($"An exception was encountered while trying to get blog contents. Exception: {ex}");
            }

            return(null);
        }
Esempio n. 29
0
 private static ParticleEmitterData CreateDefaultEmitterData()
 {
     return(new ParticleEmitterData
     {
         ParticleMaterial = ContentExtensions.CreateDefaultMaterial2D(),
         LifeTime = 1,
         Size = new RangeGraph <Size>(new Size(0.01f, 0.01f), new Size(0.1f, 0.1f)),
         SpawnInterval = 0.1f,
         MaximumNumberOfParticles = 128,
         StartVelocity =
             new RangeGraph <Vector3D>(new Vector3D(-0.1f, -0.2f, 0), new Vector3D(0.4f, -0.2f, 0)),
         Acceleration =
             new RangeGraph <Vector3D>(new Vector3D(0.0f, 0.1f, 0.0f), new Vector3D(0.0f, 0.3f, 0.0f))
     });
 }
        private static async Task <ContentItem> UpdateAsync(IContentManager contentManager, ContentItem contentItem, Posting posting)
        {
            if (contentItem.DisplayText == posting.Text && contentItem.ComparePostingPart(posting))
            {
                return(contentItem);
            }

            contentItem.DisplayText = posting.Text;
            contentItem.SetLeverPostingPart(posting);

            ContentExtensions.Apply(contentItem, contentItem);

            await contentManager.UpdateAsync(contentItem);

            return(contentItem);
        }