Esempio n. 1
0
        public static ObjectPath _CreateNewObjectObjectPath(ClientRequestContext context, string typeName, bool isCollection)
        {
            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id             = context._NextId(),
                ObjectPathType = ObjectPathType.NewObject,
                Name           = typeName
            };

            return(new ObjectPath(objectPathInfo, null, isCollection, false /*isInvalidAfterRequest*/));
        }
Esempio n. 2
0
        public static ObjectPath _CreateGlobalObjectObjectPath(ClientRequestContext context)
        {
            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id             = context._NextId(),
                ObjectPathType = ObjectPathType.GlobalObject,
                Name           = ""
            };

            return(new ObjectPath(objectPathInfo, null, false /*isCollection*/, false /*isInvalidAfterRequest*/));
        }
Esempio n. 3
0
        public static ObjectPath _CreatePropertyObjectPath(ClientRequestContext context, ClientObject parent, string propertyName, bool isCollection, bool isInvalidAfterRequest)
        {
            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id                 = context._NextId(),
                ObjectPathType     = ObjectPathType.Property,
                Name               = propertyName,
                ParentObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
            };

            return(new ObjectPath(objectPathInfo, parent._ObjectPath, isCollection, isInvalidAfterRequest));
        }
Esempio n. 4
0
        public static ObjectPath _CreateIndexerObjectPathUsingParentPath(ClientRequestContext context, ObjectPath parentObjectPath, object[] args)
        {
            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id                 = context._NextId(),
                ObjectPathType     = ObjectPathType.Indexer,
                Name               = "",
                ParentObjectPathId = parentObjectPath.ObjectPathInfo.Id,
                ArgumentInfo       = new ArgumentInfo()
            };

            objectPathInfo.ArgumentInfo.Arguments = args;
            return(new ObjectPath(objectPathInfo, parentObjectPath, false /*isCollection*/, false /*isInvalidAfterRequest*/));
        }
Esempio n. 5
0
        internal static Action CreateTraceAction(ClientRequestContext context, string message)
        {
            ActionInfo actionInfo = new ActionInfo()
            {
                Id           = context._NextId(),
                ActionType   = ActionType.Trace,
                Name         = "Trace",
                ObjectPathId = 0
            };
            Action ret = new Action(actionInfo, false);

            context._PendingRequest.AddAction(ret);
            context._PendingRequest.AddTrace(actionInfo.Id, message);
            return(ret);
        }
Esempio n. 6
0
        internal static Action CreateInstantiateAction(ClientRequestContext context, ClientObject obj)
        {
            Utility.ValidateObjectPath(obj);
            ActionInfo actionInfo = new ActionInfo()
            {
                Id           = context._NextId(),
                ActionType   = ActionType.Instantiate,
                Name         = "",
                ObjectPathId = obj._ObjectPath.ObjectPathInfo.Id
            };
            var ret = new Action(actionInfo, false);

            context._PendingRequest.AddAction(ret);
            context._PendingRequest.AddReferencedObjectPath(obj._ObjectPath);
            context._PendingRequest.AddActionResultHandler(ret, new InstantiateActionResultHandler(obj));
            return(ret);
        }
Esempio n. 7
0
        public static ObjectPath _CreateMethodObjectPath(ClientRequestContext context, ClientObject parent, string methodName, OperationType operationType, object[] args, bool isCollection, bool isInvalidAfterRequest)
        {
            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id                 = context._NextId(),
                ObjectPathType     = ObjectPathType.Method,
                Name               = methodName,
                ParentObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
                ArgumentInfo       = new ArgumentInfo()
            };
            List <ObjectPath> argumentObjectPaths = Utility.SetMethodArguments(context, objectPathInfo.ArgumentInfo, args);
            ObjectPath        ret = new ObjectPath(objectPathInfo, parent._ObjectPath, isCollection, isInvalidAfterRequest);

            ret.ArgumentObjectPaths = argumentObjectPaths;
            ret.IsWriteOperation    = (operationType != OperationType.Read);
            return(ret);
        }
