示例#1
0
        public override void SetResourceName(DeviceResource resource, string name)
        {
            switch (resource)
            {
            case OpenGLBuffer buffer:
                buffer.Name = name;
                break;

            case OpenGLFramebuffer framebuffer:
                framebuffer.Name = name;
                break;

            case OpenGLSampler sampler:
                sampler.Name = name;
                break;

            case OpenGLShader shader:
                shader.Name = name;
                break;

            case OpenGLTexture tex:
                tex.Name = name;
                break;
            }
        }
        private IEnumerable <DeviceResource> GetResources(Device device, string payload)
        {
            var coreResources = CoreLinkFormat.Parse(payload);

            foreach (var coreResource in coreResources)
            {
                var resource = new DeviceResource
                {
                    Device = device,
                    Url    = coreResource.UriReference,
                };

                if (!string.IsNullOrEmpty(coreResource.Title))
                {
                    resource.Name = coreResource.Title;
                }

                if (coreResource.SuggestedContentTypes.Count > 0)
                {
                    resource.ContentFormat = coreResource.SuggestedContentTypes[0];
                }

                yield return(resource);
            }
        }
        /// <inheritdoc />
        /// <summary>
        /// Create a device &lt;b&gt;Permissions Needed:&lt;/b&gt; ANY
        /// </summary>
        /// <param name="device">device</param>
        public void CreateDevice(DeviceResource device)
        {
            // verify the required parameter 'device' is set
            if (device == null)
            {
                throw new KnetikException(400, "Missing required parameter 'device' when calling CreateDevice");
            }

            mWebCallEvent.WebPath = "/devices";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(device); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mCreateDeviceStartTime    = DateTime.Now;
            mWebCallEvent.Context     = mCreateDeviceResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateDeviceStartTime, "CreateDevice", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
示例#4
0
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Fetch("524116518656369");

        Console.WriteLine(device.FriendlyName);
    }
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        const string fleetSid = "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string deviceSid = "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const DeviceResource device = DeviceResource.Fetch(fleetSid, deviceSid);

        Console.WriteLine(device.Sid);
    }
示例#6
0
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";
        const string deviceSid  = "DEb8eff34b248d066a31c4a953134e183e";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Fetch(deviceSid);

        Console.WriteLine(device.FriendlyName);
    }
示例#7
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        DeviceResource.Delete(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );
    }
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        TwilioClient.Init(accountSid, authToken);

        const string fleetSid = "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string deviceSid = "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const bool wasDeleted = DeviceResource.Delete(fleetSid, deviceSid);

        Console.WriteLine(wasDeleted);
    }
示例#9
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Create(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(device.Sid);
    }
示例#10
0
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Create(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            friendlyName: "My Device #1"
        );

        Console.WriteLine(device.Sid);
    }
示例#11
0
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Create("{{ rate_plan_sid }}",
                                           alias: "996224413905003",
                                           friendlyName: "Charlie's SmartMeter");

        Console.WriteLine(device.FriendlyName);
    }
示例#12
0
        public void Initialize()
        {
            DeviceResource = Device.Logical.CreateBuffer(new BufferCreateInfo(
                                                             DeviceSize,
                                                             BufferUsages.StorageBuffer,
                                                             queueFamilyIndices: new[] { Device.QueueFamilyIndex }));

            MemoryRequirements memReq = DeviceResource.GetMemoryRequirements();

            DeviceAlignedSize = DeviceSize.Align(memReq.Alignment);

            MemoryType[] memoryTypes = Device.PhysicalMemoryProperties.MemoryTypes;
            int          memoryTypeIndex;

            if (Direction == ResourceDirection.CpuToGpu)
            {
                memoryTypeIndex = memoryTypes.IndexOf(memReq.MemoryTypeBits, MemoryProperties.DeviceLocal | MemoryProperties.HostVisible);
                if (memoryTypeIndex == -1)
                {
                    memoryTypeIndex = memoryTypes.IndexOf(memReq.MemoryTypeBits, MemoryProperties.HostVisible);
                }
            }
            else
            {
                memoryTypeIndex = memoryTypes.IndexOf(memReq.MemoryTypeBits,
                                                      MemoryProperties.HostVisible | MemoryProperties.HostCoherent | MemoryProperties.HostCached);
            }

            if (memoryTypeIndex == -1)
            {
                throw new ApplicationException("No suitable memory type found for storage buffer");
            }

            // Some platforms may have a limit on the maximum size of a single allocation.
            // For example, certain systems may fail to create allocations with a size greater than or equal to 4GB.
            // Such a limit is implementation-dependent, and if such a failure occurs then the error
            // VK_ERROR_OUT_OF_DEVICE_MEMORY should be returned.
            try
            {
                DeviceMemory = Device.Logical.AllocateMemory(new MemoryAllocateInfo(memReq.Size, memoryTypeIndex));
            }
            catch (VulkanException ex) when(ex.Result == Result.ErrorOutOfDeviceMemory)
            {
                // TODO: Allocate in chunks instead?
                throw;
            }

            DeviceResource.BindMemory(DeviceMemory);
        }
