Beispiel #1
0
        /// <summary>
        /// Create a new PCIDevice instance
        /// </summary>
        /// <param name="pciController">The pci controller.</param>
        /// <param name="bus">The bus.</param>
        /// <param name="slot">The slot.</param>
        /// <param name="fun">The fun.</param>
        public PCIDevice(IPCIController pciController, byte bus, byte slot, byte fun)
        {
            base.Parent = pciController as Device;
            base.Name = base.Parent.Name + "/" + bus.ToString() + "." + slot.ToString() + "." + fun.ToString();
            base.DeviceStatus = DeviceStatus.Available;

            this.pciController = pciController;
            Bus = bus;
            Slot = slot;
            Function = fun;

            ioPortRegionCount = memoryRegionCount = 0;
            BaseAddresses = new BaseAddress[8];

            for (byte i = 0; i < 6; i++)
            {
                byte barr = (byte)(PCIConfigurationHeader.BaseAddressRegisterBase + (i * 4));
                uint address = pciController.ReadConfig32(bus, slot, fun, barr);

                if (address == 0)
                    continue;

                HAL.DisableAllInterrupts();

                pciController.WriteConfig32(bus, slot, fun, barr, 0xFFFFFFFF);
                uint mask = pciController.ReadConfig32(bus, slot, fun, barr);
                pciController.WriteConfig32(bus, slot, fun, barr, address);

                HAL.EnableAllInterrupts();

                if (address % 2 == 1)
                    BaseAddresses[i] = new BaseAddress(AddressType.IO, address & 0x0000FFF8, (~(mask & 0xFFF8) + 1) & 0xFFFF, false);
                else
                    BaseAddresses[i] = new BaseAddress(AddressType.Memory, address & 0xFFFFFFF0, ~(mask & 0xFFFFFFF0) + 1, ((address & 0x08) == 1));
            }

            if ((ClassCode == 0x03) && (SubClassCode == 0x00) && (ProgIF == 0x00))
            {
                // Special case for generic VGA
                BaseAddresses[6] = new BaseAddress(AddressType.Memory, 0xA0000, 0x1FFFF, false);
                BaseAddresses[7] = new BaseAddress(AddressType.IO, 0x3B0, 0x0F, false);
            }

            foreach (var baseAddress in BaseAddresses)
            {
                if (baseAddress == null)
                    continue;

                switch (baseAddress.Region)
                {
                    case AddressType.IO: ioPortRegionCount++; break;
                    case AddressType.Memory: memoryRegionCount++; break;
                }
            }
        }
Beispiel #2
0
        private static void initialize()
        {
            OffsetXML off = OffsetXML.getLocal<OffsetXML>(Properties.Settings.Default.OffSetXML);

            Offsets.playerName = off.playerName;
            Offsets.playerRealm = off.playerRealm;
            Offsets.lfgQueueStats = off.lfgQueueStats;
            Offsets.lfgProposal = off.lfgProposal;
            Offsets.bgQueueStats = off.bgQueueStats;
            Offsets.dbc = off.dbc;
        }
Beispiel #3
0
 /// <summary>
 ///     Returns a string that represents the current object.
 /// </summary>
 public override string ToString()
 {
     return($"BaseAddress = 0x{BaseAddress.ToInt64():X} Name = {Name}");
 }
Beispiel #4
0
 /// <summary>
 ///     Serves as a hash function for a particular type.
 /// </summary>
 public override int GetHashCode()
 {
     return(BaseAddress.GetHashCode() ^ Process.GetHashCode() ^ Information.RegionSize.GetHashCode());
 }
Beispiel #5
0
        public async Task QueryEntityWithSingleAlternateKeysWorks()
        {
            // query with alternate keys
            string expect = "{" +
                            "\"@odata.context\":\"{XXXX}\",\"value\":\"special-SSN\"" +
                            "}";

            expect = expect.Replace("{XXXX}", string.Format("{0}/odata/$metadata#Edm.String", BaseAddress.ToLowerInvariant()));

            var requestUri = string.Format("{0}/odata/Customers(SSN='special-SSN')", this.BaseAddress);
            HttpResponseMessage response = await Client.GetAsync(requestUri);

            response.EnsureSuccessStatusCode();
            string responseContent = await response.Content.ReadAsStringAsync();

            Assert.Equal(expect, responseContent);
        }
