当前位置: 首页>>代码示例>>C#>>正文


C# IContainerOwner.IsAccountContainer方法代码示例

本文整理汇总了C#中IContainerOwner.IsAccountContainer方法的典型用法代码示例。如果您正苦于以下问题:C# IContainerOwner.IsAccountContainer方法的具体用法?C# IContainerOwner.IsAccountContainer怎么用?C# IContainerOwner.IsAccountContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContainerOwner的用法示例。


在下文中一共展示了IContainerOwner.IsAccountContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDefaultViewRelativeToRequester

        /// <summary>
        /// Creates default views and returns the one relative to the requester
        /// </summary>
        /// <param name="requesterLocation">Requester relative location</param>
        /// <param name="informationObject">Information object to create the view for</param>
        /// <param name="owner">Container owner</param>
        /// <returns></returns>
        public static CloudBlob CreateDefaultViewRelativeToRequester(string requesterLocation, IInformationObject informationObject, IContainerOwner owner)
        {
            bool isAccountOwner = owner.IsAccountContainer();
            bool isGroupOwner = owner.IsGroupContainer();
            bool isDeveloperView = owner.ContainerName == "dev";
            string[] viewLocations;
            if (isAccountOwner)
                viewLocations = FixedAccountSiteLocations;
            else if (isGroupOwner)
                viewLocations = FixedGroupSiteLocations;
            else throw new NotSupportedException("Invalid owner container type for default view (non acct, non group): " + owner.ContainerName);

            string requesterDirectory = StorageSupport.GetLocationParentDirectory(requesterLocation);
            FileInfo fileInfo = new FileInfo(requesterLocation);
            //string viewRoot = fileInfo.Directory.Parent != null
            //                      ? fileInfo.Directory.Parent.Name
            //                      : fileInfo.Directory.Name;
            CloudBlob relativeViewBlob = null;
            bool hasException = false;
            bool allException = true;
            foreach (string viewLocation in viewLocations)
            {
                try
                {
                    string viewRoot = isDeveloperView ? "developer-00000000000000000000000000" : GetViewRoot(viewLocation);
                    string viewItemDirectory = Path.Combine(viewRoot, viewLocation).Replace("\\", "/") + "/";
                    string viewName = GetDefaultStaticViewName(informationObject);
                    string viewTemplateName = GetDefaultStaticTemplateName(informationObject);
                    // TODO: Relative from xyzsite => xyztemplate; now we only have website - also acct/grp specific
                    //string viewTemplateLocation = "webtemplate/oip-viewtemplate/" + viewTemplateName;
                    string viewTemplateLocation = viewItemDirectory + viewTemplateName;
                    CloudBlob viewTemplate = StorageSupport.CurrActiveContainer.GetBlob(viewTemplateLocation, owner);
                    string renderedViewLocation = viewItemDirectory + viewName;
                    CloudBlob renderTarget = StorageSupport.CurrActiveContainer.GetBlob(renderedViewLocation, owner);
                    InformationSource defaultSource = InformationSource.GetAsDefaultSource(informationObject);
                    RenderWebSupport.RenderTemplateWithContentToBlob(viewTemplate, renderTarget, defaultSource);
                    if (viewItemDirectory == requesterDirectory)
                        relativeViewBlob = renderTarget;
                    allException = false;
                }
                catch (Exception ex)
                {
                    hasException = true;
                }

            }
            if (relativeViewBlob == null && hasException == false && false)
                throw new InvalidDataException(
                    String.Format("Default view with relative location {0} not found for owner type {1}",
                                  requesterLocation, owner.ContainerName));
            return relativeViewBlob;
        }
开发者ID:kallex,项目名称:Caloom,代码行数:59,代码来源:DefaultViewSupport.cs

示例2: HandleOwnerGetRequest

        private void HandleOwnerGetRequest(IContainerOwner containerOwner, HttpContext context, string contentPath)
        {
            if(String.IsNullOrEmpty(contentPath) == false && contentPath.EndsWith("/") == false)
                validateThatOwnerGetComesFromSameReferer(containerOwner, context.Request, contentPath);
            if ((context.Request.Url.Host == "localhost" || context.Request.Url.Host == "localdev") &&
                (contentPath.Contains("groupmanagement/") ||
                contentPath.Contains("wwwsite/") ||
                contentPath.Contains("webview/") ||
                (contentPath.Contains("webui/") && containerOwner is TBAccount) ||
                contentPath.StartsWith("cpanel/") ||
                (contentPath.Contains("foundation-one/") && containerOwner is TBAccount) ||
                contentPath.Contains("categoriesandcontent/") ||
                contentPath.Contains("controlpanel_comments_v1/")))
            {
                HandleFileSystemGetRequest(containerOwner, context, contentPath);
                return;
            }
            if (String.IsNullOrEmpty(contentPath) || contentPath.EndsWith("/"))
            {
                CloudBlob redirectBlob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath +
                                                                      InstanceConfiguration.RedirectFromFolderFileName);
                string redirectToUrl = null;
                try
                {
                    redirectToUrl = redirectBlob.DownloadText();
                }
                catch
                {

                }
                if (redirectToUrl == null)
                {
                    if (containerOwner.IsAccountContainer())
                        redirectToUrl = InstanceConfiguration.AccountDefaultRedirect;
                    else
                        redirectToUrl = InstanceConfiguration.GroupDefaultRedirect;
                }
                context.Response.Redirect(redirectToUrl, true);
                return;
            }
            if (contentPath.Contains("/MediaContent/"))
            {
                int lastIndexOfSlash = contentPath.LastIndexOf('/');
                var strippedPath = contentPath.Substring(0, lastIndexOfSlash);
                int lastIndexOfMediaContent = strippedPath.LastIndexOf("/MediaContent/");
                if (lastIndexOfMediaContent > 0) // Still found MediaContent after stripping the last slash
                    contentPath = strippedPath;
            }
            CloudBlob blob = StorageSupport.GetOwnerBlobReference(containerOwner, contentPath);
            var response = context.Response;
            // Read blob content to response.
            response.Clear();
            try
            {
                HandleBlobRequestWithCacheSupport(context, blob, response);
            } catch(StorageClientException scEx)
            {
                if(scEx.ErrorCode == StorageErrorCode.BlobNotFound || scEx.ErrorCode == StorageErrorCode.ResourceNotFound || scEx.ErrorCode == StorageErrorCode.BadRequest)
                {
                    response.Write("Blob not found or bad request: " + blob.Name + " (original path: " + context.Request.Path + ")");
                    response.StatusCode = (int)scEx.StatusCode;
                } else
                {
                    response.Write("Error code: " + scEx.ErrorCode.ToString() + Environment.NewLine);
                    response.Write(scEx.ToString());
                    response.StatusCode = (int)scEx.StatusCode;
                }
            }
            catch (Exception ex)
            {
                response.StatusCode = 500;
                string errMsg = ex.ToString();
                response.Write(errMsg);
            }
            response.End();
        }
开发者ID:kallex,项目名称:Caloom,代码行数:76,代码来源:AuthorizedBlobStorageHandler.cs


注:本文中的IContainerOwner.IsAccountContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。