Esempio n. 8
0
        internal static Action CreateQueryAction(ClientRequestContext context, ClientObject parent, QueryInfo queryOption)
        {
            Utility.ValidateObjectPath(parent);
            ActionInfo actionInfo = new ActionInfo()
            {
                Id           = context._NextId(),
                ActionType   = ActionType.Query,
                Name         = "",
                ObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
            };

            actionInfo.QueryInfo = queryOption;
            Action ret = new Action(actionInfo, false);

            context._PendingRequest.AddAction(ret);
            context._PendingRequest.AddReferencedObjectPath(parent._ObjectPath);
            return(ret);
        }
Esempio n. 9
0
        public static ObjectPath _CreateChildItemObjectPathUsingGetItemAt(ClientRequestContext context, ClientObject parent, JToken childItem, int index)
        {
            JToken indexFromServer = childItem[Constants.Index];

            if (!Utility._IsNullOrUndefined(indexFromServer))
            {
                index = indexFromServer.Value <int>();
            }

            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id                 = context._NextId(),
                ObjectPathType     = ObjectPathType.Method,
                Name               = Constants.GetItemAt,
                ParentObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
                ArgumentInfo       = new ArgumentInfo()
            };

            objectPathInfo.ArgumentInfo.Arguments = new object[] { index };
            return(new ObjectPath(objectPathInfo, parent._ObjectPath, false /*isCollection*/, false /*isInvalidAfterRequest*/));
        }
Esempio n. 10
0
        public static ObjectPath _CreateChildItemObjectPathUsingIndexer(ClientRequestContext context, ClientObject parent, JToken childItem)
        {
            var id = childItem[Constants.Id];

            if (Utility._IsNullOrUndefined(id))
            {
                id = childItem[Constants.IdPrivate];
            }

            ObjectPathInfo objectPathInfo = new ObjectPathInfo()
            {
                Id                 = context._NextId(),
                ObjectPathType     = ObjectPathType.Indexer,
                Name               = "",
                ParentObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
                ArgumentInfo       = new ArgumentInfo()
            };

            objectPathInfo.ArgumentInfo.Arguments = new object[] { id };
            return(new ObjectPath(objectPathInfo, parent._ObjectPath, false /*isCollection*/, false /*isInvalidAfterRequest*/));
        }
Esempio n. 11
0
        public static Action _CreateMethodAction(ClientRequestContext context, ClientObject parent, string methodName, OperationType operationType, object[] args)
        {
            Utility.ValidateObjectPath(parent);
            ActionInfo actionInfo = new ActionInfo()
            {
                Id           = context._NextId(),
                ActionType   = ActionType.Method,
                Name         = methodName,
                ObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
                ArgumentInfo = new ArgumentInfo()
            };
            var referencedArgumentObjectPaths = Utility.SetMethodArguments(context, actionInfo.ArgumentInfo, args);

            Utility.ValidateReferencedObjectPaths(referencedArgumentObjectPaths);
            bool isWriteOperation = operationType != OperationType.Read;
            var  ret = new Action(actionInfo, isWriteOperation);

            context._PendingRequest.AddAction(ret);
            context._PendingRequest.AddReferencedObjectPath(parent._ObjectPath);
            context._PendingRequest.AddReferencedObjectPaths(referencedArgumentObjectPaths);
            return(ret);
        }
Esempio n. 12
0
        public static Action _CreateSetPropertyAction(ClientRequestContext context, ClientObject parent, string propertyName, object value)
        {
            Utility.ValidateObjectPath(parent);
            ActionInfo actionInfo = new ActionInfo()
            {
                Id           = context._NextId(),
                ActionType   = ActionType.SetProperty,
                Name         = propertyName,
                ObjectPathId = parent._ObjectPath.ObjectPathInfo.Id,
                ArgumentInfo = new ArgumentInfo()
            };

            object[] args = new object[] { value };
            var      referencedArgumentObjectPaths = Utility.SetMethodArguments(context, actionInfo.ArgumentInfo, args);

            Utility.ValidateReferencedObjectPaths(referencedArgumentObjectPaths);
            var ret = new Action(actionInfo, true);

            context._PendingRequest.AddAction(ret);
            context._PendingRequest.AddReferencedObjectPath(parent._ObjectPath);
            context._PendingRequest.AddReferencedObjectPaths(referencedArgumentObjectPaths);

            return(ret);
        }