Beispiel #6
0
 public override string ToString()
 {
     return(BaseAddress.ToString());
 }
Beispiel #7
0
        } // end ToColorString()

        #region IComparable<DbgModuleInfo> Members

        public int CompareTo(DbgModuleInfo other)
        {
            // TODO: Take Target into account?
            return(BaseAddress.CompareTo(other.BaseAddress));
        }
 public override string ToString() => $"Address = 0x{BaseAddress.ToInt64():X8} Name = {Name}";
        public async Task NestedDollarSelectWorksOnCurrencyTokenProperty()
        {
            string expect = "{\r\n" +
                            "  \"@odata.context\":\"{XXXX}\",\"value\":[\r\n" +
                            "    {\r\n" +
                            "      \"@odata.etag\":\"W/\\\"bnVsbA==\\\"\",\"Id\":\"1\",\"Descrizione\":\"Test1\",\"ServerAutenticazioneId\":\"1\",\"RECVER\":null,\"ServerAutenticazione\":{\r\n" +
                            "        \"@odata.etag\":\"W/\\\"bnVsbA==\\\"\",\"Id\":\"1\",\"RECVER\":null\r\n" +
                            "      }\r\n" +
                            "    },{\r\n" +
                            "      \"@odata.etag\":\"W/\\\"MTA=\\\"\",\"Id\":\"2\",\"Descrizione\":\"Test2\",\"ServerAutenticazioneId\":\"2\",\"RECVER\":10,\"ServerAutenticazione\":{\r\n" +
                            "        \"@odata.etag\":\"W/\\\"NQ==\\\"\",\"Id\":\"2\",\"RECVER\":5\r\n" +
                            "      }\r\n" +
                            "    }\r\n" +
                            "  ]\r\n" +
                            "}";

            // Remove indentation
            expect = Regex.Replace(expect, @"\r\n\s*([""{}\]])", "$1");

            expect = expect.Replace("{XXXX}", string.Format("{0}/odata/$metadata#Dominios(ServerAutenticazione(Id,RECVER))", BaseAddress.ToLowerInvariant()));

            var getUri = this.BaseAddress + "/odata/Dominios?$expand=ServerAutenticazione($select=Id,RECVER)";

            var response = await Client.GetAsync(getUri);

            response.EnsureSuccessStatusCode();

            Assert.NotNull(response.Content);

            var payload = await response.Content.ReadAsStringAsync();

            Assert.Equal(expect, payload);
        }
Beispiel #10
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 public override string ToString()
 {
     return(string.Format("BaseAddress = 0x{0:X} Size = 0x{1:X} Protection = {2}", BaseAddress.ToInt64(),
                          Information.RegionSize, Information.Protect));
 }
Beispiel #11
0
 protected virtual Uri GetUrl(string endpoint)
 {
     return(new Uri($"{BaseAddress.TrimEnd('/')}/{endpoint}"));
 }
        public async Task PageSizeWorksOnCollectionOfComplexProperty()
        {
            string resquestUri           = BaseAddress + "/odata/ComplextTypeCollectionTests_Persons(1)/PersonInfos";
            HttpResponseMessage response = await Client.GetAsync(resquestUri);

            response.EnsureSuccessStatusCode();

            string responseContent = await response.Content.ReadAsStringAsync();

            JObject result = JObject.Parse(responseContent);

            Assert.Equal("XXX/odata/$metadata#ComplextTypeCollectionTests_Persons(1)/PersonInfos".Replace("XXX", BaseAddress.ToLowerInvariant()),
                         result["@odata.context"]);

#if NETCORE
            Assert.Equal("XXX/odata/ComplextTypeCollectionTests_Persons(1)/PersonInfos?$skip=2".Replace("XXX", BaseAddress.ToLowerInvariant()),
                         result["@odata.nextLink"]);
#else
            Assert.Equal("XXX/odata/ComplextTypeCollectionTests_Persons%281%29/PersonInfos?$skip=2".Replace("XXX", BaseAddress.ToLowerInvariant()),
                         result["@odata.nextLink"]);
#endif

            JArray personInfos = result["value"] as JArray;
            Assert.NotNull(personInfos);
            IEnumerable <string> actualData = personInfos.Select(jt => jt["CompanyName"].ToString());
            Assert.Equal(new[] { "Company 1", "Company 2" }, actualData);
        }
