예제 #1
0
        public ClientActionInvokeStaticMethod(ClientRuntimeContext context, string typeId, string methodName, object[] parameters) : base(context, null, methodName)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            ClientAction.CheckActionParametersInContext(context, parameters);
            this.m_typeId               = typeId;
            this.m_parameters           = parameters;
            this.m_serializationContext = new SerializationContext(context);
            this.m_sb = new ChunkStringBuilder();
            XmlWriter xmlWriter = this.m_sb.CreateXmlWriter();

            this.WriteToXmlPrivate(xmlWriter, this.m_serializationContext);
            xmlWriter.Dispose();// Close();
            this.m_parameters = null;
        }
        private static void FormsAuthenticationLogin(ClientRuntimeContext context, HttpWebRequest request)
        {
            if (context.FormsAuthenticationLoginInfo == null)
            {
                throw new ArgumentNullException(Resources.GetString("MissedFormsAuthLoginInfo"));
            }
            Uri contextUri           = new Uri(context.Url);
            CookieCollection cookies = context.FormsAuthenticationLoginInfo.EnsureLogin(contextUri);

            if (request.CookieContainer == null)
            {
                request.CookieContainer = new CookieContainer();
            }
            //Edited for .NET Core
            //request.CookieContainer.Add(cookies);
            request.CookieContainer.Add(contextUri, cookies);
        }
예제 #3
0
        public SPWebRequestExecutor(ClientRuntimeContext context, string requestUrl)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(requestUrl))
            {
                throw new ArgumentNullException("requestUrl");
            }
            this.m_context    = context;
            this.m_webRequest = (HttpWebRequest)System.Net.WebRequest.Create(requestUrl);

            //Edited for .NET Core
            //this.m_webRequest.Timeout = context.RequestTimeout;
            this.m_webRequest.ContinueTimeout = context.RequestTimeout;
            this.m_webRequest.Method          = "POST";
        }
예제 #4
0
 public static IFromJson CreateObjectFromFallbackScriptType(Type fallbackType, ClientRuntimeContext context)
 {
     ScriptTypeMap.EnsureInited();
     ScriptTypeMap.ScriptTypeInfo scriptTypeInfo = null;
     if (ScriptTypeMap.s_typeToScriptTypeMap.TryGetValue(fallbackType, out scriptTypeInfo))
     {
         IFromJson result;
         if (scriptTypeInfo.ValueObject)
         {
             result = (Activator.CreateInstance(fallbackType) as IFromJson);
         }
         else
         {
             object[] array = new object[2];
             array[0] = context;
             result   = (Activator.CreateInstance(fallbackType, array) as IFromJson);
         }
         return(result);
     }
     return(null);
 }
 private void ProcessResponseStream(Stream responseStream)
 {
     StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
     JsonReader jsonReader = new JsonReader(reader, this.m_context);
     jsonReader.ReadArrayStart();
     Dictionary<string, object> dictionary = jsonReader.ReadObject() as Dictionary<string, object>;
     if (dictionary == null)
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     object obj;
     if (!dictionary.TryGetValue("SchemaVersion", out obj))
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     string text = obj as string;
     if (string.IsNullOrEmpty(text))
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     this.m_context.ServerSchemaVersion = new Version(text);
     if (!dictionary.TryGetValue("LibraryVersion", out obj))
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     string text2 = obj as string;
     if (string.IsNullOrEmpty(text2))
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     this.m_context.ServerLibraryVersion = new Version(text2);
     if (dictionary.TryGetValue("TraceCorrelationId", out obj))
     {
         this.m_context.SetTraceCorrelationId(obj as string);
     }
     if (!dictionary.TryGetValue("ErrorInfo", out obj))
     {
         throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
     }
     object obj2 = obj;
     if (obj2 != null)
     {
         Dictionary<string, object> dictionary2 = obj2 as Dictionary<string, object>;
         if (dictionary2 == null)
         {
             throw new ClientRequestException(Resources.GetString("RequestUnknownResponse"));
         }
         ServerException ex = ServerException.CreateFromErrorInfo(dictionary2);
         throw ex;
     }
     else
     {
         if (!ClientRuntimeContext.CanHandleResponseSchema(this.m_context.ServerSchemaVersion))
         {
             throw new ClientRequestException(Resources.GetString("CannotHandleServerResponseSchema", new object[]
             {
                 text
             }));
         }
         while (jsonReader.PeekTokenType() != JsonTokenType.ArrayEnd)
         {
             long num = jsonReader.ReadInt64();
             obj = null;
             if (this.m_queryIdToObjectMap.TryGetValue(num.ToString(CultureInfo.InvariantCulture), out obj) && obj != null)
             {
                 ClientObject clientObject = obj as ClientObject;
                 string scriptType = null;
                 if (clientObject != null && jsonReader.PeekTokenType() == JsonTokenType.ObjectStart && jsonReader.PeekObjectType(out scriptType))
                 {
                     Type typeFromScriptType = ScriptTypeMap.GetTypeFromScriptType(scriptType);
                     if (typeFromScriptType != null && typeFromScriptType != clientObject.GetType())
                     {
                         ClientObject clientObject2 = ScriptTypeMap.CreateObjectFromScriptType(scriptType, this.Context) as ClientObject;
                         if (clientObject2 != null)
                         {
                             clientObject.SetTypedObject(clientObject2);
                             obj = clientObject2;
                         }
                     }
                 }
                 IFromJson fromJson = obj as IFromJson;
                 if (fromJson != null && !fromJson.CustomFromJson(jsonReader))
                 {
                     fromJson.FromJson(jsonReader);
                 }
             }
             else
             {
                 jsonReader.ReadObject();
             }
         }
         return;
     }
 }
