Example #1
0
        public static Web DecideWeb(this CSOMOperation operation)
        {
            operation.LogTrace($"Deciding which web to use by operation level: {operation.OperationLevel}");
            switch (operation.OperationLevel)
            {
            case OperationLevels.Site:
                operation.LogTrace("Using last site root web");
                return(operation.LastSite.RootWeb);

            case OperationLevels.Web:
                operation.LogTrace("Using last loaded web");
                return(operation.LastWeb);

            case OperationLevels.List:
                operation.LogTrace("Using list's parent web");
                return(operation.LastList.ParentWeb);

            default:
                operation.LogWarn("Not sure how did you end up here but for the current operation level there is no predefined web to load.");
                return(null);                        //todo throw exception
            }
        }