Beispiel #13
0
        public async Task BoundAction_Works_WithPrimitive_And_CollectionOfPrimitiveParameters(string route)
        {
            // Arrange
            var requestUri = string.Format("{0}/{1}/Employees/Default.PrimitiveAction", BaseAddress, route);
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);

            string payload = @"{
                ""param"": 7,
                ""price"": 9.9,
                ""name"": ""Tony"",
                ""names"": [ ""Mike"", null, ""John""]
            }";

            request.Content = new StringContent(payload);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            // Act
            HttpResponseMessage response = await Client.SendAsync(request);

            string responseString = response.Content.ReadAsStringAsync().Result;

            // Assert
            response.EnsureSuccessStatusCode();

            Assert.Contains(String.Format("\"@odata.context\":\"{0}/{1}/$metadata#Edm.Boolean\",\"value\":true", BaseAddress.ToLower(), route),
                            responseString);
        }
Beispiel #14
0
        /// <summary>
        /// Create a new PCIDevice instance
        /// </summary>
        /// <param name="pciController">The pci controller.</param>
        /// <param name="bus">The bus.</param>
        /// <param name="slot">The slot.</param>
        /// <param name="fun">The fun.</param>
        public PCIDevice(IPCIController pciController, byte bus, byte slot, byte fun)
        {
            base.Parent       = pciController as Device;
            base.Name         = base.Parent.Name + "/" + bus.ToString() + "." + slot.ToString() + "." + fun.ToString();
            base.DeviceStatus = DeviceStatus.Available;

            this.pciController = pciController;
            Bus      = bus;
            Slot     = slot;
            Function = fun;

            ioPortRegionCount = memoryRegionCount = 0;
            BaseAddresses     = new BaseAddress[8];

            for (byte i = 0; i < 6; i++)
            {
                byte barr    = (byte)(PCIConfigurationHeader.BaseAddressRegisterBase + (i * 4));
                uint address = pciController.ReadConfig32(bus, slot, fun, barr);

                if (address == 0)
                {
                    continue;
                }

                HAL.DisableAllInterrupts();

                pciController.WriteConfig32(bus, slot, fun, barr, 0xFFFFFFFF);
                uint mask = pciController.ReadConfig32(bus, slot, fun, barr);
                pciController.WriteConfig32(bus, slot, fun, barr, address);

                HAL.EnableAllInterrupts();

                if (address % 2 == 1)
                {
                    BaseAddresses[i] = new BaseAddress(AddressType.IO, address & 0x0000FFF8, (~(mask & 0xFFF8) + 1) & 0xFFFF, false);
                }
                else
                {
                    BaseAddresses[i] = new BaseAddress(AddressType.Memory, address & 0xFFFFFFF0, ~(mask & 0xFFFFFFF0) + 1, ((address & 0x08) == 1));
                }
            }

            if ((ClassCode == 0x03) && (SubClassCode == 0x00) && (ProgIF == 0x00))
            {
                // Special case for generic VGA
                BaseAddresses[6] = new BaseAddress(AddressType.Memory, 0xA0000, 0x1FFFF, false);
                BaseAddresses[7] = new BaseAddress(AddressType.IO, 0x3B0, 0x0F, false);
            }

            foreach (var baseAddress in BaseAddresses)
            {
                if (baseAddress == null)
                {
                    continue;
                }

                switch (baseAddress.Region)
                {
                case AddressType.IO: ioPortRegionCount++; break;

                case AddressType.Memory: memoryRegionCount++; break;
                }
            }
        }
 internal Uri GetUrl(string endpoint, string version)
 {
     return(new Uri(BaseAddress.AppendPath($"v{version}", endpoint)));
 }
