public IDisposable StartScope()
 {
     if (this.m_executionScope != null)
     {
         throw ExceptionHandlingScope.CreateInvalidUsageException();
     }
     this.m_executionScope = new ExceptionHandlingExecutionScope(this.m_context, this, new ExecutionScopeDisposingCallback(this.ExceptionHandlingScopeDisposingCallback));
     this.m_context.PendingRequest.AddQueryIdAndResultObject(this.m_executionScope.Id, this);
     return(this.m_executionScope);
 }
Esempio n. 2
0
 public void Dispose()
 {
     if (this.m_disposed)
     {
         throw ExceptionHandlingScope.CreateInvalidUsageException();
     }
     if (this.m_disposingCallback != null)
     {
         this.m_disposingCallback();
     }
     if (this.m_context.PendingRequest.ExecutionScopes.Count > 0 && this.m_context.PendingRequest.ExecutionScopes.Pop() == this)
     {
         this.m_context.PendingRequest.AddQuery(new ClientActionExecutionScopeEnd(this, this.m_name));
         this.m_disposed = true;
         return;
     }
     throw ExceptionHandlingScope.CreateInvalidUsageException();
 }
        public IDisposable StartFinally()
        {
            if (this.m_executionScope == null || this.m_executionScope.Disposed || this.m_tryScope == null || !this.m_tryScope.Disposed || (this.m_catchScope != null && !this.m_catchScope.Disposed) || this.m_finallyScope != null)
            {
                throw ExceptionHandlingScope.CreateInvalidUsageException();
            }
            ClientAction lastAction = this.m_context.PendingRequest.LastAction;

            if (lastAction == null || !(lastAction is ClientActionExecutionScopeEnd))
            {
                throw ExceptionHandlingScope.CreateInvalidUsageException();
            }
            if (((ClientActionExecutionScopeEnd)lastAction).Scope.Name != "TryScope" && ((ClientActionExecutionScopeEnd)lastAction).Scope.Name != "CatchScope")
            {
                throw ExceptionHandlingScope.CreateInvalidUsageException();
            }
            this.m_finallyScope = new ExecutionScope(this.m_context, "FinallyScope", null);
            return(this.m_finallyScope);
        }
 private void ExceptionHandlingScopeDisposingCallback()
 {
     if (this.m_tryScope != null)
     {
         if (this.m_catchScope == null && this.m_finallyScope == null)
         {
             throw ExceptionHandlingScope.CreateInvalidUsageException();
         }
         ClientAction lastAction = this.m_context.PendingRequest.LastAction;
         if (lastAction == null || !(lastAction is ClientActionExecutionScopeEnd))
         {
             throw ExceptionHandlingScope.CreateInvalidUsageException();
         }
         ClientActionExecutionScopeEnd clientActionExecutionScopeEnd = (ClientActionExecutionScopeEnd)lastAction;
         if (clientActionExecutionScopeEnd.Scope.Name != "CatchScope" && clientActionExecutionScopeEnd.Scope.Name != "FinallyScope")
         {
             throw ExceptionHandlingScope.CreateInvalidUsageException();
         }
     }
 }
 private ChunkStringBuilder BuildQuery()
 {
     SerializationContext serializationContext = this.SerializationContext;
     ChunkStringBuilder chunkStringBuilder = new ChunkStringBuilder();
     XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
     xmlWriterSettings.OmitXmlDeclaration = true;
     xmlWriterSettings.NewLineHandling = NewLineHandling.Entitize;
     XmlWriter xmlWriter = XmlWriter.Create(chunkStringBuilder.CreateTextWriter(CultureInfo.InvariantCulture), xmlWriterSettings);
     xmlWriter.WriteStartElement("Request", "http://schemas.microsoft.com/sharepoint/clientquery/2009");
     xmlWriter.WriteAttributeString("AddExpandoFieldTypeSuffix", "true");
     xmlWriter.WriteAttributeString("SchemaVersion", this.Context.RequestSchemaVersion.ToString());
     xmlWriter.WriteAttributeString("LibraryVersion", "16.0.0.0");
     if (!string.IsNullOrEmpty(this.m_context.ApplicationName))
     {
         xmlWriter.WriteAttributeString("ApplicationName", this.m_context.ApplicationName);
     }
     xmlWriter.WriteStartElement("Actions");
     Stack<ExecutionScope> stack = new Stack<ExecutionScope>();
     foreach (ClientAction current in this.m_queries)
     {
         if (current is ClientActionExecutionScopeStart)
         {
             ClientActionExecutionScopeStart clientActionExecutionScopeStart = (ClientActionExecutionScopeStart)current;
             clientActionExecutionScopeStart.Scope.WriteStart(xmlWriter, serializationContext);
             stack.Push(clientActionExecutionScopeStart.Scope);
         }
         else if (current is ClientActionExecutionScopeEnd)
         {
             ClientActionExecutionScopeEnd clientActionExecutionScopeEnd = (ClientActionExecutionScopeEnd)current;
             if (stack.Count == 0 || stack.Pop() != clientActionExecutionScopeEnd.Scope)
             {
                 throw ExceptionHandlingScope.CreateInvalidUsageException();
             }
             clientActionExecutionScopeEnd.Scope.WriteEnd(xmlWriter, serializationContext);
         }
         else
         {
             current.WriteToXml(xmlWriter, serializationContext);
         }
     }
     if (stack.Count > 0)
     {
         throw ExceptionHandlingScope.CreateInvalidUsageException();
     }
     xmlWriter.WriteEndElement();
     xmlWriter.WriteStartElement("ObjectPaths");
     Dictionary<long, ObjectPath> dictionary = new Dictionary<long, ObjectPath>();
     while (true)
     {
         List<long> list = new List<long>();
         foreach (long current2 in serializationContext.Paths.Keys)
         {
             if (!dictionary.ContainsKey(current2))
             {
                 list.Add(current2);
             }
         }
         if (list.Count == 0)
         {
             break;
         }
         for (int i = 0; i < list.Count; i++)
         {
             ObjectPath objectPath = this.m_context.ObjectPaths[list[i]];
             objectPath.WriteToXml(xmlWriter, serializationContext);
             dictionary[list[i]] = objectPath;
         }
     }
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
     xmlWriter.Flush();
     return chunkStringBuilder;
 }
Esempio n. 6
0
 internal ExceptionHandlingExecutionScope(ClientRuntimeContext context, ExceptionHandlingScope scope, ExecutionScopeDisposingCallback callback) : base(context, "ExceptionHandlingScope", callback)
 {
     this.m_scope = scope;
 }