/// <summary> /// Checks if the /// </summary> /// <param name="searchPath"></param> /// <param name="sourceDirectory"></param> /// <param name="applicationRoot"></param> /// <returns></returns> private static bool IsRootConfig(string searchPath, string sourceDirectory, string applicationRoot) { Mandate.ParameterNotNullOrEmpty(searchPath, "searchPath"); Mandate.ParameterNotNullOrEmpty(sourceDirectory, "sourceDirectory"); Mandate.ParameterCondition(Path.IsPathRooted(sourceDirectory), "sourceDirectory"); Mandate.ParameterCondition(Path.IsPathRooted(applicationRoot), "applicationRoot"); var directoryName = Path.GetDirectoryName(sourceDirectory); if (directoryName.Length < applicationRoot.Length) { return(false); } var pathWithRootRemoved = "~/" + NormaliseRelativeRoot(directoryName.Substring(applicationRoot.Length - 1)); if (pathWithRootRemoved.StartsWith(NormaliseRelativeRoot(searchPath), StringComparison.InvariantCultureIgnoreCase)) { //this is a sub folder of our search path, so we'll assume that it is a local config return(false); } else { //this is not a sub folder or the same folder of our search path so we'll assume that it is a global/root config return(true); } }
//TODO: We need to add an internal cache to this lookup as it gets called quite a few times when dealing with relations private FileSystemInfo GetFile(HiveId id) { Mandate.ParameterCondition(id.Value.Type == HiveIdValueTypes.String, "id"); var directory = new DirectoryInfo(Settings.AbsoluteRootedPath); //if there is an empty id, then we need to return our root //empty id could also be a null string if (id == HiveId.Empty || (id.Value.Type == HiveIdValueTypes.String && ((string)id.Value).IsNullOrWhiteSpace())) { return(directory); } //the value should not begin/end with a DirectorySeperatorChar and should contain '\' instead of '/' var path = ((string)id.Value.Value) .Replace("/", "\\") .TrimEnd(Path.DirectorySeparatorChar) .TrimStart(Path.DirectorySeparatorChar); var combinedPath = Path.Combine(Settings.AbsoluteRootedPath, path); if (Directory.Exists(combinedPath.NormaliseDirectoryPath())) { return(new DirectoryInfo(combinedPath)); } if (System.IO.File.Exists(combinedPath)) { return(new FileInfo(combinedPath)); } return(null); }
/// <summary> /// Creates and saves a payment /// </summary> /// <param name="paymentTfKey">The payment typefield key</param> /// <param name="amount">The amount of the payment</param> /// <param name="paymentMethodKey">The optional paymentMethodKey</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> /// <returns>Returns <see cref="IPayment"/></returns> internal IPayment CreatePaymentWithKey(Guid paymentTfKey, decimal amount, Guid?paymentMethodKey, bool raiseEvents = true) { Mandate.ParameterCondition(!Guid.Empty.Equals(paymentTfKey), "paymentTfKey"); var payment = new Payment(paymentTfKey, amount, paymentMethodKey, new ExtendedDataCollection()); if (raiseEvents) { if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs <IPayment>(payment), this)) { payment.WasCancelled = true; return(payment); } } using (new WriteLock(Locker)) { var uow = UowProvider.GetUnitOfWork(); using (var repository = RepositoryFactory.CreatePaymentRepository(uow)) { repository.AddOrUpdate(payment); uow.Commit(); } } if (raiseEvents) { Created.RaiseEvent(new Events.NewEventArgs <IPayment>(payment), this); } return(payment); }
/// <summary> /// Creates a <see cref="IInvoice"/> without saving it to the database /// </summary> /// <param name="invoiceStatusKey">The <see cref="IInvoiceStatus"/> key</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> /// <returns><see cref="IInvoice"/></returns> public IInvoice CreateInvoice(Guid invoiceStatusKey, bool raiseEvents = true) { Mandate.ParameterCondition(Guid.Empty != invoiceStatusKey, "invoiceStatusKey"); var status = GetInvoiceStatusByKey(invoiceStatusKey); var invoice = new Invoice(status) { VersionKey = Guid.NewGuid(), InvoiceDate = DateTime.Now }; if (raiseEvents) { if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs <IInvoice>(invoice), this)) { invoice.WasCancelled = true; return(invoice); } } if (raiseEvents) { Created.RaiseEvent(new Events.NewEventArgs <IInvoice>(invoice), this); } return(invoice); }
protected override void PersistNewItem(IProduct entity) { Mandate.ParameterCondition(SkuExists(entity.Sku) == false, "Skus must be unique."); ((Product)entity).AddingEntity(); ((ProductVariant)((Product)entity).MasterVariant).VersionKey = Guid.NewGuid(); var factory = new ProductFactory(); var dto = factory.BuildDto(entity); // save the product Database.Insert(dto); entity.Key = dto.Key; // setup and save the master (singular) variant dto.ProductVariantDto.ProductKey = dto.Key; Database.Insert(dto.ProductVariantDto); Database.Insert(dto.ProductVariantDto.ProductVariantIndexDto); ((Product)entity).MasterVariant.ProductKey = dto.ProductVariantDto.ProductKey; ((Product)entity).MasterVariant.Key = dto.ProductVariantDto.Key; ((ProductVariant)((Product)entity).MasterVariant).ExamineId = dto.ProductVariantDto.ProductVariantIndexDto.Id; // save the product options SaveProductOptions(entity); // synchronize the inventory ((ProductVariantRepository)_productVariantRepository).SaveCatalogInventory(((Product)entity).MasterVariant); entity.ResetDirtyProperties(); }
/// <summary> /// Initializes a new instance of the <see cref="CopyEntityTaskBase{T}"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="original"> /// The original. /// </param> protected CopyEntityTaskBase(IMerchelloContext merchelloContext, T original) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); Mandate.ParameterCondition(original is IEntity, "orginal"); _merchelloContext = merchelloContext; _original = original; }
internal HiveId NormaliseId(HiveId path) { Mandate.ParameterCondition(path.Value.Type == HiveIdValueTypes.String, "id"); var pathValue = NormaliseValue(path.Value); return(new HiveId(ProviderMetadata.MappingRoot, ProviderMetadata.Alias, pathValue)); }
/// <summary> /// Saves customer address. /// </summary> /// <param name="customer"> /// The customer. /// </param> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="address"> /// The address. /// </param> /// <returns> /// The <see cref="ICustomerAddress"/>. /// </returns> internal static ICustomerAddress SaveCustomerAddress(this ICustomer customer, IMerchelloContext merchelloContext, ICustomerAddress address) { Mandate.ParameterCondition(address.CustomerKey == customer.Key, "The customer address is not associated with this customer."); var addressList = new List <ICustomerAddress>(); var addresses = customer.Addresses.ToList(); var isUpdate = false; foreach (var adr in addresses) { if (address.IsDefault && adr.Key != address.Key && adr.AddressType == address.AddressType) { adr.IsDefault = false; } if (addresses.Any(x => x.Key == address.Key)) { isUpdate = true; } addressList.Add(adr); } if (!isUpdate) { addresses.Add(address); } ((Customer)customer).Addresses = addresses; merchelloContext.Services.CustomerService.Save(customer); return(address); }
/// <summary> /// Creates a <see cref="IOrder"/> without saving it to the database /// </summary> /// <param name="orderStatusKey"> /// The <see cref="IOrderStatus"/> key /// </param> /// <param name="invoiceKey"> /// The invoice key /// </param> /// <param name="orderNumber"> /// The order Number. /// </param> /// <param name="raiseEvents"> /// Optional boolean indicating whether or not to raise events /// </param> /// <returns> /// The <see cref="IOrder"/>. /// </returns> /// <remarks> /// Order number must be a positive integer value or zero /// </remarks> public IOrder CreateOrder(Guid orderStatusKey, Guid invoiceKey, int orderNumber, bool raiseEvents = true) { Mandate.ParameterCondition(!Guid.Empty.Equals(orderStatusKey), "orderStatusKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(invoiceKey), "invoiceKey"); Mandate.ParameterCondition(orderNumber >= 0, "orderNumber must be greater than or equal to 0"); var status = GetOrderStatusByKey(orderStatusKey); var order = new Order(status, invoiceKey) { VersionKey = Guid.NewGuid(), OrderNumber = orderNumber, OrderDate = DateTime.Now }; if (raiseEvents) { if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs <IOrder>(order), this)) { order.WasCancelled = true; return(order); } } if (raiseEvents) { Created.RaiseEvent(new Events.NewEventArgs <IOrder>(order), this); } return(order); }
/// <summary> /// Gets the next invoice number /// </summary> /// <param name="storeSettingKey">Constant GUID Key of the NextInvoiceNumber store setting</param> /// <param name="validate">Function to execute to validate the next number</param> /// <param name="invoicesCount">The number of invoices needing invoice numbers. Useful when saving multiple new invoices.</param> /// <returns>The next invoice number</returns> public int GetNextInvoiceNumber(Guid storeSettingKey, Func <int> validate, int invoicesCount = 1) { Mandate.ParameterCondition(1 <= invoicesCount, "invoicesCount"); var setting = Get(storeSettingKey); if (string.IsNullOrEmpty(setting.Value)) { setting.Value = "1"; } var nextInvoiceNumber = int.Parse(setting.Value); var max = validate(); if (max == 0) { max++; } nextInvoiceNumber = nextInvoiceNumber >= max ? nextInvoiceNumber : max + 5; var invoiceNumber = nextInvoiceNumber + invoicesCount; setting.Value = invoiceNumber.ToString(CultureInfo.InvariantCulture); PersistUpdatedItem(setting); // this will deal with the cache as well return(invoiceNumber); }
/// <summary> /// Gets the next order number /// </summary> /// <param name="storeSettingKey">Constant GUID Key of the NextOrderNumber store setting</param> /// <param name="validate">Function to execute to validate the next number</param> /// <param name="ordersCount">The number of orders needing invoice orders. Useful when saving multiple new orders.</param> /// <returns>The next order number</returns> public int GetNextOrderNumber(Guid storeSettingKey, Func <int> validate, int ordersCount = 1) { Mandate.ParameterCondition(1 >= ordersCount, "ordersCount"); var setting = Get(storeSettingKey); if (string.IsNullOrEmpty(setting.Value)) { setting.Value = "1"; } var max = validate(); if (max == 0) { max++; } var nextOrderNumber = int.Parse(setting.Value); nextOrderNumber = nextOrderNumber >= max ? nextOrderNumber : max + 5; var orderNumber = nextOrderNumber + ordersCount; setting.Value = orderNumber.ToString(CultureInfo.InvariantCulture); PersistUpdatedItem(setting); return(orderNumber); }
/// <summary> /// The persist updated item. /// </summary> /// <param name="entity"> /// The entity. /// </param> protected override void PersistUpdatedItem(IProductVariant entity) { if (!MandateProductVariantRules(entity)) { return; } Mandate.ParameterCondition(!SkuExists(entity.Sku, entity.Key), "Entity cannot be updated. The sku already exists."); ((Entity)entity).UpdatingEntity(); ((ProductVariant)entity).VersionKey = Guid.NewGuid(); var factory = new ProductVariantFactory( pa => ((ProductVariant)entity).ProductAttributes, ci => ((ProductVariant)entity).CatalogInventoryCollection, dc => ((ProductVariant)entity).DetachedContents); var dto = factory.BuildDto(entity); // update the variant Database.Update(dto); SaveCatalogInventory(entity); SaveDetachedContents(entity); entity.ResetDirtyProperties(); RemoveProductsFromRuntimeCache(new[] { entity.ProductKey }); }
///<summary> ///</summary> ///<param name="id"></param> ///<returns></returns> public static HiveEntityUri ConvertIntToGuid(int id) { Mandate.ParameterCondition(id != 0, "id"); string template = Guid.Empty.ToString("N"); bool isSystem = false; if (id < 0) { // Reset it id = id * -1; // Add a prefix to the generated Guid template = 1 + template.Substring(1); //because it is negative we will deem it a system Uri isSystem = true; } string number = id.ToString(); string guid = template.Substring(0, template.Length - number.Length) + number; var hId = new HiveEntityUri(Guid.Parse(guid)) { _isSystem = isSystem }; return(hId); }
public CatalogInventory(Guid catalogKey, Guid productVariantKey) { Mandate.ParameterCondition(catalogKey != Guid.Empty, "catalogKey"); Mandate.ParameterCondition(productVariantKey != Guid.Empty, "productVariantKey"); _catalogKey = catalogKey; _productVariantKey = productVariantKey; }
/// <summary> /// Initializes a new instance of the <see cref="EntityCollection"/> class. /// </summary> /// <param name="entityTfKey"> /// The entity type field key. /// </param> /// <param name="providerKey"> /// The provider Key. /// </param> public EntityCollection(Guid entityTfKey, Guid providerKey) { Mandate.ParameterCondition(!Guid.Empty.Equals(entityTfKey), "entityKey"); Mandate.ParameterCondition(!Guid.Empty.Equals(providerKey), "providerKey"); _entityTfKey = entityTfKey; _prodiverKey = providerKey; }
internal ShipCountry(Guid catalogKey, string countryCode, IEnumerable <IProvince> provinces) : base(countryCode, provinces) { Mandate.ParameterCondition(catalogKey != Guid.Empty, "catalogKey"); _catalogKey = catalogKey; }
public QueryResultDisplay SearchByDateRange(QueryDisplay query) { var lastActivityDateStart = query.Parameters.FirstOrDefault(x => x.FieldName == "lastActivityDateStart"); var lastActivityDateEnd = query.Parameters.FirstOrDefault(x => x.FieldName == "lastActivityDateEnd"); DateTime startDate; DateTime endDate; Mandate.ParameterNotNull(lastActivityDateStart, "lastActivityDateStart is a required parameter"); Mandate.ParameterCondition(DateTime.TryParse(lastActivityDateStart.Value, out startDate), "Failed to convert lastActivityDateStart to a valid DateTime"); endDate = lastActivityDateEnd == null ? DateTime.MaxValue : DateTime.TryParse(lastActivityDateEnd.Value, out endDate) ? endDate : DateTime.MaxValue; return (_merchello.Query.Customer.Search( startDate, endDate, query.CurrentPage + 1, query.ItemsPerPage, query.SortBy, query.SortDirection)); }
/// <summary> /// Creates a <see cref="IProductVariant"/> of the <see cref="IProduct"/> passed defined by the collection of <see cref="IProductAttribute"/> /// without saving it to the database /// </summary> /// <param name="product"><see cref="IProduct"/></param> /// <param name="name">The name of the product variant</param> /// <param name="sku">The unique sku of the product variant</param> /// <param name="price">The price of the product variant</param> /// <param name="attributes"><see cref="IProductVariant"/></param> /// <returns>Either a new <see cref="IProductVariant"/> or, if one already exists with associated attributes, the existing <see cref="IProductVariant"/></returns> internal IProductVariant CreateProductVariant(IProduct product, string name, string sku, decimal price, ProductAttributeCollection attributes) { Mandate.ParameterNotNull(product, "product"); Mandate.ParameterNotNull(attributes, "attributes"); Mandate.ParameterCondition(attributes.Count >= product.ProductOptions.Count(x => x.Required), "An attribute must be assigned for every required option"); // verify there is not already a variant with these attributes Mandate.ParameterCondition(false == ProductVariantWithAttributesExists(product, attributes), "A ProductVariant already exists for the ProductAttributeCollection"); return(new ProductVariant(product.Key, attributes, name, sku, price) { CostOfGoods = product.CostOfGoods, SalePrice = product.SalePrice, OnSale = product.OnSale, Weight = product.Weight, Length = product.Length, Width = product.Width, Height = product.Height, Barcode = product.Barcode, Available = product.Available, TrackInventory = product.TrackInventory, OutOfStockPurchase = product.OutOfStockPurchase, Taxable = product.Taxable, Shippable = product.Shippable, Download = product.Download }); }
private static string NormaliseRelativeRoot(string path) { Mandate.ParameterNotNullOrEmpty(path, "path"); path = path.Trim('\\'); Mandate.ParameterCondition(!Path.IsPathRooted(path), "path"); return(path.Replace('\\', '/').Trim('/')); }
public Inventory(int warehouseId, Guid productVariantKey) { Mandate.ParameterCondition(warehouseId > 0, "warehouseId"); Mandate.ParameterCondition(productVariantKey != Guid.Empty, "productVariantKey"); _warehouseId = warehouseId; _productVariantKey = productVariantKey; }
/// <summary> /// Gets the first discoverable value from the 'appSettings' section of configuration, by calling <see cref="GetWebAppSettings{TOut}(string,string)"/>. /// </summary> /// <typeparam name="TOut">The type of the value returned.</typeparam> /// <param name="key">The key of the setting.</param> /// <param name="pluginBasePath">The relative plugin root path.</param> /// <returns></returns> public TOut GetSingleWebAppSetting <TOut>(string key, string pluginBasePath) where TOut : class { Mandate.ParameterNotNullOrEmpty(key, "key"); Mandate.ParameterNotNullOrEmpty(pluginBasePath, "pluginBasePath"); Mandate.ParameterCondition(!Path.IsPathRooted(pluginBasePath), "pluginBasePath"); return(GetWebAppSettings <TOut>(key, pluginBasePath).FirstOrDefault()); }
/// <summary> /// Initializes a new instance of the <see cref="EntityCollectionProviderBase"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="collectionKey"> /// The collection Key. /// </param> protected EntityCollectionProviderBase(IMerchelloContext merchelloContext, Guid collectionKey) { Mandate.ParameterCondition(!Guid.Empty.Equals(collectionKey), "collectionKey"); Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); MerchelloContext = merchelloContext; this.CollectionKey = collectionKey; this.Initialize(); }
public NotificationMessage(Guid notificationMethodKey, string name) { Mandate.ParameterCondition(!Guid.Empty.Equals(notificationMethodKey), "notificationMethodKey"); Mandate.ParameterNotNullOrEmpty(name, "name"); _methodKey = notificationMethodKey; _name = name; }
/// <summary> /// Return a customer based on its entityKey /// </summary> /// <param name="entityKey"></param> /// <returns></returns> public ICustomer GetByEntityKey(Guid entityKey) { Mandate.ParameterCondition(entityKey != Guid.Empty, "entityKey"); var q = Querying.Query <ICustomer> .Builder.Where(c => c.EntityKey == entityKey); return(PerformGetByQuery(q).FirstOrDefault()); }
/// <summary> /// Gets a value from the 'appSettings' section of configuration, by first searching for all consumable configuration files contained in /// <paramref name="absolutePluginRoot"/>. /// </summary> /// <typeparam name="TOut">The type of the value returned.</typeparam> /// <param name="key">The key of the setting.</param> /// <param name="applicationRoot">The application root path.</param> /// <param name="absolutePluginRoot">The absolute plugin root path.</param> /// <param name="pluginBasePath">The relative plugin root path.</param> /// <returns></returns> public IEnumerable <TOut> GetWebAppSettings <TOut>(string key, string applicationRoot, string absolutePluginRoot, string pluginBasePath) where TOut : class { Mandate.ParameterNotNullOrEmpty(key, "key"); Mandate.ParameterNotNullOrEmpty(applicationRoot, "applicationRoot"); Mandate.ParameterNotNullOrEmpty(absolutePluginRoot, "absolutePluginRoot"); Mandate.ParameterNotNullOrEmpty(pluginBasePath, "pluginBasePath"); Mandate.ParameterCondition(!Path.IsPathRooted(pluginBasePath), "pluginBasePath"); Mandate.ParameterCondition(Path.IsPathRooted(applicationRoot), "applicationRoot"); Mandate.ParameterCondition(Path.IsPathRooted(absolutePluginRoot), "absolutePluginRoot"); foreach (var searchPath in GetSearchPaths(pluginBasePath, absolutePluginRoot)) { ConfigurationSection section = null; NameValueCollection coll = null; try { // ApplicationSettingsSection has some weirdness where it won't case from the result of GetSection, // the real returntype is KeyValueInternalCollection which is an internal type, however its base // is a public type of NameValueCollection. // We need the section itself for accessing the ElementInformation, but we also need it casted as the collection // for grabbing the values. section = WebConfigurationManager.GetSection("appSettings", searchPath) as ConfigurationSection; coll = (object)section as NameValueCollection; } catch (Exception) { continue; } if (section != null && coll != null) { // By default ASP.NET inherits settings down the config chain. // Since this configuration is purely for overriding in the opposite direction, we specifically don't want to include settings that are // inherited, since in this loop through sub-config locations we may later move to a setting file which contains a specific, genuine overriding value. if (IsRootConfig(searchPath, section.ElementInformation.Source, applicationRoot)) { var inferredAppSettings = coll[key]; if (inferredAppSettings != null) { var tryCast = inferredAppSettings as TOut; if (tryCast != null) { yield return(tryCast); } } } } } var mainValue = WebConfigurationManager.AppSettings[key] as TOut; if (mainValue != null) { yield return(mainValue); } }
/// <summary> /// Gets all the configuration settings matching <paramref name="sectionName"/> by first searching for all consumable configuration files contained in /// <paramref name="absolutePluginRoot"/>. For every configuration found which has a matching section name, yields back the output specified in the provided /// delegate <paramref name="deferred"/>. /// </summary> /// <example> /// If you have a custom <see cref="ConfigurationSection"/> called <see cref="FoundationConfigurationSection"/>, you can ask for a specific setting like so: /// <code> /// var myValue = DeepConfigManager.Default.GetFirstWebSetting<FoundationConfigurationSection, string>("umbraco.foundation", x => x.FoundationSettings.ApplicationTierAlias, "~/App_Plugins"); /// </code> /// This will first scan the ~/App_Plugins folder recursively to find configuraiton settings called 'umbraco.foundation' that are readable as <see cref="FoundationConfigurationSection"/>, /// and for all those it finds (including the main app config) it will invoke the delegate provided in <paramref name="deferred"/>. /// </example> /// <typeparam name="TSection">The type of the section.</typeparam> /// <typeparam name="TOut">The type outputted by the expression in <paramref name="deferred"/>.</typeparam> /// <param name="sectionName">Name of the section in the configuration files.</param> /// <param name="deferred">The deffered expression.</param> /// <param name="applicationRoot">The application root path.</param> /// <param name="absolutePluginRoot">The absolute plugin root path.</param> /// <param name="pluginBasePath">The relative plugin root path.</param> /// <returns></returns> public IEnumerable <TOut> GetWebSettings <TSection, TOut>(string sectionName, Expression <Func <TSection, TOut> > deferred, string applicationRoot, string absolutePluginRoot, string pluginBasePath) where TSection : ConfigurationSection { Mandate.ParameterNotNullOrEmpty(sectionName, "sectionName"); Mandate.ParameterNotNull(deferred, "deferred"); Mandate.ParameterNotNullOrEmpty(applicationRoot, "applicationRoot"); Mandate.ParameterNotNullOrEmpty(absolutePluginRoot, "absolutePluginRoot"); Mandate.ParameterNotNullOrEmpty(pluginBasePath, "pluginBasePath"); Mandate.ParameterCondition(!Path.IsPathRooted(pluginBasePath), "pluginBasePath"); Mandate.ParameterCondition(Path.IsPathRooted(applicationRoot), "applicationRoot"); Mandate.ParameterCondition(Path.IsPathRooted(absolutePluginRoot), "absolutePluginRoot"); var accessorDelegate = deferred.Compile(); var isHosted = System.Web.Hosting.HostingEnvironment.IsHosted; if (!isHosted) { LogHelper.Warn <DeepConfigManager>("DeepConfigManager is designed for web applications, outside of a web context all config elements must follow normal configuraiton rules"); } foreach (var searchPath in GetSearchPaths(pluginBasePath, absolutePluginRoot)) { TSection localSection = null; try { if (isHosted) { localSection = WebConfigurationManager.GetSection(sectionName, searchPath) as TSection; } else { localSection = ConfigurationManager.GetSection(sectionName) as TSection; } } catch (Exception e) { LogHelper.Error <DeepConfigManager>("Error parsing config section in path " + searchPath + ". This config is being skipped.", e); continue; } // By default ASP.NET inherits settings down the config chain. // Since this configuration is purely for overriding in the opposite direction, we specifically don't want to include settings that are // inherited, since in this loop through sub-config locations we may later move to a setting file which contains a specific, genuine overriding value. if (localSection != null && !IsRootConfig(searchPath, localSection.ElementInformation.Source, applicationRoot)) { var val = GetConfigValue(deferred, accessorDelegate, localSection); yield return(val); } } // Finally add the app default to the enumerable at the end var mainSection = WebConfigurationManager.GetSection(sectionName) as TSection; if (mainSection != null) { yield return(accessorDelegate.Invoke(mainSection)); } }
internal Basket(IItemCache itemCache, ICustomerBase customer) { Mandate.ParameterNotNull(itemCache, "ItemCache"); Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Basket, "itemCache"); Mandate.ParameterNotNull(customer, "customer"); _customer = customer; _itemCache = itemCache; }
/// <summary> /// Initializes a new instance of the <see cref="NumericalValueFilterConstraintVisitor"/> class. /// </summary> /// <param name="target"> /// The target. /// </param> /// <param name="op"> /// The op. /// </param> /// <param name="property"> /// The property - either quantity or price /// </param> public NumericalValueFilterConstraintVisitor(decimal target, string op, string property) { Mandate.ParameterNotNullOrEmpty(property, "property"); Mandate.ParameterCondition(property.Equals("quantity") || property.Equals("price"), "property must be 'quantity' or 'price'"); _property = property; this._operator = op; _target = target; FilteredLineItems = new List <ILineItem>(); }
public ReadOnlyUnitOfWork(AbstractDataContext dataContext) : base(dataContext) { Mandate.ParameterNotNull(dataContext, "dataContext"); Mandate.ParameterCondition(dataContext is DataContext, "dataContext"); _repo = new RepositoryReader(dataContext as DataContext); _transaction = DataContext.BeginTransaction(); }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <returns>The <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod) { Mandate.ParameterCondition(invoice.HasIdentity, "The invoice must be saved before a payment can be authorized."); Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); return(invoice.AuthorizePayment(paymentGatewayMethod, new ProcessorArgumentCollection())); }