Beispiel #16
0
        /// <summary>
        /// Initializes the list of base addresses.
        /// </summary>
        private void InitializeBaseAddresses(ApplicationConfiguration configuration)
        {
            BaseAddresses = new List <BaseAddress>();

            StringCollection sourceBaseAddresses      = null;
            StringCollection sourceAlternateAddresses = null;

            if (configuration.ServerConfiguration != null)
            {
                sourceBaseAddresses      = configuration.ServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.ServerConfiguration.AlternateBaseAddresses;
            }

            if (configuration.DiscoveryServerConfiguration != null)
            {
                sourceBaseAddresses      = configuration.DiscoveryServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.DiscoveryServerConfiguration.AlternateBaseAddresses;
            }

            if (sourceBaseAddresses == null)
            {
                return;
            }

            foreach (string baseAddress in sourceBaseAddresses)
            {
                BaseAddress address = new BaseAddress()
                {
                    Url = new Uri(baseAddress)
                };

                if (sourceAlternateAddresses != null)
                {
                    foreach (string alternateAddress in sourceAlternateAddresses)
                    {
                        Uri alternateUrl = new Uri(alternateAddress);

                        if (alternateUrl.Scheme == address.Url.Scheme)
                        {
                            if (address.AlternateUrls == null)
                            {
                                address.AlternateUrls = new List <Uri>();
                            }

                            address.AlternateUrls.Add(alternateUrl);
                        }
                    }
                }

                switch (address.Url.Scheme)
                {
                case Utils.UriSchemeHttps:
                {
                    address.ProfileUri   = Profiles.HttpsBinaryTransport;
                    address.DiscoveryUrl = address.Url;
                    break;
                }

                case Utils.UriSchemeOpcTcp:
                {
                    address.ProfileUri   = Profiles.UaTcpTransport;
                    address.DiscoveryUrl = address.Url;
                    break;
                }
                }

                BaseAddresses.Add(address);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Returns the best discovery URL for the base address based on the URL used by the client.
        /// </summary>
        private string GetBestDiscoveryUrl(Uri clientUrl, BaseAddress baseAddress)
        {
            string url = baseAddress.Url.ToString();

            if (baseAddress.ProfileUri == Profiles.WsHttpXmlOrBinaryTransport || baseAddress.ProfileUri == Profiles.WsHttpXmlTransport)
            {
                url += "/discovery";
            }

            return url;
        }
Beispiel #18
0
        public async Task BoundFunction_Works_WithComplex_And_CollectionOfComplexParameters(string route, string parameter, string expect)
        {
            // Arrange
            var requestUri = string.Format("{0}/{1}/Employees/Default.ComplexFunction{2}", BaseAddress, route, parameter);

            // Act
            HttpResponseMessage response = await Client.GetAsync(requestUri);

            string responseString = await response.Content.ReadAsStringAsync();

            // Assert
            response.EnsureSuccessStatusCode();

            expect = expect.Replace("CONTEXT", String.Format("\"{0}/{1}/$metadata#Collection(NS.Address)\"", BaseAddress.ToLower(), route));

            Assert.Equal(JObject.Parse(expect), JObject.Parse(responseString));
        }
Beispiel #19
0
 protected virtual Uri GetUrl(string endpoint, string version = null)
 {
     return(string.IsNullOrEmpty(version) ? new Uri($"{BaseAddress.TrimEnd('/')}/{endpoint}") : new Uri($"{BaseAddress.TrimEnd('/')}/v{version}/{endpoint}"));
 }
Beispiel #20
0
        public async Task BoundAction_Works_WithEnum_And_CollectionOfEnumParameters(string route)
        {
            // Arrange
            var requestUri = string.Format("{0}/{1}/Employees/Default.EnumAction", BaseAddress, route);
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);

            string payload = @"{
                ""bkColor"": ""Red"",
                ""frColor"": ""Green"",
                ""colors"": [""Red"", ""Blue""]
            }";

            request.Content = new StringContent(payload);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            // Act
            HttpResponseMessage response = await Client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            // Assert
            response.EnsureSuccessStatusCode();

            Assert.Contains(String.Format("\"@odata.context\":\"{0}/{1}/$metadata#Edm.Boolean\",\"value\":true", BaseAddress.ToLower(), route),
                            responseString);
        }
Beispiel #21
0
 public override int GetHashCode()
 {
     return(BaseAddress.GetHashCode() + Name.GetHashCode());
 }
