Exemple #1
0
        public RemoteLocation(string name, string className, string path, ulong internalId, ulong parentInternalId, JsonValue data) :
            base(name, className, path, internalId, parentInternalId)
        {
            mBeginAddress = data["begin"];
            mEndAddress   = data["end"];

            if (!data.ContainsKey("decoders"))
            {
                return;
            }

            var decoders = data["decoders"];
            var count    = decoders.Count;

            mRemoteDecoders = new RemoteDecoder[count];

            for (int i = 0; i < count; ++i)
            {
                var decInfo = decoders[i];
                if (decInfo == null)
                {
                    continue;
                }

                var remoteObject = RemoteObjectManager.LoadObject(decInfo);

                mRemoteDecoders[i] = remoteObject as RemoteDecoder;
            }
        }
Exemple #2
0
        public RemoteLocationManager(string name, string className, string path, ulong internalId, ulong parentInternalId, JsonValue objectDef) :
            base(name, className, path, internalId, parentInternalId)
        {
            if (!objectDef.ContainsKey("mismatches"))
            {
                return;
            }

            var mismatches = objectDef["mismatches"];

            mMismatches = new LocationMismatch[mismatches.Count];

            int index = 0;

            foreach (JsonValue item in mismatches)
            {
                var remoteDecoder = (RemoteDecoder)RemoteObjectManager.LoadObject(item["decoder"]);
                var reason        = item["reason"];

                String mappedLocation = item.ContainsKey("location") ? item["location"] : null;

                var mismatch = new LocationMismatch(remoteDecoder, reason, mappedLocation);
                mMismatches[index++] = mismatch;
            }
        }
Exemple #3
0
        public Console()
        {
            InitializeComponent();

            mConsole = ucConsole;
            ucConsole.RequestManager  = mRequestManager;
            ucTreeView.RequestManager = mRequestManager;
            RemoteObjectManager.SetRequestManager(mRequestManager);
        }
Exemple #4
0
        private async void mRequestManager_ConnectionStateChanged(RequestManager sender, ConnectionStateEventArgs args)
        {
            if (mTreeView.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(delegate { this.mRequestManager_ConnectionStateChanged(sender, args); }));
            }
            else
            {
                if (args.State == ConnectionState.OK)
                {
                    mTreeView.Nodes.Clear();

                    var rootFolder = (RemoteFolder)await RemoteObjectManager.GetRemoteObjectAsync("/");

                    var brokerNode = mTreeView.Nodes.Add("Broker");
                    brokerNode.Name = "Broker";
                    brokerNode.Tag  = rootFolder;

                    var children = await rootFolder.LoadChildrenAsync(mRequestManager);

                    if (children != null)
                    {
                        FillTree(brokerNode, children);
                    }

                    var servicesFolder = (RemoteFolder)await RemoteObjectManager.GetRemoteObjectAsync("/services");

                    var services = await servicesFolder.LoadChildrenAsync(mRequestManager);

                    var locationService = services.Where(x => x.Name == "locationManager").FirstOrDefault();
                    if (locationService != null)
                    {
                        var locationNode = mTreeView.Nodes.Add("locations");
                        locationNode.Tag = locationService;

                        RegisterNode(locationService, locationNode);
                    }
                }
                else if (args.State == ConnectionState.DISCONNECTED)
                {
                }
            }
        }
Exemple #5
0
        internal void OnChildCreated(JsonValue data)
        {
            //Are we tracking children?
            if (mChildren == null)
            {
                //No, so just ignore
                return;
            }

            var obj = RemoteObjectManager.LoadObject(data);

            mChildren.Add(obj.Name, obj);

            if (ChildAdded != null)
            {
                var args = new RemoteFolderChildEventArgs(obj);
                ChildAdded(this, args);
            }
        }
Exemple #6
0
 private void FillServices(JsonArray objects)
 {
     if (mTreeView.InvokeRequired)
     {
         this.Invoke(new MethodInvoker(delegate { this.FillServices(objects); }));
     }
     else
     {
         mTreeView.SuspendLayout();
         try
         {
             foreach (var item in objects)
             {
                 var remoteObject = RemoteObjectManager.LoadObject(item);
             }
         }
         finally
         {
             mTreeView.ResumeLayout();
         }
     }
 }
Exemple #7
0
        public async Task <IEnumerable <RemoteObject> > LoadChildrenAsync(RequestManager requestManager)
        {
            if (mChildren == null)
            {
                var response = await requestManager.RequestAsync(new string[] { "Get-ChildItem", this.Path });

                var children = (JsonArray)response["children"];

                if (children.Count == 0)
                {
                    return(null);
                }

                mChildren = new Dictionary <string, RemoteObject>();

                foreach (var item in children)
                {
                    var obj = RemoteObjectManager.LoadObject(item);
                    mChildren.Add(obj.Name, obj);
                }
            }

            return(mChildren.Select(x => x.Value));
        }