示例#13
0
    public static void Main(string[] args)
    {
        // Find your Account SID and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var devices = DeviceResource.Read();

        foreach (var device in devices)
        {
            Console.WriteLine(device.FriendlyName);
        }
    }
示例#14
0
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Create(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            friendlyName: "My Device #1"
        );

        Console.WriteLine(device.Sid);
    }
示例#15
0
        public void TestCreateResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.Created,
                         "{\"binding_sid\": \"BSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"phone_number\": \"+573000000000\",\"sid\": \"DDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"url\": \"https://preview.twilio.com/TrustedComms/Devices\"}"
                         ));

            var response = DeviceResource.Create("phone_number", "push_token", client: twilioRestClient);

            Assert.NotNull(response);
        }
示例#16
0
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"devices\": [],\"meta\": {\"first_page_url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0\",\"key\": \"devices\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0\"}}"
                         ));

            var response = DeviceResource.Read("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
示例#17
0
        public void TestDeleteResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.NoContent,
                         "null"
                         ));

            var response = DeviceResource.Delete("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
示例#18
0
        public void TestFetchResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"sid\": \"THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"unique_name\": \"unique_name\",\"friendly_name\": \"friendly_name\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"fleet_sid\": \"FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"enabled\": true,\"deployment_sid\": \"DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"[email protected]\",\"date_created\": \"2016-07-30T20:00:00Z\",\"date_updated\": \"2016-07-30T20:00:00Z\",\"date_authenticated\": null,\"url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}"
                         ));

            var response = DeviceResource.Fetch("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
示例#19
0
        public void TestReadFullResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"devices\": [{\"sid\": \"THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"unique_name\": \"unique_name\",\"friendly_name\": \"friendly_name\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"enabled\": true,\"fleet_sid\": \"FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"deployment_sid\": \"DLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"identity\": \"[email protected]\",\"date_created\": \"2016-07-30T20:00:00Z\",\"date_updated\": \"2016-07-30T20:00:00Z\",\"date_authenticated\": null,\"url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices/THaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}],\"meta\": {\"first_page_url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0\",\"key\": \"devices\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://preview.twilio.com/DeployedDevices/Fleets/FLaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Devices?PageSize=50&Page=0\"}}"
                         ));

            var response = DeviceResource.Read("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);

            Assert.NotNull(response);
        }
示例#20
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Fetch(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(device.UniqueName);
    }
示例#21
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var device = DeviceResource.Update(
            friendlyName: "FriendlyName",
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(device.UniqueName);
    }
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        const string fleetSid = "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string deviceSid = "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        DeviceResource device = DeviceResource
            .Fetch(fleetSid, deviceSid)
            .Update(friendlyName: "My New Device", identity: "*****@*****.**");

        Console.WriteLine(device.FriendlyName);
    }
示例#23
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var devices = DeviceResource.Read(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        foreach (var record in devices)
        {
            Console.WriteLine(record.Sid);
        }
    }
示例#24
0
    public static void Main(string[] args)
    {
        // Get your Account SID and Auth Token from https://twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
        TwilioClient.Init(accountSid, authToken);

        const string fleetSid = "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string deviceSid = "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

        DeviceResource device = DeviceResource
            .Fetch(fleetSid, deviceSid)
            .Update(friendlyName: "My New Device", identity: "*****@*****.**");

        Console.WriteLine(device.FriendlyName);
    }
示例#25
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var devices = DeviceResource.Read(
            pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            limit: 20
            );

        foreach (var record in devices)
        {
            Console.WriteLine(record.Sid);
        }
    }
示例#26
0
        public void TestDeleteRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Delete,
                Twilio.Rest.Domain.Preview,
                "/DeployedDevices/Fleets/FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Devices/THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                DeviceResource.Delete("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "THXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
示例#27
0
        public override void SetResourceName(DeviceResource resource, string name)
        {
            switch (resource)
            {
            case D3D11Buffer buffer:
                buffer.Buffer.DebugName = name;
                break;

            case D3D11CommandList commandList:
                commandList.DeviceContext.DebugName = name;
                break;

            case D3D11Framebuffer framebuffer:
                for (int i = 0; i < framebuffer.RenderTargetViews.Length; i++)
                {
                    framebuffer.RenderTargetViews[i].DebugName = string.Format("{0}_RTV{1}", name, i);
                }
                if (framebuffer.DepthStencilView != null)
                {
                    framebuffer.DepthStencilView.DebugName = string.Format("{0}_DSV", name);
                }
                break;

            case D3D11Sampler sampler:
                sampler.DeviceSampler.DebugName = name;
                break;

            case D3D11Shader shader:
                shader.DeviceShader.DebugName = name;
                break;

            case D3D11Texture tex:
                tex.DeviceTexture.DebugName = name;
                break;

            case D3D11TextureView texView:
                texView.ShaderResourceView.DebugName = name;
                break;
            }
        }