Beispiel #22
0
        public async Task BoundAction_Works_WithComplex_And_CollectionOfComplexParameters(string route)
        {
            // Arrange
            var requestUri = string.Format("{0}/{1}/Employees/Default.ComplexAction", BaseAddress, route);
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);

            string payload = @"{
                ""address"": {""Street"":""NE 24th St."",""City"":""Redmond""},
                ""location"": {""@odata.type"":""#NS.SubAddress"",""Street"":""LianHua Rd."",""City"":""Shanghai"", ""Code"":9.9},
                ""addresses"": [{""Street"":""NE 24th St."",""City"":""Redmond""}, {""@odata.type"":""#NS.SubAddress"",""Street"":""LianHua Rd."",""City"":""Shanghai"", ""Code"":9.9}]
            }";

            request.Content = new StringContent(payload);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            // Act
            HttpResponseMessage response = await Client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            // Assert
            response.EnsureSuccessStatusCode();

            Assert.Contains(String.Format("\"@odata.context\":\"{0}/{1}/$metadata#Edm.Boolean\",\"value\":true", BaseAddress.ToLower(), route),
                            responseString);
        }
Beispiel #23
0
        public override void Initialize()
        {
            pciController = Device.Parent.DeviceDriver as IPCIController;

            var configuration = Device.Configuration as PCIDeviceConfiguration;

            Bus      = configuration.Bus;
            Slot     = configuration.Slot;
            Function = configuration.Function;

            Device.Name = Device.Parent.Name + '/' + Bus.ToString() + '.' + Slot.ToString() + '.' + Function.ToString();

            ioPortRegionCount = memoryRegionCount = 0;
            BaseAddresses     = new BaseAddress[8];

            for (byte i = 0; i < 6; i++)
            {
                byte barr = (byte)(PCIConfigurationHeader.BaseAddressRegisterBase + (i * 4));

                uint address = pciController.ReadConfig32(Bus, Slot, Function, barr);

                if (address == 0)
                {
                    continue;
                }

                HAL.DisableAllInterrupts();

                pciController.WriteConfig32(Bus, Slot, Function, barr, 0xFFFFFFFF);
                uint mask = pciController.ReadConfig32(Bus, Slot, Function, barr);
                pciController.WriteConfig32(Bus, Slot, Function, barr, address);

                HAL.EnableAllInterrupts();

                if (address % 2 == 1)
                {
                    BaseAddresses[i] = new BaseAddress(AddressType.IO, address & 0x0000FFF8, (~(mask & 0xFFF8) + 1) & 0xFFFF, false);
                }
                else
                {
                    BaseAddresses[i] = new BaseAddress(AddressType.Memory, address & 0xFFFFFFF0, ~(mask & 0xFFFFFFF0) + 1, ((address & 0x08) == 1));
                }
            }

            // Special case for generic VGA
            if (ClassCode == 0x03 && SubClassCode == 0x00 && ProgIF == 0x00)
            {
                BaseAddresses[6] = new BaseAddress(AddressType.Memory, 0xA0000, 0x1FFFF, false);
                BaseAddresses[7] = new BaseAddress(AddressType.IO, 0x3B0, 0x0F, false);
            }

            foreach (var baseAddress in BaseAddresses)
            {
                if (baseAddress == null)
                {
                    continue;
                }

                if (baseAddress.Region == AddressType.Undefined)
                {
                    continue;
                }

                switch (baseAddress.Region)
                {
                case AddressType.IO: ioPortRegionCount++; break;

                case AddressType.Memory: memoryRegionCount++; break;
                }
            }
        }
Beispiel #24
0
        public async Task BoundAction_Works_WithEntity_And_CollectionOfEntityParameters(string route)
        {
            // Arrange
            var requestUri = string.Format("{0}/{1}/Employees/Default.EntityAction", BaseAddress, route);
            var request    = new HttpRequestMessage(HttpMethod.Post, requestUri);

            string payload = @"{
                ""person"": {""@odata.type"":""#NS.Employee"",""ID"":801,""Name"":""Mike""},
                ""guard"": {""@odata.type"":""#NS.Manager"",""ID"":901,""Name"":""John"", ""Heads"":9},
                ""staff"": [{""@odata.type"":""#NS.Employee"",""ID"":801,""Name"":""Mike""}, {""@odata.type"":""#NS.Manager"",""ID"":901,""Name"":""John"", ""Heads"":9}]
            }";

            request.Content = new StringContent(payload);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            // Act
            HttpResponseMessage response = await Client.SendAsync(request);

            string responseString = await response.Content.ReadAsStringAsync();

            // Assert
            response.EnsureSuccessStatusCode();

            Assert.Contains(String.Format("\"@odata.context\":\"{0}/{1}/$metadata#Edm.Boolean\",\"value\":true", BaseAddress.ToLower(), route),
                            responseString);
        }
Beispiel #25
0
        public void CreateRefundAPaymentTest()
        {
            string paymentId = "40006143732";
            //Amount Details
            AmountDetail amountDetail = new AmountDetail("100.00", "USD");

            // Solution Details
            Solution solution = new Solution
            {
                Name       = "SolDemo",
                VendorName = "VenodeName"
            };

            // Credit Card
            CreditCard creditCard = new CreditCard("1111", "XXXX", "VISA", "123");

            // Bank Account
            BankAccount bankAccount = new BankAccount(null, "325070760", "4111111", "demo acount", null, "bank anme",
                                                      null);
            //Base AddressBillTo
            BaseAddress baseAdressBillTo = new BaseAddress
            {
                Address1    = " Demo Adress",
                Company     = "XXXXCOMAPNAY",
                Country     = "India",
                FirstName   = "Demo first",
                LastName    = "Demo Second",
                PhoneNumber = "1123456987",
                PostalCode  = "192123"
            };

            //Base AddressShipTo
            BaseAddress baseAdressShipTo = new BaseAddress
            {
                Address1    = " Demo Adress",
                Company     = "XXXXCOMAPNAY",
                Country     = "India",
                FirstName   = "Demo first",
                LastName    = "Demo Second",
                PhoneNumber = "1123456987",
                PostalCode  = "192123"
            };

            // Ip Address
            String Ip = null;

            // Order
            Order order = new Order("12365");

            // Extended Amount Tax
            ExtendedAmount extendedAmountTax = new ExtendedAmount("100.00", "Tax", "Tax");

            // Extended Amount Duty
            ExtendedAmount extendedAmountDuty = new ExtendedAmount("100.00", "duty", "Duty");

            // Extended Amount Ship
            ExtendedAmount extendedAmountShip = new ExtendedAmount("100.00", "ship", "Ship");

            //Payment Instrunment
            //  PaymentInstrument paymentInstrument = new PaymentInstrument(null, bankAccount, null, null, true);
            PaymentInstrument paymentInstrument = new PaymentInstrument(creditCard, null, null, null, true);

            List <LineItem> lineItems = new List <LineItem>();

            lineItems.Add(new LineItem("1", "tshir", "tshir desc", 1, "100", true));

            RefundRequest body = new RefundRequest("50.00", order, lineItems, extendedAmountTax, extendedAmountShip,
                                                   extendedAmountDuty, paymentInstrument, baseAdressBillTo, baseAdressShipTo);
            string authorization = "Basic asdadsa";

            mockRestClient.Expects.One.Method(v => v.Execute(new RestRequest())).With(NMock.Is.TypeOf(typeof(RestRequest))).WillReturn(paymentResponse);
            ApiClient apiClient = new ApiClient(mockRestClient.MockObject);

            apiClient.Configuration = null;

            Configuration configuration = new Configuration
            {
                ApiClient      = apiClient,
                Username       = "******",
                Password       = "******",
                AccessToken    = null,
                ApiKey         = null,
                ApiKeyPrefix   = null,
                TempFolderPath = null,
                DateTimeFormat = null,
                Timeout        = 60000,
                UserAgent      = "asdasd"
            };

            instance = new RefundsApi(configuration);

            var response = instance.CreateRefundAPayment(paymentId, body, authorization);

            Assert.IsInstanceOf <Payment>(response, "response is Payment");
        }
Beispiel #26
0
 public string ChangePasswordLinkFormatted()
 {
     return(BaseAddress.Replace("/identity", "") + string.Format(ChangePasswordUrl, ClientId));
 }
Beispiel #27
0
        public async Task CanUpdateEntityWithSingleAlternateKeys()
        {
            string expect = "{" +
                            "\"@odata.context\":\"{XXXX}\",\"ID\":6,\"Name\":\"Updated Customer Name\",\"SSN\":\"SSN-6-T-006\"" +
                            "}";

            expect = expect.Replace("{XXXX}", string.Format("{0}/odata/$metadata#Customers/$entity", BaseAddress.ToLowerInvariant()));

            var requestUri = string.Format("{0}/odata/Customers(SSN='SSN-6-T-006')", this.BaseAddress);

            HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
            const string       content = @"{'Name':'Updated Customer Name'}";

            request.Content = new StringContent(content);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            HttpResponseMessage response = await Client.SendAsync(request);

            response.EnsureSuccessStatusCode();
            string responseContent = await response.Content.ReadAsStringAsync();

            Assert.Equal(expect, responseContent);
        }
        /// <summary>
        /// Returns the best discovery URL for the base address based on the URL used by the client.
        /// </summary>
        private string GetBestDiscoveryUrl(Uri clientUrl, BaseAddress baseAddress)
        {
            string url = baseAddress.Url.ToString();

            if ((baseAddress.ProfileUri == Profiles.HttpsBinaryTransport) && (!(url.EndsWith("discovery"))))
            {
                url += "/discovery";
            }

            return url;
        }
Beispiel #29
0
 /// <summary>
 ///     Returns a string that represents the current object.
 /// </summary>
 public override string ToString()
 {
     return
         ($"BaseAddress = 0x{BaseAddress.ToInt64():X} Size = 0x{Information.RegionSize:X} Protection = {Information.Protect}");
 }
        /// <summary>
        /// Initializes the list of base addresses.
        /// </summary>
        private void InitializeBaseAddresses(ApplicationConfiguration configuration)
        {
            BaseAddresses = new List<BaseAddress>();

            StringCollection sourceBaseAddresses = null;
            StringCollection sourceAlternateAddresses = null;

            if (configuration.ServerConfiguration != null)
            {
                sourceBaseAddresses = configuration.ServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.ServerConfiguration.AlternateBaseAddresses;
            }

            if (configuration.DiscoveryServerConfiguration != null)
            {
                sourceBaseAddresses = configuration.DiscoveryServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.DiscoveryServerConfiguration.AlternateBaseAddresses;
            }

            if (sourceBaseAddresses == null)
            {
                return;
            }

            foreach (string baseAddress in sourceBaseAddresses)
            {
                BaseAddress address = new BaseAddress() { Url = new Uri(baseAddress) };

                if (sourceAlternateAddresses != null)
                {
                    foreach (string alternateAddress in sourceAlternateAddresses)
                    {
                        Uri alternateUrl = new Uri(alternateAddress);

                        if (alternateUrl.Scheme == address.Url.Scheme)
                        {
                            if (address.AlternateUrls == null)
                            {
                                address.AlternateUrls = new List<Uri>();
                            }

                            address.AlternateUrls.Add(alternateUrl);
                        }
                    }
                }

                switch (address.Url.Scheme)
                {
                    case Utils.UriSchemeHttps:
                    {
                        address.ProfileUri = Profiles.HttpsBinaryTransport;
                        address.DiscoveryUrl = address.Url;
                        break;
                    }

                    case Utils.UriSchemeOpcTcp:
                    {
                        address.ProfileUri = Profiles.UaTcpTransport;
                        address.DiscoveryUrl = address.Url;
                        break;
                    }
                }

                BaseAddresses.Add(address);
            }
        }
Beispiel #31
0
 public Constant?ReadRelocation(long imageOffset)
 {
     return(Relocations[BaseAddress.ToLinear() + (ulong)imageOffset]);
 }
Beispiel #32
0
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 public override int GetHashCode()
 {
     return(BaseAddress.GetHashCode() ^ MemorySharp.GetHashCode());
 }
Beispiel #33
0
        public async Task CreateFileTest(string mode)
        {
            await ResetDatasource();

            string expect = "{\r\n" +
                            "  \"@odata.context\":\"{XXXX}\",\"FileId\":6,\"Name\":\"FileName\",\"CreatedDate\":\"2014-12-30T15:01:03-08:00\",\"DeleteDate\":null,\"ModifiedDates\":[\r\n" +
                            "    \"2014-12-24T01:02:03-08:00\"\r\n" +
                            "  ]\r\n" +
                            "}";

            expect = expect.Replace("{XXXX}", string.Format("{0}/{1}/$metadata#Files/$entity", BaseAddress.ToLowerInvariant(), mode));

            string requestUri = string.Format("{0}/{1}/Files", BaseAddress, mode);

            string             content = @"{'FileId':0,'Name':'FileName','CreatedDate':'2014-12-31T07:01:03+08:00','ModifiedDates':[]}";
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUri);

            request.Content = new StringContent(content);
            request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            var response = await Client.SendAsync(request);

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
            Assert.Equal(expect, response.Content.ReadAsStringAsync().Result);
        }
Beispiel #34
0
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 public override string ToString()
 {
     return(string.Format("BaseAddress = 0x{0:X} Name = {1}", BaseAddress.ToInt64(), Name));
 }
Beispiel #35
0
        /// <summary>
        /// Initializes the list of base addresses.
        /// </summary>
        private void InitializeBaseAddresses(ApplicationConfiguration configuration)
        {
            BaseAddresses = new List<BaseAddress>();

            StringCollection sourceBaseAddresses = null;
            StringCollection sourceAlternateAddresses = null;

            if (configuration.ServerConfiguration != null)
            {
                sourceBaseAddresses = configuration.ServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.ServerConfiguration.AlternateBaseAddresses;
            }

            if (configuration.DiscoveryServerConfiguration != null)
            {
                sourceBaseAddresses = configuration.DiscoveryServerConfiguration.BaseAddresses;
                sourceAlternateAddresses = configuration.DiscoveryServerConfiguration.AlternateBaseAddresses;
            }

            if (sourceBaseAddresses == null)
            {
                return;
            }

            foreach (string baseAddress in sourceBaseAddresses)
            {
                BaseAddress address = new BaseAddress() { Url = new Uri(baseAddress) };

                if (sourceAlternateAddresses != null)
                {
                    foreach (string alternateAddress in sourceAlternateAddresses)
                    {
                        Uri alternateUrl = new Uri(alternateAddress);

                        if (alternateUrl.Scheme == address.Url.Scheme)
                        {
                            if (address.AlternateUrls == null)
                            {
                                address.AlternateUrls = new List<Uri>();
                            }

                            address.AlternateUrls.Add(alternateUrl);
                        }
                    }
                }

                switch (address.Url.Scheme)
                {
                    case Utils.UriSchemeHttp:
                    case Utils.UriSchemeNetTcp:
                    case Utils.UriSchemeNetPipe:
                    {
                        address.ProfileUri = Profiles.WsHttpXmlOrBinaryTransport;
                        address.DiscoveryUrl = new Uri(address.Url.ToString() + "/discovery");
                        break;
                    }

                    case Utils.UriSchemeHttps:
                    {
                        address.ProfileUri = Profiles.HttpsXmlOrBinaryTransport;
                        address.DiscoveryUrl = address.Url;
                        break;
                    }

                    case Utils.UriSchemeNoSecurityHttp:
                    {
                        UriBuilder builder = new UriBuilder(address.Url);
                        builder.Scheme = Utils.UriSchemeHttp;
                        address.Url = builder.Uri;

                        if (address.AlternateUrls != null)
                        {
                            for (int ii = 0; ii < address.AlternateUrls.Count; ii++)
                            {
                                builder = new UriBuilder(address.AlternateUrls[ii]);
                                builder.Scheme = Utils.UriSchemeHttp;
                                address.AlternateUrls[ii] = builder.Uri;
                            }
                        }

                        address.ProfileUri = Profiles.HttpsXmlOrBinaryTransport;
                        address.DiscoveryUrl = address.Url;
                        break;
                    }

                    case Utils.UriSchemeOpcTcp:
                    {
                        address.ProfileUri = Profiles.UaTcpTransport;
                        address.DiscoveryUrl = address.Url;
                        break;
                    }
                }

                BaseAddresses.Add(address);
            }
        }
Beispiel #36
0
        public async Task <bool> SaveShippingAddressAsync(BaseAddress address)
        {
            await _dbcontext.AddAsync(address);

            return(await _dbcontext.SaveChangesAsync() > 0);
        }