예제 #1
0
        public static void HandleListRequest(System.IO.TextWriter stream, HttpListenerRequest request)
        {
                        #if DEBUG
            Debug.Log("Processing list request");
                        #endif

            PerLogicalIdParams param = null;
            try
            {
                param = new PerLogicalIdParams(request);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                throw new HttpServer.HttpException(400);
            }

            var objects = new Dictionary <string, Json.Node>();
            RemotableContainer.Instance.Walk(
                (obj, logicalId) => GetOrCreate(objects, logicalId).Add(obj.GetType().FullName, BuildObjectDescription(obj, param.TryGet(logicalId))));
            var result = new Json.Object();
            result.Add("objects", new Json.Object(objects));

            var idMapping = new Dictionary <string, Json.Node>();
            foreach (var kv in RemotableContainer.Instance.logicalIdNames)
            {
                idMapping.Add(kv.Key, new Json.String(kv.Value));
            }
            result.Add("objectNames", new Json.Object(idMapping));

            result.Write(stream);
        }
예제 #2
0
        public static void HandleListRequest(System.IO.TextWriter stream, HttpListenerRequest request)
        {
            #if DEBUG
            Debug.Log("Processing list request");
            #endif

            PerLogicalIdParams param = null;
            try
            {
                param = new PerLogicalIdParams(request);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                throw new HttpServer.HttpException(400);
            }

            var objects = new Dictionary<string, Json.Node>();
            RemotableContainer.Instance.Walk(
                (obj, logicalId) =>	GetOrCreate(objects, logicalId).Add(obj.GetType().FullName, BuildObjectDescription(obj, param.TryGet(logicalId))));
            var result = new Json.Object();
            result.Add("objects", new Json.Object(objects));

            var idMapping = new Dictionary<string, Json.Node>();
            foreach (var kv in RemotableContainer.Instance.logicalIdNames)
            {
                idMapping.Add(kv.Key, new Json.String(kv.Value));
            }
            result.Add("objectNames", new Json.Object(idMapping));

            result.Write(stream);
        }