示例#28
0
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Preview,
                "/TrustedComms/Devices",
                ""
                );

            request.AddPostParam("PhoneNumber", Serialize("phone_number"));
            request.AddPostParam("PushToken", Serialize("push_token"));
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                DeviceResource.Create("phone_number", "push_token", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
示例#29
0
 public abstract void SetResourceName(DeviceResource resource, string name);
示例#30
0
        public void LoadResources()
        {
            if (Directory.Exists(RESOURCES_CACHE))
            {
                foreach (string directory in Directory.GetDirectories(RESOURCES_CACHE))
                {
                    string id = Path.GetFileName(directory);
                    int    objectID;
                    if (int.TryParse(id, out objectID))
                    {
                        LWM2MResources resources = null;
                        switch (objectID)
                        {
                        case 0:
                            resources = _SecurityResources;
                            break;

                        case 1:
                            resources = _ServerResources;
                            break;

                        case 3:
                            resources = new DeviceResources();
                            break;

                        case 4:
                            resources = new ConnectivityMonitoringResources();
                            break;

                        case 5:
                            resources = new FirmwareUpdateResources();
                            break;

                        case 6:
                            resources = new LocationResources();
                            break;

                        case 7:
                            resources = new ConnectivityStatisticsResources();
                            break;

                        case 15:
                            resources = new DeviceCapabilityResources();
                            break;

                        case 20000:
                            resources = new FlowObjectResources();
                            break;

                        case 20001:
                            resources = new FlowAccessResources();
                            break;

                        case 20005:
                            resources = new FlowCommandResources();
                            EventHandler <ChildCreatedEventArgs> handler = (s, e) =>
                            {
                                FlowCommandResource flowCommandResource = e.Resource as FlowCommandResource;
                                if (flowCommandResource != null)
                                {
                                    flowCommandResource.Updated += new EventHandler(FlowCommand_Updated);
                                    FlowCommand_Updated(flowCommandResource, null);
                                }
                            };
                            resources.ChildCreated += handler;
                            break;

                        default:
                            break;
                        }
                        if (resources != null)
                        {
                            foreach (string fileName in Directory.GetFiles(directory, "*.tlv"))
                            {
                                LWM2MResource resource = null;
                                switch (objectID)
                                {
                                case 0:
                                    resource = new SecurityResource(Path.GetFileNameWithoutExtension(fileName));
                                    break;

                                case 1:
                                    resource = new ServerResource(Path.GetFileNameWithoutExtension(fileName));
                                    break;

                                case 3:
                                    resource = new DeviceResource();
                                    break;

                                case 4:
                                    resource = new ConnectivityMonitoringResource();
                                    break;

                                case 5:
                                    resource = new FirmwareUpdateResource();
                                    break;

                                case 6:
                                    resource = new LocationResource();
                                    break;

                                case 7:
                                    resource = new ConnectivityStatisticsResource();
                                    break;

                                case 15:
                                    resource = new DeviceCapabilityResource(Path.GetFileNameWithoutExtension(fileName));
                                    break;

                                case 20000:
                                    resource          = new FlowObjectResource();
                                    resource.Updated += new EventHandler(FlowObject_Updated);
                                    break;

                                case 20001:
                                    resource = new FlowAccessResource();
                                    break;

                                case 20005:
                                    resource          = new FlowCommandResource(Path.GetFileNameWithoutExtension(fileName));
                                    resource.Updated += new EventHandler(FlowCommand_Updated);
                                    break;

                                default:
                                    break;
                                }
                                if (resource != null)
                                {
                                    using (Stream stream = File.OpenRead(fileName))
                                    {
                                        TlvReader reader = new TlvReader(stream);
                                        if (resource.Deserialise(reader))
                                        {
                                            resources.Add(resource);
                                        }
                                    }

                                    if (objectID == 0)
                                    {
                                        SecurityResource securityResource = resource as SecurityResource;
                                        if (securityResource.SecurityMode == TSecurityMode.PreSharedKey)
                                        {
                                            UsePSK(System.Text.Encoding.UTF8.GetString(securityResource.ClientPublicKey), StringUtils.HexString(securityResource.SecretKey));
                                        }
                                    }
                                    else if (objectID == 20000)
                                    {
                                        FlowObjectResource flowObjectResource = resource as FlowObjectResource;
                                        if (flowObjectResource != null)
                                        {
                                            flowObjectResource.TenantHash = null;
                                        }
                                    }
                                }
                            }
                            this.AddResources(resources);
                        }
                    }
                }
            }
            else
            {
                LoadDefaultResources();
            }
        }