public ProjectsMapper(IUserManager userManager) { Require.NotNull(userManager, nameof(userManager)); _userManager = userManager; }
protected override void CheckRequirements() { Require.ProviderIs(StorageProvider.Firebird); }
private async Task <Application> UpdateApplicationAsyncInternal(string applicationSid, string friendlyName, ApplicationOptions options) { Require.Argument("ApplicationSid", applicationSid); var request = new RestRequest(); request.Method = Method.POST; request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json"; request.AddUrlSegment("ApplicationSid", applicationSid); if (friendlyName.HasValue()) { request.AddParameter("FriendlyName", friendlyName); } if (options != null) { if (options.VoiceUrl != null) { request.AddParameter("VoiceUrl", options.VoiceUrl); } if (options.VoiceMethod.HasValue()) { request.AddParameter("VoiceMethod", options.VoiceMethod.ToString()); } if (options.VoiceFallbackUrl != null) { request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl); } if (options.VoiceFallbackMethod.HasValue()) { request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString()); } if (options.VoiceCallerIdLookup.HasValue) { request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value); } if (options.StatusCallback.HasValue()) { request.AddParameter("StatusCallback", options.StatusCallback); } if (options.StatusCallbackMethod.HasValue()) { request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString()); } if (options.SmsUrl != null) { request.AddParameter("SmsUrl", options.SmsUrl); } if (options.SmsMethod.HasValue()) { request.AddParameter("SmsMethod", options.SmsMethod.ToString()); } if (options.SmsFallbackUrl != null) { request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl); } if (options.SmsFallbackMethod.HasValue()) { request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString()); } } var result = await ExecuteAsync(request, typeof(Application)); return((Application)result); }
public dynamic DeleteDomain(int id) { Require.Argument(nameof(id), id); return(DeleteDomain(id.ToString())); }
public void All_WhenAllElementsMatchesPredicate_DoesNotThrow() { Require.All(new[] { 2, 3 }, v => v > 1, "message", "name"); }
public void All_WhenContainsElementThatDoesNotMatchPredicate_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => Require.All(new[] { 1, 5 }, v => v > 1, "message", "name")); }
public IfErrorFunctionCompiler(ExcelFunction function) : base(function) { Require.That(function).Named("function").IsNotNull(); }
//--------------------------------------------------------------------- internal void UseForCurrentEntry(LocationAndIndex entry) { Require.ArgumentNotNull(entry); currentEntry = entry; }
public Stdeva(DoubleEnumerableArgConverter argConverter) { Require.Argument(argConverter).IsNotNull("argConverter"); _argConverter = argConverter; }
protected override void CheckRequirements() { Require.ProviderIs(StorageProvider.Oracle); }
/// <summary> /// Determines if an instance of this type can be assigned to a variable of another type. /// </summary> /// <param name="type">The current type.</param> /// <param name="otherType">The type to compare with the current type.</param> /// <returns> /// True if an instance of <c>type</c> can be assigned to a variable of <c>otherType</c>; otherwise, false. /// </returns> public static bool IsA(this Type type, Type otherType) { Require.NotNull(otherType, nameof(otherType)); return(otherType.IsAssignableFrom(type)); }
public void MultidatabaseMappingResolverOnSharedSchemaTest() { Require.AllFeaturesSupported(ProviderFeatures.Multidatabase); var domainConfiguration = DomainConfigurationFactory.Create(); domainConfiguration.UpgradeMode = DomainUpgradeMode.Recreate; domainConfiguration.Types.Register(typeof(model.Part1.TestEntity1).Assembly, typeof(model.Part1.TestEntity1).Namespace); domainConfiguration.Types.Register(typeof(model.Part2.TestEntity2).Assembly, typeof(model.Part2.TestEntity2).Namespace); domainConfiguration.Types.Register(typeof(model.Part3.TestEntity3).Assembly, typeof(model.Part3.TestEntity3).Namespace); domainConfiguration.Types.Register(typeof(model.Part4.TestEntity4).Assembly, typeof(model.Part4.TestEntity4).Namespace); domainConfiguration.Databases.Add("DO-Tests-1"); domainConfiguration.Databases.Add("DO-Tests-2"); domainConfiguration.MappingRules.Map(typeof(model.Part1.TestEntity1).Assembly, typeof(model.Part1.TestEntity1).Namespace).To("DO-Tests-1", "Model1"); domainConfiguration.MappingRules.Map(typeof(model.Part2.TestEntity2).Assembly, typeof(model.Part2.TestEntity2).Namespace).To("DO-Tests-1", "Model2"); domainConfiguration.MappingRules.Map(typeof(model.Part3.TestEntity3).Assembly, typeof(model.Part3.TestEntity3).Namespace).To("DO-Tests-2", "Model1"); domainConfiguration.MappingRules.Map(typeof(model.Part4.TestEntity4).Assembly, typeof(model.Part4.TestEntity4).Namespace).To("DO-Tests-2", "Model2"); domainConfiguration.DefaultDatabase = "DO-Tests-1"; domainConfiguration.DefaultSchema = "Model1"; var nodeConfiguration = new NodeConfiguration("Additional"); nodeConfiguration.UpgradeMode = DomainUpgradeMode.Recreate; nodeConfiguration.DatabaseMapping.Add("DO-Tests-1", "DO-Tests-3"); nodeConfiguration.DatabaseMapping.Add("DO-Tests-2", "DO-Tests-4"); nodeConfiguration.SchemaMapping.Add("Model1", "Model3"); nodeConfiguration.SchemaMapping.Add("Model2", "Model4"); using (var domain = Domain.Build(domainConfiguration)) { domain.StorageNodeManager.AddNode(nodeConfiguration); var defaultNodeConfig = domain.StorageNodeManager.GetNode(WellKnown.DefaultNodeId).Configuration; var additionalNodeConfig = domain.StorageNodeManager.GetNode("Additional").Configuration; DefaultSchemaInfo defaultSchemaInfo; using (var connection = driver.CreateConnection()) { connection.Open(); defaultSchemaInfo = driver.GetDefaultSchema(connection); } var defaultMappingResolver = MappingResolver.Create(domainConfiguration, defaultNodeConfig, defaultSchemaInfo); Assert.That(defaultMappingResolver, Is.InstanceOf <MultidatabaseMappingResolver>()); var additionalMappingResolver = MappingResolver.Create(domainConfiguration, additionalNodeConfig, defaultSchemaInfo); Assert.That(additionalMappingResolver, Is.InstanceOf <MultidatabaseMappingResolver>()); SchemaExtractionResult extractionResult; using (var connection = driver.CreateConnection()) { connection.Open(); extractionResult = new SchemaExtractionResult(driver.Extract(connection, defaultMappingResolver.GetSchemaTasks())); } extractionResult.MakeShared(); var resolverPerNodeMap = new Dictionary <NodeConfiguration, MappingResolver> { { defaultNodeConfig, defaultMappingResolver }, { additionalNodeConfig, additionalMappingResolver } }; var baseDb1 = "DO-Tests-1"; var baseDb2 = "DO-Tests-2"; var baseSch1 = "Model1"; var baseSch2 = "Model2"; foreach (var pair in resolverPerNodeMap) { var nodeConfig = pair.Key; var resolver = pair.Value; var tasks = resolver.GetSchemaTasks(); Assert.That(tasks.Count(), Is.EqualTo(4)); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-1") && t.Schema == nodeConfig.SchemaMapping.Apply("Model1")), Is.True); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-1") && t.Schema == nodeConfig.SchemaMapping.Apply("Model2")), Is.True); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-2") && t.Schema == nodeConfig.SchemaMapping.Apply("Model1")), Is.True); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-2") && t.Schema == nodeConfig.SchemaMapping.Apply("Model2")), Is.True); tasks = resolver.GetMetadataTasks(); Assert.That(tasks.Count(), Is.EqualTo(2)); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-1") && t.Schema == nodeConfig.SchemaMapping.Apply("Model1")), Is.True); Assert.That(tasks.Any(t => t.Catalog == nodeConfig.DatabaseMapping.Apply("DO-Tests-2") && t.Schema == nodeConfig.SchemaMapping.Apply("Model1")), Is.True); var fullName = resolver.GetNodeName("TestDb", "TestSchema", "TestEntity1"); Assert.That(fullName, Is.EqualTo("TestDb:TestSchema:TestEntity1")); var expectedDatabase = nodeConfig.DatabaseMapping.Apply(baseDb1); var expectedSchema = nodeConfig.SchemaMapping.Apply(baseSch1); fullName = resolver.GetNodeName("DO-Tests-1", "Model1", "TestEntity1"); Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity1", expectedDatabase, expectedSchema))); var table = extractionResult .Catalogs[baseDb1] .Schemas[baseSch1] .Tables["TestEntity1"]; fullName = resolver.GetNodeName(table); expectedDatabase = baseDb1; expectedSchema = baseSch1; Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity1", expectedDatabase, expectedSchema))); table = extractionResult .Catalogs[baseDb1] .Schemas[baseSch2] .Tables["TestEntity2"]; fullName = resolver.GetNodeName(table); expectedDatabase = baseDb1; expectedSchema = baseSch2; Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity2", expectedDatabase, expectedSchema))); table = extractionResult .Catalogs[baseDb2] .Schemas[baseSch1] .Tables["TestEntity3"]; expectedDatabase = baseDb2; expectedSchema = baseSch1; fullName = resolver.GetNodeName(table); Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity3", expectedDatabase, expectedSchema))); var typeinfo = domain.Model.Types[typeof(model.Part1.TestEntity1)]; expectedDatabase = nodeConfig.DatabaseMapping.Apply(baseDb1); expectedSchema = nodeConfig.SchemaMapping.Apply(baseSch1); fullName = resolver.GetNodeName(typeinfo); Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity1", expectedDatabase, expectedSchema))); var resolveResult = resolver.Resolve(extractionResult, fullName); expectedDatabase = baseDb1; expectedSchema = baseSch1; Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(resolveResult.Schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); var schema = resolver.ResolveSchema(extractionResult, typeinfo.MappingDatabase, typeinfo.MappingSchema); Assert.That(schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); typeinfo = domain.Model.Types[typeof(model.Part2.TestEntity2)]; expectedDatabase = nodeConfig.DatabaseMapping.Apply(baseDb1); expectedSchema = nodeConfig.SchemaMapping.Apply(baseSch2); fullName = resolver.GetNodeName(typeinfo); Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity2", expectedDatabase, expectedSchema))); resolveResult = resolver.Resolve(extractionResult, fullName); expectedDatabase = baseDb1; expectedSchema = baseSch2; Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(resolveResult.Schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); schema = resolver.ResolveSchema(extractionResult, typeinfo.MappingDatabase, typeinfo.MappingSchema); Assert.That(schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); typeinfo = domain.Model.Types[typeof(model.Part3.TestEntity3)]; expectedDatabase = nodeConfig.DatabaseMapping.Apply(baseDb2); expectedSchema = nodeConfig.SchemaMapping.Apply(baseSch1); fullName = resolver.GetNodeName(typeinfo); Assert.That(fullName, Is.EqualTo(string.Format("{0}:{1}:TestEntity3", expectedDatabase, expectedSchema))); resolveResult = resolver.Resolve(extractionResult, fullName); expectedDatabase = baseDb2; expectedSchema = baseSch1; Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(resolveResult.Schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); schema = resolver.ResolveSchema(extractionResult, typeinfo.MappingDatabase, typeinfo.MappingSchema); Assert.That(schema.GetNameInternal(), Is.EqualTo(expectedSchema)); Assert.That(schema.Catalog.GetNameInternal(), Is.EqualTo(expectedDatabase)); } } }
public void MultischemaMappingResolverOnSharedSchemaTest() { Require.AllFeaturesSupported(ProviderFeatures.Multischema); var domainConfiguration = DomainConfigurationFactory.Create(); domainConfiguration.UpgradeMode = DomainUpgradeMode.Recreate; domainConfiguration.Types.Register(typeof(model.Part1.TestEntity1).Assembly, typeof(model.Part1.TestEntity1).Namespace); domainConfiguration.Types.Register(typeof(model.Part2.TestEntity2).Assembly, typeof(model.Part2.TestEntity2).Namespace); domainConfiguration.Types.Register(typeof(model.Part3.TestEntity3).Assembly, typeof(model.Part3.TestEntity3).Namespace); domainConfiguration.Types.Register(typeof(model.Part4.TestEntity4).Assembly, typeof(model.Part4.TestEntity4).Namespace); domainConfiguration.MappingRules.Map(typeof(model.Part1.TestEntity1).Assembly, typeof(model.Part1.TestEntity1).Namespace).ToSchema("Model1"); domainConfiguration.MappingRules.Map(typeof(model.Part2.TestEntity2).Assembly, typeof(model.Part2.TestEntity2).Namespace).ToSchema("Model1"); domainConfiguration.MappingRules.Map(typeof(model.Part3.TestEntity3).Assembly, typeof(model.Part3.TestEntity3).Namespace).ToSchema("Model2"); domainConfiguration.MappingRules.Map(typeof(model.Part4.TestEntity4).Assembly, typeof(model.Part4.TestEntity4).Namespace).ToSchema("Model2"); domainConfiguration.DefaultSchema = "Model1"; var nodeConfiguration = new NodeConfiguration("Additional"); nodeConfiguration.UpgradeMode = DomainUpgradeMode.Recreate; nodeConfiguration.SchemaMapping.Add("Model1", "Model3"); nodeConfiguration.SchemaMapping.Add("Model2", "Model4"); using (var domain = Domain.Build(domainConfiguration)) { domain.StorageNodeManager.AddNode(nodeConfiguration); var defaultNodeConfig = domain.StorageNodeManager.GetNode(WellKnown.DefaultNodeId).Configuration; var additionalNodeConfig = domain.StorageNodeManager.GetNode("Additional").Configuration; DefaultSchemaInfo defaultSchemaInfo; using (var connection = driver.CreateConnection()) { connection.Open(); defaultSchemaInfo = driver.GetDefaultSchema(connection); } var defaultMappingResolver = MappingResolver.Create(domainConfiguration, defaultNodeConfig, defaultSchemaInfo); Assert.That(defaultMappingResolver, Is.InstanceOf <MultischemaMappingResolver>()); var additionalMappingResolver = MappingResolver.Create(domainConfiguration, additionalNodeConfig, defaultSchemaInfo); Assert.That(additionalMappingResolver, Is.InstanceOf <MultischemaMappingResolver>()); SchemaExtractionResult extractionResult; using (var connection = driver.CreateConnection()) { connection.Open(); extractionResult = new SchemaExtractionResult(driver.Extract(connection, defaultMappingResolver.GetSchemaTasks())); } extractionResult.MakeShared(); var resolverPerNodeMap = new Dictionary <NodeConfiguration, MappingResolver> { { defaultNodeConfig, defaultMappingResolver }, { additionalNodeConfig, additionalMappingResolver } }; foreach (var pair in resolverPerNodeMap) { var nodeConfig = pair.Key; var mappingResolver = pair.Value; Assert.That(mappingResolver, Is.InstanceOf <MultischemaMappingResolver>()); var metadataExtactionTasks = mappingResolver.GetMetadataTasks(); Assert.That(metadataExtactionTasks.Count(), Is.EqualTo(1)); Assert.That(metadataExtactionTasks.First().Catalog, Is.EqualTo(defaultSchemaInfo.Database)); Assert.That(metadataExtactionTasks.First().Schema, Is.EqualTo(nodeConfig.SchemaMapping.Apply("Model1"))); var schemaExtractionTasks = mappingResolver.GetSchemaTasks(); Assert.That(schemaExtractionTasks.Count(), Is.EqualTo(2)); Assert.That(schemaExtractionTasks.Any(t => t.Catalog == defaultSchemaInfo.Database && t.Schema == nodeConfig.SchemaMapping.Apply("Model1")), Is.True); Assert.That(schemaExtractionTasks.Any(t => t.Catalog == defaultSchemaInfo.Database && t.Schema == nodeConfig.SchemaMapping.Apply("Model2")), Is.True); var fullName = mappingResolver.GetNodeName("dummy", "SchemaName", "Table1"); Assert.That(fullName, Is.EqualTo("SchemaName:Table1")); fullName = mappingResolver.GetNodeName("dummy", "Model1", "Table1"); Assert.That(fullName, Is.EqualTo(nodeConfig.SchemaMapping.Apply("Model1") + ":" + "Table1")); var table = extractionResult.Catalogs.First().Schemas["Model1"].Tables["TestEntity1"]; fullName = mappingResolver.GetNodeName(table); Assert.That(fullName, Is.EqualTo("Model1" + ":" + "TestEntity1")); table = extractionResult.Catalogs.First().Schemas["Model2"].Tables["TestEntity4"]; fullName = mappingResolver.GetNodeName(table); Assert.That(fullName, Is.EqualTo("Model2" + ":" + "TestEntity4")); var typeInfo = domain.Model.Types[typeof(model.Part1.TestEntity1)]; fullName = mappingResolver.GetNodeName(typeInfo); Assert.That(fullName, Is.EqualTo(nodeConfig.SchemaMapping.Apply("Model1") + ":" + "TestEntity1")); var resolveResult = mappingResolver.Resolve(extractionResult, fullName); Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo("Model1")); var schema = mappingResolver.ResolveSchema(extractionResult, typeInfo.MappingDatabase, typeInfo.MappingSchema); Assert.That(schema.GetNameInternal(), Is.EqualTo("Model1")); typeInfo = domain.Model.Types[typeof(model.Part4.TestEntity4)]; fullName = mappingResolver.GetNodeName(typeInfo); Assert.That(fullName, Is.EqualTo(nodeConfig.SchemaMapping.Apply("Model2") + ":" + "TestEntity4")); resolveResult = mappingResolver.Resolve(extractionResult, fullName); Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo("Model2")); schema = mappingResolver.ResolveSchema(extractionResult, typeInfo.MappingDatabase, typeInfo.MappingSchema); Assert.That(schema.GetNameInternal(), Is.EqualTo("Model2")); var sequence = typeInfo.Hierarchy.Key.Sequence; fullName = mappingResolver.GetNodeName(sequence); Assert.That(fullName, Is.EqualTo(nodeConfig.SchemaMapping.Apply("Model1") + ":" + sequence.MappingName)); resolveResult = mappingResolver.Resolve(extractionResult, fullName); Assert.That(resolveResult.Schema.GetNameInternal(), Is.EqualTo("Model1")); } } }
/// <summary> /// Visit the specified project /// </summary> /// <param name="project">Project to visit.</param> public void VisitProject(NAntProject project) { Require.NotNull("project", project); }
public PageRequesterSettingsProvider(IEnumerable <IPageRequestSettings> settings) { Require.NotNull(settings, nameof(settings)); this.settings = settings.ToDictionary(s => s.Host, s => s, StringComparer.OrdinalIgnoreCase); }
protected override void CheckRequirements() { Require.ProviderIs(StorageProvider.PostgreSql, "Only PostgreSql supports the data type of NpgsqlPolygon"); }
/// <param name="entryPoint"> /// Region that contains the entrypoint, use its MemoryAddress after it has been placed. /// </param> public void SetEntryPoint(Region entryPoint) { Require.Assigned(entryPoint); this.entryPoint = entryPoint; }
public async Task <Payment> AuthorizePayment( OrderCloudIntegrationsCreditCardPayment payment, string userToken, string merchantID ) { Require.That((payment.CreditCardID != null) || (payment.CreditCardDetails != null), new ErrorCode("CreditCard.CreditCardAuth", 400, "Request must include either CreditCardDetails or CreditCardID")); var cc = await GetMeCardDetails(payment, userToken); Require.That(payment.IsValidCvv(cc), new ErrorCode("CreditCardAuth.InvalidCvv", 400, "CVV is required for Credit Card Payment")); Require.That(cc.Token != null, new ErrorCode("CreditCardAuth.InvalidToken", 400, "Credit card must have valid authorization token")); Require.That(cc.xp.CCBillingAddress != null, new ErrorCode("Invalid Bill Address", 400, "Credit card must have a billing address")); var orderWorksheet = await _oc.IntegrationEvents.GetWorksheetAsync <HSOrderWorksheet>(OrderDirection.Incoming, payment.OrderID); var order = orderWorksheet.Order; Require.That(!order.IsSubmitted, new ErrorCode("CreditCardAuth.AlreadySubmitted", 400, "Order has already been submitted")); var ccAmount = _orderCalc.GetCreditCardTotal(orderWorksheet); var ocPaymentsList = (await _oc.Payments.ListAsync <HSPayment>(OrderDirection.Incoming, payment.OrderID, filters: "Type=CreditCard")); var ocPayments = ocPaymentsList.Items; var ocPayment = ocPayments.Any() ? ocPayments[0] : null; if (ocPayment == null) { throw new CatalystBaseException("Payment.MissingCreditCardPayment", 400, "Order is missing credit card payment"); } try { if (ocPayment?.Accepted == true) { if (ocPayment.Amount == ccAmount) { return(ocPayment); } else { await VoidTransactionAsync(ocPayment, order, userToken); } } var call = await _cardConnect.AuthWithoutCapture(CardConnectMapper.Map(cc, order, payment, merchantID, ccAmount)); ocPayment = await WithRetry().ExecuteAsync(() => _oc.Payments.PatchAsync <HSPayment>(OrderDirection.Incoming, order.ID, ocPayment.ID, new PartialPayment { Accepted = true, Amount = ccAmount })); return(await WithRetry().ExecuteAsync(() => _oc.Payments.CreateTransactionAsync(OrderDirection.Incoming, order.ID, ocPayment.ID, CardConnectMapper.Map(ocPayment, call)))); } catch (CreditCardAuthorizationException ex) { ocPayment = await WithRetry().ExecuteAsync(() => _oc.Payments.PatchAsync <HSPayment>(OrderDirection.Incoming, order.ID, ocPayment.ID, new PartialPayment { Accepted = false, Amount = ccAmount })); await WithRetry().ExecuteAsync(() => _oc.Payments.CreateTransactionAsync(OrderDirection.Incoming, order.ID, ocPayment.ID, CardConnectMapper.Map(ocPayment, ex.Response))); throw new CatalystBaseException($"CreditCardAuth.{ex.ApiError.ErrorCode}", 400, ex.ApiError.Message, ex.Response); } }
public void SaveToFile() { codeSection = sections.GetSection(".text"); dataSection = sections.GetSection(".data"); interpSection = sections.GetSection(".interp"); strtabSection = sections.GetSection(".strtab"); rodataSection = sections.GetSection(".rodata"); symtabSection = sections.GetSection(".symtab"); hashSection = sections.GetSection(".hash"); dynsymSection = sections.GetSection(".dynsym"); dynstrSection = sections.GetSection(".dynstr"); dynamicSection = sections.GetSection(".dynamic"); pltSection = sections.GetSection(".plt"); gotpltSection = sections.GetSection(".got.plt"); relapltSection = sections.GetSection(".rela.plt"); debugInfoSection = sections.GetSection(".debug_info"); debugAbbrevSection = sections.GetSection(".debug_abbrev"); debugLineSection = sections.GetSection(".debug_line"); stringTable.WriteTo(strtabSection.AllocateRegion()); long totalSize = SizeOfElfHeader; // readonly FakePlace(interpSection, ref totalSize); FakePlace(strtabSection, ref totalSize); FakePlace(rodataSection, ref totalSize); FakePlace(symtabSection, ref totalSize); FakePlace(hashSection, ref totalSize); FakePlace(dynsymSection, ref totalSize); FakePlace(dynstrSection, ref totalSize); FakePlace(relapltSection, ref totalSize); FakePlace(debugInfoSection, ref totalSize); FakePlace(debugAbbrevSection, ref totalSize); FakePlace(debugLineSection, ref totalSize); // executable FakePlace(codeSection, ref totalSize); FakePlace(pltSection, ref totalSize); // readwrite FakePlace(dataSection, ref totalSize); FakePlace(gotpltSection, ref totalSize); FakePlace(dynamicSection, ref totalSize); //phdr if ((totalSize % 16) != 0) { totalSize += 16 - (totalSize % 16); } totalSize += phdrsz; // section if ((totalSize % 16) != 0) { totalSize += 16 - (totalSize % 16); } totalSize += sectionheadersize; long address = imageBase; address += SizeOfElfHeader; // readonly Place(interpSection, ref address); Place(strtabSection, ref address); Place(rodataSection, ref address); Place(symtabSection, ref address); Place(hashSection, ref address); Place(dynsymSection, ref address); Place(dynstrSection, ref address); Place(relapltSection, ref address); Place(debugInfoSection, ref address); Place(debugAbbrevSection, ref address); Place(debugLineSection, ref address); // readonlyLength = address - interpSection.MemoryAddress; /* * long x = totalSize; * while (x >= MaxPageSize) * { * address += MaxPageSize; * x -= MaxPageSize; * } * address += MaxPageSize; */ // executable Place(codeSection, ref address); Place(pltSection, ref address); // execLength = address - codeSection.MemoryAddress; address += MaxPageSize; // readwrite Place(dataSection, ref address); Place(gotpltSection, ref address); Place(dynamicSection, ref address); readWriteLength = address - dataSection.MemoryAddress; address += MaxPageSize; //phdr if ((address % 16) != 0) { address += 16 - (address % 16); } phdrma = address - 2 * MaxPageSize; address += phdrsz; // section if ((address % 16) != 0) { address += 16 - (address % 16); } address += sectionheadersize; fileImageLength = address - imageBase - 2 * MaxPageSize; Require.True(totalSize == fileImageLength); //TODO: i don't know why i placed this limit here, it seems to work fine without.... // Require.True(fileImageLength < MaxPageSize); sections.ResolvePlaceholders(imageBase); WriteElfHeader(); WriteBody(); using (FileStream f = new FileStream(moduleName, FileMode.Create)) output.WriteToStream(f); #if MONO Mono.Unix.Native.Syscall.chmod(moduleName, (Mono.Unix.Native.FilePermissions) 493); //0755 #endif }
public void All_WhenNull_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => Require.All((int[])null, v => v > 1, "message", "name")); }
private void WriteElfHeader() { //e_ident // EI_MAG0 to EI_MAG3 output.Write(new byte[] { 0x7f, (byte)'E', (byte)'L', (byte)'F' }); // EI_CLASS if (is64bit) { output.WriteByte(2); // ELFCLASS64 } else { output.WriteByte(1); // ELFCLASS32 } // EI_DATA output.WriteByte(1); // ELFDATA2LSB // EI_VERSION output.WriteByte(1); // EV_CURRENT // EI_PAD output.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }); Require.Equals(16, output.Length); //e_type output.WriteInt16(2); //ET_EXEC //e_machine if (is64bit) { output.WriteInt16(62); //EM_X86_64 } else { output.WriteInt16(3); // EM_386 } //e_version output.WriteInt32(1); // EV_CURRENT //e_entry output.WriteNumber(entryPoint.MemoryLocation); if (is64bit) { Require.Equals(32, output.Length); } else { Require.Equals(28, output.Length); } //e_phoff programHeaderTable_fo = output.InsertNumberToken(); //e_shoff sectionHeaderTable_fo = output.InsertNumberToken(); if (is64bit) { Require.Equals(48, output.Length); } else { Require.Equals(36, output.Length); } //e_flags output.WriteInt32(0); //e_ehsize WordToken elfHeaderSize = output.InsertWordToken(); //e_phentsize output.WriteInt16(ProgramHeaderTableEntrySize); //e_phnum output.WriteInt16(ProgramHeaderEntryCount); //e_shentsize output.WriteInt16(SectionHeaderEntrySize); //e_shnum output.WriteInt16(SectionHeaderEntryCount); // e_shstrndx output.WriteInt16(StringHeaderSectionIndex); elfHeaderSize.SetValue(output.Length); Require.Equals(SizeOfElfHeader, output.Length); }
public void All_WhenEmpty_DoesNotThrow() { Require.All(Enumerable.Empty <int>(), v => v > 1, "message", "name"); }
/****************************************************************************************/ #region Constructors /// <summary> /// Initialize the <see cref="ExcelConditionalFormattingCollection"/> /// </summary> /// <param name="worksheet"></param> internal ExcelConditionalFormattingCollection( ExcelWorksheet worksheet) : base( worksheet.NameSpaceManager, worksheet.WorksheetXml.DocumentElement) { Require.Argument(worksheet).IsNotNull("worksheet"); _worksheet = worksheet; SchemaNodeOrder = _worksheet.SchemaNodeOrder; // Look for all the <conditionalFormatting> var conditionalFormattingNodes = TopNode.SelectNodes( "//" + ExcelConditionalFormattingConstants.Paths.ConditionalFormatting, _worksheet.NameSpaceManager); // Check if we found at least 1 node if ((conditionalFormattingNodes != null) && (conditionalFormattingNodes.Count > 0)) { // Foreach <conditionalFormatting> foreach (XmlNode conditionalFormattingNode in conditionalFormattingNodes) { // Check if @sqref attribute exists if (conditionalFormattingNode.Attributes[ExcelConditionalFormattingConstants.Attributes.Sqref] == null) { throw new Exception( ExcelConditionalFormattingConstants.Errors.MissingSqrefAttribute); } // Get the @sqref attribute ExcelAddress address = new ExcelAddress( conditionalFormattingNode.Attributes[ExcelConditionalFormattingConstants.Attributes.Sqref].Value); // Check for all the <cfRules> nodes and load them var cfRuleNodes = conditionalFormattingNode.SelectNodes( ExcelConditionalFormattingConstants.Paths.CfRule, _worksheet.NameSpaceManager); // Foreach <cfRule> inside the current <conditionalFormatting> foreach (XmlNode cfRuleNode in cfRuleNodes) { // Check if @type attribute exists if (cfRuleNode.Attributes[ExcelConditionalFormattingConstants.Attributes.Type] == null) { throw new Exception( ExcelConditionalFormattingConstants.Errors.MissingTypeAttribute); } // Check if @priority attribute exists if (cfRuleNode.Attributes[ExcelConditionalFormattingConstants.Attributes.Priority] == null) { throw new Exception( ExcelConditionalFormattingConstants.Errors.MissingPriorityAttribute); } // Get the <cfRule> main attributes string typeAttribute = ExcelConditionalFormattingHelper.GetAttributeString( cfRuleNode, ExcelConditionalFormattingConstants.Attributes.Type); int priority = ExcelConditionalFormattingHelper.GetAttributeInt( cfRuleNode, ExcelConditionalFormattingConstants.Attributes.Priority); // Transform the @type attribute to EPPlus Rule Type (slighty diferente) var type = ExcelConditionalFormattingRuleType.GetTypeByAttrbiute( typeAttribute, cfRuleNode, _worksheet.NameSpaceManager); // Create the Rule according to the correct type, address and priority var cfRule = ExcelConditionalFormattingRuleFactory.Create( type, address, priority, _worksheet, cfRuleNode); // Add the new rule to the list if (cfRule != null) { _rules.Add(cfRule); } } } } }
private async Task <Application> AddApplicationAsyncInternal(string friendlyName, ApplicationOptions options) { var request = new RestRequest(); request.Method = Method.POST; request.Resource = "Accounts/{AccountSid}/Applications.json"; Require.Argument("FriendlyName", friendlyName); Validate.IsValidLength(friendlyName, 64); request.AddParameter("FriendlyName", friendlyName); // some check for null. in those cases an empty string is a valid value (to remove a URL assignment) if (options != null) { if (options.VoiceUrl != null) { request.AddParameter("VoiceUrl", options.VoiceUrl); } if (options.VoiceMethod.HasValue()) { request.AddParameter("VoiceMethod", options.VoiceMethod.ToString()); } if (options.VoiceFallbackUrl != null) { request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl); } if (options.VoiceFallbackMethod.HasValue()) { request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString()); } if (options.VoiceCallerIdLookup.HasValue) { request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value); } if (options.StatusCallback.HasValue()) { request.AddParameter("StatusCallback", options.StatusCallback); } if (options.StatusCallbackMethod.HasValue()) { request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString()); } if (options.SmsUrl != null) { request.AddParameter("SmsUrl", options.SmsUrl); } if (options.SmsMethod.HasValue()) { request.AddParameter("SmsMethod", options.SmsMethod.ToString()); } if (options.SmsFallbackUrl != null) { request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl); } if (options.SmsFallbackMethod.HasValue()) { request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString()); } } var result = await ExecuteAsync(request, typeof(Application)); return((Application)result); }
public KV1BinarySerializer(Stream stream) { Require.NotNull(stream, nameof(stream)); writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen: true); }
public SumIf(NumericExpressionEvaluator evaluator) { Require.That(evaluator).Named("evaluator").IsNotNull(); _evaluator = evaluator; }
protected override void CheckRequirements() { Require.AllFeaturesSupported(ProviderFeatures.Batches); }
public IndexPageProject ToIndexPageProject(Project project) { Require.NotNull(project, nameof(project)); return(new IndexPageProject(project.ProjectId, project.LandingImage?.SmallPhotoUri, project.Name)); }
public void OneTimeSetUp() => Require.ProviderIs(StorageProvider.SqlServer);
public UnitOfWorkConfig(string sourceName, IsolationLevel isolationLevel, Require require) { this.sourceName = sourceName ?? string.Empty; this.isolationLevel = isolationLevel; this.require = require; }
/// <summary> /// Resets this EdgeGenerator for reuse /// </summary> /// <param name="nodes">Nodes that make up this graph.</param> public void Reset(IEnumerable <Node> nodes) { Require.NotNull("nodes", nodes); mNodes = nodes.ToDictionary(n => n.Name); }