예제 #6
0
 public ObjectPathStaticProperty(ClientRuntimeContext context, string typeId, string propertyName) : base(context, null, true)
 {
     this.m_typeId       = typeId;
     this.m_propertyName = propertyName;
 }
 public ObjectPathProperty(ClientRuntimeContext context, ObjectPath parent, string propertyName) : base(context, parent, true)
 {
     this.m_propertyName = propertyName;
 }
예제 #8
0
 public abstract WebRequestExecutor CreateWebRequestExecutor(ClientRuntimeContext context, string requestUrl);
 public ObjectPathIdentity(ClientRuntimeContext context, string identity) : base(context, null, false)
 {
     this.m_identity = identity;
 }
        public ClientActionSetProperty(ClientObject obj, string propName, object propValue) : base(ClientRuntimeContext.GetContextFromClientObject(obj), (obj == null) ? null : obj.Path, propName)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            if (obj.Path == null || !obj.Path.IsValid)
            {
                throw new ClientRequestException(Resources.GetString("NoObjectPathAssociatedWithObject"));
            }
            ClientAction.CheckActionParameterInContext(obj.Context, propValue);
            this.m_propName             = propName;
            this.m_propValue            = propValue;
            this.m_serializationContext = new SerializationContext(obj.Context);
            this.m_sb = new ChunkStringBuilder();
            XmlWriter xmlWriter = this.m_sb.CreateXmlWriter();

            this.WriteToXmlPrivate(xmlWriter, this.m_serializationContext);
            xmlWriter.Dispose();//.Close();
            this.m_propValue = null;
        }
예제 #11
0
 internal ExceptionHandlingExecutionScope(ClientRuntimeContext context, ExceptionHandlingScope scope, ExecutionScopeDisposingCallback callback) : base(context, "ExceptionHandlingScope", callback)
 {
     this.m_scope = scope;
 }
 protected ClientObjectCollection(ClientRuntimeContext context, ObjectPath objectPath) : base(context, objectPath)
 {
 }
예제 #13
0
 public ObjectIdentityQuery(ObjectPath objectPath) : base(ClientRuntimeContext.GetContextFromObjectPath(objectPath), objectPath, null)
 {
 }
 public ClientActionInstantiateObjectPath(ObjectPath path) : base(ClientRuntimeContext.GetContextFromObjectPath(path), path, null)
 {
 }
        public ClientActionInvokeMethod(ClientObject obj, string methodName, object[] parameters) : base(ClientRuntimeContext.GetContextFromClientObject(obj), (obj == null) ? null : obj.Path, methodName)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            ClientAction.CheckActionParametersInContext(obj.Context, parameters);
            this.m_parameters = parameters;
            if (obj.Path == null || !obj.Path.IsValid)
            {
                throw new ClientRequestException(Resources.GetString("NoObjectPathAssociatedWithObject"));
            }
            this.m_version = obj.ObjectData.Version;
            this.m_serializationContext = new SerializationContext(obj.Context);
            this.m_sb = new ChunkStringBuilder();
            XmlWriter xmlWriter = this.m_sb.CreateXmlWriter();

            this.WriteToXmlPrivate(xmlWriter, this.m_serializationContext);
            xmlWriter.Dispose();// Close();
            this.m_parameters = null;
        }