public static IInventoryPostingRuleCommand ToCreateOrMergePatchInventoryPostingRule <TCreateInventoryPostingRule, TMergePatchInventoryPostingRule>(this IInventoryPostingRuleState state)
            where TCreateInventoryPostingRule : ICreateInventoryPostingRule, new()
            where TMergePatchInventoryPostingRule : IMergePatchInventoryPostingRule, new()
        {
            bool bUnsaved = ((IInventoryPostingRuleState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateInventoryPostingRule <TCreateInventoryPostingRule>());
            }
            else
            {
                return(state.ToMergePatchInventoryPostingRule <TMergePatchInventoryPostingRule>());
            }
        }